Skip to content

Commit

Permalink
Rollup merge of rust-lang#113603 - workingjubilee:test-for-98016, r=o…
Browse files Browse the repository at this point in the history
…li-obk

Test simd-wide-sum for codegen error

This adds the necessary test infrastructure to "build-pass" codegen tests, for the purpose of doing that for a single revision of a codegen test. When mir-opts are tested, the output may vary from the usual, and maybe for positive reasons... but we don't necessarily want to output such bad LLVMIR that LLVM starts crashing on it.

Currently when enabling MIR opts at higher levels this LLVMIR is still emitted, but it was previously disabled for getting in mir-opt's way and as this new revision without `// [mir-opt3]build-pass` would make it more likely to, I would like to not see the testing for the actual results regress again just because it was bundled with an ICE check as well.

This fixes rust-lang#98016
  • Loading branch information
matthiaskrgr committed Jul 12, 2023
2 parents ac2e412 + 7dc049c commit 491ac78
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
21 changes: 9 additions & 12 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,16 +541,15 @@ impl TestProps {
}

fn update_pass_mode(&mut self, ln: &str, revision: Option<&str>, config: &Config) {
let check_no_run = |s| {
if config.mode != Mode::Ui && config.mode != Mode::Incremental {
panic!("`{}` header is only supported in UI and incremental tests", s);
}
if config.mode == Mode::Incremental
&& !revision.map_or(false, |r| r.starts_with("cfail"))
&& !self.revisions.iter().all(|r| r.starts_with("cfail"))
{
panic!("`{}` header is only supported in `cfail` incremental tests", s);
let check_no_run = |s| match (config.mode, s) {
(Mode::Ui, _) => (),
(Mode::Codegen, "build-pass") => (),
(Mode::Incremental, _) => {
if revision.is_some() && !self.revisions.iter().all(|r| r.starts_with("cfail")) {
panic!("`{s}` header is only supported in `cfail` incremental tests")
}
}
(mode, _) => panic!("`{s}` header is not supported in `{mode}` tests"),
};
let pass_mode = if config.parse_name_directive(ln, "check-pass") {
check_no_run("check-pass");
Expand All @@ -559,9 +558,7 @@ impl TestProps {
check_no_run("build-pass");
Some(PassMode::Build)
} else if config.parse_name_directive(ln, "run-pass") {
if config.mode != Mode::Ui {
panic!("`run-pass` header is only supported in UI tests")
}
check_no_run("run-pass");
Some(PassMode::Run)
} else {
None
Expand Down
4 changes: 4 additions & 0 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2752,6 +2752,10 @@ impl<'test> TestCx<'test> {
self.fatal_proc_rec("compilation failed!", &proc_res);
}

if let Some(PassMode::Build) = self.pass_mode() {
return;
}

let output_path = self.output_base_name().with_extension("ll");
let proc_res = self.verify_with_filecheck(&output_path);
if !proc_res.status.success() {
Expand Down
12 changes: 8 additions & 4 deletions tests/codegen/simd-wide-sum.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// revisions: llvm mir-opt3
// compile-flags: -C opt-level=3 -Z merge-functions=disabled --edition=2021
// only-x86_64
// ignore-debug: the debug assertions get in the way
// [mir-opt3]compile-flags: -Zmir-opt-level=3
// [mir-opt3]build-pass

// mir-opt3 is a regression test for https://github.com/rust-lang/rust/issues/98016

#![crate_type = "lib"]
#![feature(portable_simd)]
Expand Down Expand Up @@ -47,9 +52,8 @@ pub fn wider_reduce_iter(x: Simd<u8, N>) -> u16 {
#[no_mangle]
// CHECK-LABEL: @wider_reduce_into_iter
pub fn wider_reduce_into_iter(x: Simd<u8, N>) -> u16 {
// FIXME MIR inlining messes up LLVM optimizations.
// WOULD-CHECK: zext <8 x i8>
// WOULD-CHECK-SAME: to <8 x i16>
// WOULD-CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
// CHECK: zext <8 x i8>
// CHECK-SAME: to <8 x i16>
// CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
x.to_array().into_iter().map(u16::from).sum()
}

0 comments on commit 491ac78

Please sign in to comment.