diff options
Diffstat (limited to '')
-rw-r--r-- | tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff (renamed from src/test/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff) | 2 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/branch.rs (renamed from src/test/mir-opt/dest-prop/branch.rs) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff (renamed from src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff (renamed from src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff (renamed from src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff (renamed from src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/copy_propagation_arg.rs (renamed from src/test/mir-opt/dest-prop/copy_propagation_arg.rs) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff (renamed from src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/cycle.rs (renamed from src/test/mir-opt/dest-prop/cycle.rs) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir (renamed from src/test/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/dead_stores_79191.rs (renamed from src/test/mir-opt/dest-prop/dead_stores_79191.rs) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir (renamed from src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir) | 1 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/dead_stores_better.rs (renamed from src/test/mir-opt/dest-prop/dead_stores_better.rs) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff (renamed from src/test/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/simple.rs (renamed from src/test/mir-opt/dest-prop/simple.rs) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/union.main.DestinationPropagation.diff (renamed from src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff) | 3 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/union.rs (renamed from src/test/mir-opt/dest-prop/union.rs) | 0 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.diff | 86 | ||||
-rw-r--r-- | tests/mir-opt/dest-prop/unreachable.rs | 18 |
19 files changed, 105 insertions, 5 deletions
diff --git a/src/test/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff b/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff index 5fa7013d5..9c7296632 100644 --- a/src/test/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff @@ -37,7 +37,7 @@ } bb2: { - switchInt(move _3) -> [false: bb4, otherwise: bb3]; // scope 1 at $DIR/branch.rs:+3:16: +3:22 + switchInt(move _3) -> [0: bb4, otherwise: bb3]; // scope 1 at $DIR/branch.rs:+3:16: +3:22 } bb3: { diff --git a/src/test/mir-opt/dest-prop/branch.rs b/tests/mir-opt/dest-prop/branch.rs index 898c908b1..898c908b1 100644 --- a/src/test/mir-opt/dest-prop/branch.rs +++ b/tests/mir-opt/dest-prop/branch.rs diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff index 4343a5935..4343a5935 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff index 298991b5a..298991b5a 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff index bc88787e6..bc88787e6 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff index d37a9f71d..d37a9f71d 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.rs b/tests/mir-opt/dest-prop/copy_propagation_arg.rs index 31be6c931..31be6c931 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.rs +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.rs diff --git a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff index cfc203c5f..cfc203c5f 100644 --- a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff diff --git a/src/test/mir-opt/dest-prop/cycle.rs b/tests/mir-opt/dest-prop/cycle.rs index 6182878f3..6182878f3 100644 --- a/src/test/mir-opt/dest-prop/cycle.rs +++ b/tests/mir-opt/dest-prop/cycle.rs diff --git a/src/test/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir index 63cac133b..63cac133b 100644 --- a/src/test/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir +++ b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir diff --git a/src/test/mir-opt/dest-prop/dead_stores_79191.rs b/tests/mir-opt/dest-prop/dead_stores_79191.rs index 43e0bf664..43e0bf664 100644 --- a/src/test/mir-opt/dest-prop/dead_stores_79191.rs +++ b/tests/mir-opt/dest-prop/dead_stores_79191.rs diff --git a/src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir index ba7f76d28..26068931a 100644 --- a/src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir +++ b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir @@ -13,7 +13,6 @@ fn f(_1: usize) -> usize { bb0: { nop; // scope 0 at $DIR/dead_stores_better.rs:+1:9: +1:10 nop; // scope 0 at $DIR/dead_stores_better.rs:+1:13: +1:14 - nop; // scope 1 at $DIR/dead_stores_better.rs:+2:5: +2:10 nop; // scope 1 at $DIR/dead_stores_better.rs:+3:9: +3:10 nop; // scope 1 at $DIR/dead_stores_better.rs:+3:9: +3:10 nop; // scope 1 at $DIR/dead_stores_better.rs:+3:5: +3:10 diff --git a/src/test/mir-opt/dest-prop/dead_stores_better.rs b/tests/mir-opt/dest-prop/dead_stores_better.rs index 003ad57d8..003ad57d8 100644 --- a/src/test/mir-opt/dest-prop/dead_stores_better.rs +++ b/tests/mir-opt/dest-prop/dead_stores_better.rs diff --git a/src/test/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff b/tests/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff index c2a3a0025..c2a3a0025 100644 --- a/src/test/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff diff --git a/src/test/mir-opt/dest-prop/simple.rs b/tests/mir-opt/dest-prop/simple.rs index d4c27228f..d4c27228f 100644 --- a/src/test/mir-opt/dest-prop/simple.rs +++ b/tests/mir-opt/dest-prop/simple.rs diff --git a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.diff index 85d994bc8..fbed31788 100644 --- a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.diff @@ -25,11 +25,8 @@ } bb1: { - nop; // scope 0 at $DIR/union.rs:+5:14: +5:30 - nop; // scope 0 at $DIR/union.rs:+5:14: +5:30 StorageDead(_2); // scope 0 at $DIR/union.rs:+5:29: +5:30 StorageLive(_3); // scope 1 at $DIR/union.rs:+7:10: +7:26 - nop; // scope 2 at $DIR/union.rs:+7:19: +7:24 StorageDead(_3); // scope 1 at $DIR/union.rs:+7:26: +7:27 StorageDead(_1); // scope 0 at $DIR/union.rs:+8:1: +8:2 return; // scope 0 at $DIR/union.rs:+8:2: +8:2 diff --git a/src/test/mir-opt/dest-prop/union.rs b/tests/mir-opt/dest-prop/union.rs index eb6cb09fc..eb6cb09fc 100644 --- a/src/test/mir-opt/dest-prop/union.rs +++ b/tests/mir-opt/dest-prop/union.rs diff --git a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.diff b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.diff new file mode 100644 index 000000000..9ea756c27 --- /dev/null +++ b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.diff @@ -0,0 +1,86 @@ +- // MIR for `f` before DestinationPropagation ++ // MIR for `f` after DestinationPropagation + + fn f(_1: T) -> () { + debug a => _1; // in scope 0 at $DIR/unreachable.rs:+0:19: +0:20 + let mut _0: (); // return place in scope 0 at $DIR/unreachable.rs:+0:25: +0:25 + let _2: T; // in scope 0 at $DIR/unreachable.rs:+1:9: +1:10 + let mut _3: bool; // in scope 0 at $DIR/unreachable.rs:+2:8: +2:13 + let _4: (); // in scope 0 at $DIR/unreachable.rs:+3:9: +3:16 + let mut _5: T; // in scope 0 at $DIR/unreachable.rs:+3:11: +3:12 + let mut _6: T; // in scope 0 at $DIR/unreachable.rs:+3:14: +3:15 + let _7: (); // in scope 0 at $DIR/unreachable.rs:+5:9: +5:16 + let mut _8: T; // in scope 0 at $DIR/unreachable.rs:+5:11: +5:12 + let mut _9: T; // in scope 0 at $DIR/unreachable.rs:+5:14: +5:15 + scope 1 { +- debug b => _2; // in scope 1 at $DIR/unreachable.rs:+1:9: +1:10 ++ debug b => _1; // in scope 1 at $DIR/unreachable.rs:+1:9: +1:10 + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/unreachable.rs:+1:9: +1:10 +- _2 = _1; // scope 0 at $DIR/unreachable.rs:+1:13: +1:14 ++ nop; // scope 0 at $DIR/unreachable.rs:+1:9: +1:10 ++ nop; // scope 0 at $DIR/unreachable.rs:+1:13: +1:14 + StorageLive(_3); // scope 1 at $DIR/unreachable.rs:+2:8: +2:13 + _3 = const false; // scope 1 at $DIR/unreachable.rs:+2:8: +2:13 +- goto -> bb3; // scope 1 at $DIR/unreachable.rs:+2:8: +2:13 ++ goto -> bb1; // scope 1 at $DIR/unreachable.rs:+2:8: +2:13 + } + + bb1: { +- StorageLive(_4); // scope 1 at $DIR/unreachable.rs:+3:9: +3:16 +- StorageLive(_5); // scope 1 at $DIR/unreachable.rs:+3:11: +3:12 +- _5 = _1; // scope 1 at $DIR/unreachable.rs:+3:11: +3:12 +- StorageLive(_6); // scope 1 at $DIR/unreachable.rs:+3:14: +3:15 +- _6 = _2; // scope 1 at $DIR/unreachable.rs:+3:14: +3:15 +- _4 = g::<T>(move _5, move _6) -> bb2; // scope 1 at $DIR/unreachable.rs:+3:9: +3:16 +- // mir::Constant +- // + span: $DIR/unreachable.rs:11:9: 11:10 +- // + literal: Const { ty: fn(T, T) {g::<T>}, val: Value(<ZST>) } +- } +- +- bb2: { +- StorageDead(_6); // scope 1 at $DIR/unreachable.rs:+3:15: +3:16 +- StorageDead(_5); // scope 1 at $DIR/unreachable.rs:+3:15: +3:16 +- StorageDead(_4); // scope 1 at $DIR/unreachable.rs:+3:16: +3:17 +- _0 = const (); // scope 1 at $DIR/unreachable.rs:+2:14: +4:6 +- goto -> bb5; // scope 1 at $DIR/unreachable.rs:+2:5: +6:6 +- } +- +- bb3: { + StorageLive(_7); // scope 1 at $DIR/unreachable.rs:+5:9: +5:16 +- StorageLive(_8); // scope 1 at $DIR/unreachable.rs:+5:11: +5:12 +- _8 = _2; // scope 1 at $DIR/unreachable.rs:+5:11: +5:12 ++ nop; // scope 1 at $DIR/unreachable.rs:+5:11: +5:12 ++ nop; // scope 1 at $DIR/unreachable.rs:+5:11: +5:12 + StorageLive(_9); // scope 1 at $DIR/unreachable.rs:+5:14: +5:15 +- _9 = _2; // scope 1 at $DIR/unreachable.rs:+5:14: +5:15 +- _7 = g::<T>(move _8, move _9) -> bb4; // scope 1 at $DIR/unreachable.rs:+5:9: +5:16 ++ _9 = _1; // scope 1 at $DIR/unreachable.rs:+5:14: +5:15 ++ _7 = g::<T>(move _1, move _9) -> bb2; // scope 1 at $DIR/unreachable.rs:+5:9: +5:16 + // mir::Constant + // + span: $DIR/unreachable.rs:13:9: 13:10 + // + literal: Const { ty: fn(T, T) {g::<T>}, val: Value(<ZST>) } + } + +- bb4: { ++ bb2: { + StorageDead(_9); // scope 1 at $DIR/unreachable.rs:+5:15: +5:16 +- StorageDead(_8); // scope 1 at $DIR/unreachable.rs:+5:15: +5:16 ++ nop; // scope 1 at $DIR/unreachable.rs:+5:15: +5:16 + StorageDead(_7); // scope 1 at $DIR/unreachable.rs:+5:16: +5:17 + _0 = const (); // scope 1 at $DIR/unreachable.rs:+4:12: +6:6 +- goto -> bb5; // scope 1 at $DIR/unreachable.rs:+2:5: +6:6 ++ goto -> bb3; // scope 1 at $DIR/unreachable.rs:+2:5: +6:6 + } + +- bb5: { ++ bb3: { + StorageDead(_3); // scope 1 at $DIR/unreachable.rs:+6:5: +6:6 +- StorageDead(_2); // scope 0 at $DIR/unreachable.rs:+7:1: +7:2 ++ nop; // scope 0 at $DIR/unreachable.rs:+7:1: +7:2 + return; // scope 0 at $DIR/unreachable.rs:+7:2: +7:2 + } + } + diff --git a/tests/mir-opt/dest-prop/unreachable.rs b/tests/mir-opt/dest-prop/unreachable.rs new file mode 100644 index 000000000..32b5def98 --- /dev/null +++ b/tests/mir-opt/dest-prop/unreachable.rs @@ -0,0 +1,18 @@ +// Check that unreachable code is removed after the destination propagation. +// Regression test for issue #105428. +// +// compile-flags: --crate-type=lib -Zmir-opt-level=0 +// compile-flags: -Zmir-enable-passes=+ConstProp,+SimplifyConstCondition-after-const-prop,+DestinationPropagation + +// EMIT_MIR unreachable.f.DestinationPropagation.diff +pub fn f<T: Copy>(a: T) { + let b = a; + if false { + g(a, b); + } else { + g(b, b); + } +} + +#[inline(never)] +pub fn g<T: Copy>(_: T, _: T) {} |