Auto merge of #124156 - DianQK:disable-match_branches, r=RalfJung
Some checks failed
CI / bors build finished (push) Blocked by required conditions
CI / try - ${{ matrix.name }} (map[CODEGEN_BACKENDS:llvm,cranelift], dist-x86_64-linux, ubuntu-20.04-16core-64gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], x86_64-gnu-nopt, ubuntu-20.04-4core-16gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], x86_64-gnu-distcheck, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], x86_64-gnu-debug, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], x86_64-gnu-aux, ubuntu-20.04-4core-16gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], x86_64-gnu, ubuntu-20.04-4core-16gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], test-various, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], mingw-check, ubuntu-20.04-4core-16gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], i686-gnu-nopt, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], i686-gnu, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-x86_64-netbsd, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / Calculate job matrix (push) Failing after 12s
CI / auto - ${{ matrix.name }} (map[], dist-x86_64-illumos, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-x86_64-freebsd, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-various-2, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-various-1, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-s390x-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-riscv64-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-powerpc64le-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-powerpc64-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-powerpc-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-ohos, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-loongarch64-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-i686-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-i586-gnu-i586-i686-musl, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-armv7-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-armhf-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-arm-linux, ubuntu-20.04-16core-64gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], dist-android, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], armhf-gnu, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[], arm-android, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[RUST_CONFIGURE_ARGS:--build=x86_64-pc-windows-msvc --enable-profiler SCRIPT:make ci-msvc], x86_64-msvc, windows-2019-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[RUST_CONFIGURE_ARGS:--build=x86_64-pc-windows-msvc --enable-extended --enable-profiler SCRIPT:python x.py dist bootstrap --include-default-paths], dist-x86_64-msvc-alt, windows-2019-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[RUST_CONFIGURE_ARGS:--build=i686-pc-windows-msvc SCRIPT:make ci-msvc], i686-msvc, windows-2019-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[RUST_BACKTRACE:1], x86_64-gnu-llvm-18, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[RUST_BACKTRACE:1], x86_64-gnu-llvm-17, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / master (push) Has been skipped
CI / auto - ${{ matrix.name }} (map[MACOSX_DEPLOYMENT_TARGET:11 MACOSX_STD_DEPLOYMENT_TARGET:11 NO_DEBUG_ASSERTIONS:1 NO_LLVM_ASSERTIONS:1 NO_OVERFLOW_CHECKS:1 RUSTC_RETRY_LINKER_ON_SEGFAULT:1 RUST_CONFIGURE_ARGS:--enable-sanitizers --enable-profiler --set … (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[MACOSX_DEPLOYMENT_TARGET:10.12 NO_DEBUG_ASSERTIONS:1 NO_LLVM_ASSERTIONS:1 NO_OVERFLOW_CHECKS:1 RUSTC_RETRY_LINKER_ON_SEGFAULT:1 RUST_CONFIGURE_ARGS:--enable-sanitizers --enable-profiler --set rust.jemalloc SCRIPT:./x.py d… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[MACOSX_DEPLOYMENT_TARGET:10.12 MACOSX_STD_DEPLOYMENT_TARGET:10.12 NO_DEBUG_ASSERTIONS:1 NO_LLVM_ASSERTIONS:1 NO_OVERFLOW_CHECKS:1 RUSTC_RETRY_LINKER_ON_SEGFAULT:1 RUST_CONFIGURE_ARGS:--build=x86_64-apple-darwin --enable-s… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[DIST_REQUIRE_ALL_TOOLS:1 RUST_CONFIGURE_ARGS:--build=x86_64-pc-windows-msvc --host=x86_64-pc-windows-msvc --target=x86_64-pc-windows-msvc --enable-full-tools --enable-profiler --set rust.codegen-units=1 SCRIPT:python x.py… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[DIST_REQUIRE_ALL_TOOLS:1 RUST_CONFIGURE_ARGS:--build=x86_64-pc-windows-msvc --host=aarch64-pc-windows-msvc --enable-full-tools --enable-profiler SCRIPT:python x.py dist bootstrap --include-default-paths], dist-aarch64-msv… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[DIST_REQUIRE_ALL_TOOLS:1 RUST_CONFIGURE_ARGS:--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler SCRIPT:python x.py dist bootst… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[DIST_REQUIRE_ALL_TOOLS:1 MACOSX_DEPLOYMENT_TARGET:11 MACOSX_STD_DEPLOYMENT_TARGET:11 NO_DEBUG_ASSERTIONS:1 NO_LLVM_ASSERTIONS:1 NO_OVERFLOW_CHECKS:1 RUSTC_RETRY_LINKER_ON_SEGFAULT:1 RUST_CONFIGURE_ARGS:--enable-full-tools… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[DEPLOY_TOOLSTATES_JSON:toolstates-windows.json HOST_TARGET:x86_64-pc-windows-msvc RUST_CONFIGURE_ARGS:--build=x86_64-pc-windows-msvc --enable-lld --save-toolstates=/tmp/toolstate/toolstates.json SCRIPT:python x.py --stage… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[DEPLOY_TOOLSTATES_JSON:toolstates-linux.json], x86_64-gnu-tools, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CUSTOM_MINGW:1 NO_DOWNLOAD_CI_LLVM:1 RUST_CONFIGURE_ARGS:--build=x86_64-pc-windows-gnu --enable-profiler SCRIPT:make ci-mingw], x86_64-mingw, windows-2019-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CUSTOM_MINGW:1 NO_DOWNLOAD_CI_LLVM:1 RUST_CONFIGURE_ARGS:--build=i686-pc-windows-gnu SCRIPT:make ci-mingw], i686-mingw, windows-2019-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CUSTOM_MINGW:1 DIST_REQUIRE_ALL_TOOLS:1 NO_DOWNLOAD_CI_LLVM:1 RUST_CONFIGURE_ARGS:--build=x86_64-pc-windows-gnu --enable-full-tools --enable-profiler SCRIPT:python x.py dist bootstrap --include-default-paths], dist-x86_64… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CUSTOM_MINGW:1 DIST_REQUIRE_ALL_TOOLS:1 NO_DOWNLOAD_CI_LLVM:1 RUST_CONFIGURE_ARGS:--build=i686-pc-windows-gnu --enable-full-tools --enable-profiler SCRIPT:python x.py dist bootstrap --include-default-paths], dist-i686-min… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CODEGEN_BACKENDS:llvm,cranelift], dist-x86_64-musl, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CODEGEN_BACKENDS:llvm,cranelift], dist-x86_64-linux, ubuntu-20.04-16core-64gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CODEGEN_BACKENDS:llvm,cranelift], dist-aarch64-linux, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CODEGEN_BACKENDS:llvm,cranelift IMAGE:dist-x86_64-linux], dist-x86_64-linux-alt, ubuntu-20.04-16core-64gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CODEGEN_BACKENDS:llvm,cranelift DIST_REQUIRE_ALL_TOOLS:1 MACOSX_DEPLOYMENT_TARGET:10.12 NO_DEBUG_ASSERTIONS:1 NO_LLVM_ASSERTIONS:1 NO_OVERFLOW_CHECKS:1 RUSTC_RETRY_LINKER_ON_SEGFAULT:1 RUST_CONFIGURE_ARGS:--enable-full-to… (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CI_ONLY_WHEN_CHANNEL:nightly], x86_64-gnu-integration, ubuntu-20.04-8core-32gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (map[CI_ONLY_WHEN_CHANNEL:nightly IMAGE:x86_64-gnu RUST_CI_OVERRIDE_RELEASE_CHANNEL:stable], x86_64-gnu-stable, ubuntu-20.04-4core-16gb) (push) Waiting to run
CI / auto - ${{ matrix.name }} (aarch64-gnu, [self-hosted ARM64 linux]) (push) Waiting to run
CI / PR - ${{ matrix.name }} (push) Has been skipped

Disable SimplifyToExp in MatchBranchSimplification

Due to the miscompilation mentioned in #124150, We need to disable MatchBranchSimplification temporarily.

To fully resolve this issue, my plan is:
1. Disable SimplifyToExp in MatchBranchSimplification (this PR).
2. Remove all potentially unclear transforms in #124122.
3. Gradually add back the removed transforms (possibly multiple PRs).

r? `@Nilstrieb` or `@oli-obk`
This commit is contained in:
bors 2024-04-20 08:47:07 +00:00
commit a61b14d15e
9 changed files with 160 additions and 202 deletions

View File

@ -41,7 +41,10 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
should_cleanup = true;
continue;
}
if SimplifyToExp::default().simplify(tcx, body, bb_idx, param_env).is_some() {
// unsound: https://github.com/rust-lang/rust/issues/124150
if tcx.sess.opts.unstable_opts.unsound_mir_opts
&& SimplifyToExp::default().simplify(tcx, body, bb_idx, param_env).is_some()
{
should_cleanup = true;
continue;
}

View File

@ -5,42 +5,37 @@
debug i => _1;
let mut _0: u128;
let mut _2: i128;
+ let mut _3: i128;
bb0: {
_2 = discriminant(_1);
- switchInt(move _2) -> [1: bb3, 2: bb4, 3: bb5, 340282366920938463463374607431768211455: bb2, otherwise: bb1];
- }
-
- bb1: {
- unreachable;
- }
-
- bb2: {
- _0 = const core::num::<impl u128>::MAX;
- goto -> bb6;
- }
-
- bb3: {
- _0 = const 1_u128;
- goto -> bb6;
- }
-
- bb4: {
- _0 = const 2_u128;
- goto -> bb6;
- }
-
- bb5: {
- _0 = const 3_u128;
- goto -> bb6;
- }
-
- bb6: {
+ StorageLive(_3);
+ _3 = move _2;
+ _0 = _3 as u128 (IntToInt);
+ StorageDead(_3);
switchInt(move _2) -> [1: bb3, 2: bb4, 3: bb5, 340282366920938463463374607431768211455: bb2, otherwise: bb1];
}
bb1: {
unreachable;
}
bb2: {
_0 = const core::num::<impl u128>::MAX;
goto -> bb6;
}
bb3: {
_0 = const 1_u128;
goto -> bb6;
}
bb4: {
_0 = const 2_u128;
goto -> bb6;
}
bb5: {
_0 = const 3_u128;
goto -> bb6;
}
bb6: {
return;
}
}

View File

@ -5,37 +5,32 @@
debug i => _1;
let mut _0: i8;
let mut _2: i16;
+ let mut _3: i16;
bb0: {
_2 = discriminant(_1);
- switchInt(move _2) -> [65535: bb3, 2: bb4, 65533: bb2, otherwise: bb1];
- }
-
- bb1: {
- unreachable;
- }
-
- bb2: {
- _0 = const -3_i8;
- goto -> bb5;
- }
-
- bb3: {
- _0 = const -1_i8;
- goto -> bb5;
- }
-
- bb4: {
- _0 = const 2_i8;
- goto -> bb5;
- }
-
- bb5: {
+ StorageLive(_3);
+ _3 = move _2;
+ _0 = _3 as i8 (IntToInt);
+ StorageDead(_3);
switchInt(move _2) -> [65535: bb3, 2: bb4, 65533: bb2, otherwise: bb1];
}
bb1: {
unreachable;
}
bb2: {
_0 = const -3_i8;
goto -> bb5;
}
bb3: {
_0 = const -1_i8;
goto -> bb5;
}
bb4: {
_0 = const 2_i8;
goto -> bb5;
}
bb5: {
return;
}
}

View File

@ -5,37 +5,32 @@
debug i => _1;
let mut _0: i16;
let mut _2: i8;
+ let mut _3: i8;
bb0: {
_2 = discriminant(_1);
- switchInt(move _2) -> [255: bb3, 2: bb4, 253: bb2, otherwise: bb1];
- }
-
- bb1: {
- unreachable;
- }
-
- bb2: {
- _0 = const -3_i16;
- goto -> bb5;
- }
-
- bb3: {
- _0 = const -1_i16;
- goto -> bb5;
- }
-
- bb4: {
- _0 = const 2_i16;
- goto -> bb5;
- }
-
- bb5: {
+ StorageLive(_3);
+ _3 = move _2;
+ _0 = _3 as i16 (IntToInt);
+ StorageDead(_3);
switchInt(move _2) -> [255: bb3, 2: bb4, 253: bb2, otherwise: bb1];
}
bb1: {
unreachable;
}
bb2: {
_0 = const -3_i16;
goto -> bb5;
}
bb3: {
_0 = const -1_i16;
goto -> bb5;
}
bb4: {
_0 = const 2_i16;
goto -> bb5;
}
bb5: {
return;
}
}

View File

@ -5,32 +5,27 @@
debug i => _1;
let mut _0: i16;
let mut _2: u8;
+ let mut _3: u8;
bb0: {
_2 = discriminant(_1);
- switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb1];
- }
-
- bb1: {
- unreachable;
- }
-
- bb2: {
- _0 = const 2_i16;
- goto -> bb4;
- }
-
- bb3: {
- _0 = const 1_i16;
- goto -> bb4;
- }
-
- bb4: {
+ StorageLive(_3);
+ _3 = move _2;
+ _0 = _3 as i16 (IntToInt);
+ StorageDead(_3);
switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb1];
}
bb1: {
unreachable;
}
bb2: {
_0 = const 2_i16;
goto -> bb4;
}
bb3: {
_0 = const 1_i16;
goto -> bb4;
}
bb4: {
return;
}
}

View File

@ -5,37 +5,32 @@
debug i => _1;
let mut _0: u16;
let mut _2: u8;
+ let mut _3: u8;
bb0: {
_2 = discriminant(_1);
- switchInt(move _2) -> [1: bb3, 2: bb4, 5: bb2, otherwise: bb1];
- }
-
- bb1: {
- unreachable;
- }
-
- bb2: {
- _0 = const 5_u16;
- goto -> bb5;
- }
-
- bb3: {
- _0 = const 1_u16;
- goto -> bb5;
- }
-
- bb4: {
- _0 = const 2_u16;
- goto -> bb5;
- }
-
- bb5: {
+ StorageLive(_3);
+ _3 = move _2;
+ _0 = _3 as u16 (IntToInt);
+ StorageDead(_3);
switchInt(move _2) -> [1: bb3, 2: bb4, 5: bb2, otherwise: bb1];
}
bb1: {
unreachable;
}
bb2: {
_0 = const 5_u16;
goto -> bb5;
}
bb3: {
_0 = const 1_u16;
goto -> bb5;
}
bb4: {
_0 = const 2_u16;
goto -> bb5;
}
bb5: {
return;
}
}

View File

@ -75,9 +75,7 @@ enum EnumAu8 {
// EMIT_MIR matches_reduce_branches.match_u8_i16.MatchBranchSimplification.diff
fn match_u8_i16(i: EnumAu8) -> i16 {
// CHECK-LABEL: fn match_u8_i16(
// CHECK-NOT: switchInt
// CHECK: _0 = _3 as i16 (IntToInt);
// CHECH: return
// CHECK: switchInt
match i {
EnumAu8::A => 1,
EnumAu8::B => 2,
@ -146,9 +144,7 @@ enum EnumBu8 {
// EMIT_MIR matches_reduce_branches.match_u8_u16.MatchBranchSimplification.diff
fn match_u8_u16(i: EnumBu8) -> u16 {
// CHECK-LABEL: fn match_u8_u16(
// CHECK-NOT: switchInt
// CHECK: _0 = _3 as u16 (IntToInt);
// CHECH: return
// CHECK: switchInt
match i {
EnumBu8::A => 1,
EnumBu8::B => 2,
@ -204,9 +200,7 @@ enum EnumAi8 {
// EMIT_MIR matches_reduce_branches.match_i8_i16.MatchBranchSimplification.diff
fn match_i8_i16(i: EnumAi8) -> i16 {
// CHECK-LABEL: fn match_i8_i16(
// CHECK-NOT: switchInt
// CHECK: _0 = _3 as i16 (IntToInt);
// CHECH: return
// CHECK: switchInt
match i {
EnumAi8::A => -1,
EnumAi8::B => 2,
@ -235,9 +229,7 @@ enum EnumAi16 {
// EMIT_MIR matches_reduce_branches.match_i16_i8.MatchBranchSimplification.diff
fn match_i16_i8(i: EnumAi16) -> i8 {
// CHECK-LABEL: fn match_i16_i8(
// CHECK-NOT: switchInt
// CHECK: _0 = _3 as i8 (IntToInt);
// CHECH: return
// CHECK: switchInt
match i {
EnumAi16::A => -1,
EnumAi16::B => 2,
@ -256,9 +248,7 @@ enum EnumAi128 {
// EMIT_MIR matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff
fn match_i128_u128(i: EnumAi128) -> u128 {
// CHECK-LABEL: fn match_i128_u128(
// CHECK-NOT: switchInt
// CHECK: _0 = _3 as u128 (IntToInt);
// CHECH: return
// CHECK: switchInt
match i {
EnumAi128::A => 1,
EnumAi128::B => 2,

View File

@ -5,32 +5,27 @@
debug e => _1;
let mut _0: u8;
let mut _2: isize;
+ let mut _3: isize;
bb0: {
_2 = discriminant(_1);
- switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1];
- }
-
- bb1: {
- unreachable;
- }
-
- bb2: {
- _0 = const 1_u8;
- goto -> bb4;
- }
-
- bb3: {
- _0 = const 0_u8;
- goto -> bb4;
- }
-
- bb4: {
+ StorageLive(_3);
+ _3 = move _2;
+ _0 = _3 as u8 (IntToInt);
+ StorageDead(_3);
switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1];
}
bb1: {
unreachable;
}
bb2: {
_0 = const 1_u8;
goto -> bb4;
}
bb3: {
_0 = const 0_u8;
goto -> bb4;
}
bb4: {
return;
}
}

View File

@ -5,32 +5,27 @@
debug e => _1;
let mut _0: i8;
let mut _2: isize;
+ let mut _3: isize;
bb0: {
_2 = discriminant(_1);
- switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1];
- }
-
- bb1: {
- unreachable;
- }
-
- bb2: {
- _0 = const 1_i8;
- goto -> bb4;
- }
-
- bb3: {
- _0 = const 0_i8;
- goto -> bb4;
- }
-
- bb4: {
+ StorageLive(_3);
+ _3 = move _2;
+ _0 = _3 as i8 (IntToInt);
+ StorageDead(_3);
switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1];
}
bb1: {
unreachable;
}
bb2: {
_0 = const 1_i8;
goto -> bb4;
}
bb3: {
_0 = const 0_i8;
goto -> bb4;
}
bb4: {
return;
}
}