Skip to content

Commit fc72c0f

Browse files
authored
Rollup merge of #113603 - workingjubilee:test-for-98016, r=oli-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 #98016
2 parents a6fed6a + 7dc049c commit fc72c0f

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

src/tools/compiletest/src/header.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -541,16 +541,15 @@ impl TestProps {
541541
}
542542

543543
fn update_pass_mode(&mut self, ln: &str, revision: Option<&str>, config: &Config) {
544-
let check_no_run = |s| {
545-
if config.mode != Mode::Ui && config.mode != Mode::Incremental {
546-
panic!("`{}` header is only supported in UI and incremental tests", s);
547-
}
548-
if config.mode == Mode::Incremental
549-
&& !revision.map_or(false, |r| r.starts_with("cfail"))
550-
&& !self.revisions.iter().all(|r| r.starts_with("cfail"))
551-
{
552-
panic!("`{}` header is only supported in `cfail` incremental tests", s);
544+
let check_no_run = |s| match (config.mode, s) {
545+
(Mode::Ui, _) => (),
546+
(Mode::Codegen, "build-pass") => (),
547+
(Mode::Incremental, _) => {
548+
if revision.is_some() && !self.revisions.iter().all(|r| r.starts_with("cfail")) {
549+
panic!("`{s}` header is only supported in `cfail` incremental tests")
550+
}
553551
}
552+
(mode, _) => panic!("`{s}` header is not supported in `{mode}` tests"),
554553
};
555554
let pass_mode = if config.parse_name_directive(ln, "check-pass") {
556555
check_no_run("check-pass");
@@ -559,9 +558,7 @@ impl TestProps {
559558
check_no_run("build-pass");
560559
Some(PassMode::Build)
561560
} else if config.parse_name_directive(ln, "run-pass") {
562-
if config.mode != Mode::Ui {
563-
panic!("`run-pass` header is only supported in UI tests")
564-
}
561+
check_no_run("run-pass");
565562
Some(PassMode::Run)
566563
} else {
567564
None

src/tools/compiletest/src/runtest.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2752,6 +2752,10 @@ impl<'test> TestCx<'test> {
27522752
self.fatal_proc_rec("compilation failed!", &proc_res);
27532753
}
27542754

2755+
if let Some(PassMode::Build) = self.pass_mode() {
2756+
return;
2757+
}
2758+
27552759
let output_path = self.output_base_name().with_extension("ll");
27562760
let proc_res = self.verify_with_filecheck(&output_path);
27572761
if !proc_res.status.success() {

tests/codegen/simd-wide-sum.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
// revisions: llvm mir-opt3
12
// compile-flags: -C opt-level=3 -Z merge-functions=disabled --edition=2021
23
// only-x86_64
34
// ignore-debug: the debug assertions get in the way
5+
// [mir-opt3]compile-flags: -Zmir-opt-level=3
6+
// [mir-opt3]build-pass
7+
8+
// mir-opt3 is a regression test for https://github.com/rust-lang/rust/issues/98016
49

510
#![crate_type = "lib"]
611
#![feature(portable_simd)]
@@ -47,9 +52,8 @@ pub fn wider_reduce_iter(x: Simd<u8, N>) -> u16 {
4752
#[no_mangle]
4853
// CHECK-LABEL: @wider_reduce_into_iter
4954
pub fn wider_reduce_into_iter(x: Simd<u8, N>) -> u16 {
50-
// FIXME MIR inlining messes up LLVM optimizations.
51-
// WOULD-CHECK: zext <8 x i8>
52-
// WOULD-CHECK-SAME: to <8 x i16>
53-
// WOULD-CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
55+
// CHECK: zext <8 x i8>
56+
// CHECK-SAME: to <8 x i16>
57+
// CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
5458
x.to_array().into_iter().map(u16::from).sum()
5559
}

0 commit comments

Comments
 (0)