diff options
Diffstat (limited to 'tests/mir-opt/dead-store-elimination')
7 files changed, 61 insertions, 155 deletions
diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs index f09cdee14..dcd15fb2b 100644 --- a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: DeadStoreElimination // compile-flags: -Zmir-enable-passes=+CopyProp diff --git a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff new file mode 100644 index 000000000..cf73358dc --- /dev/null +++ b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff @@ -0,0 +1,29 @@ +- // MIR for `cycle` before DeadStoreElimination ++ // MIR for `cycle` after DeadStoreElimination + + fn cycle(_1: i32, _2: i32, _3: i32) -> () { + let mut _0: (); + let mut _4: bool; +- let mut _5: i32; + + bb0: { + _4 = cond() -> [return: bb1, unwind continue]; + } + + bb1: { + switchInt(_4) -> [1: bb2, otherwise: bb3]; + } + + bb2: { +- _5 = _3; +- _3 = _2; +- _2 = _1; +- _1 = _5; + _4 = cond() -> [return: bb1, unwind continue]; + } + + bb3: { + return; + } + } + diff --git a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-abort.diff b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-abort.diff deleted file mode 100644 index 6221d4780..000000000 --- a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-abort.diff +++ /dev/null @@ -1,73 +0,0 @@ -- // MIR for `cycle` before DeadStoreElimination -+ // MIR for `cycle` after DeadStoreElimination - - fn cycle(_1: i32, _2: i32, _3: i32) -> () { - debug x => _1; - debug y => _2; - debug z => _3; - let mut _0: (); -- let mut _4: (); -- let mut _5: bool; -- let _6: i32; -- let mut _7: i32; -- let mut _8: i32; -- let mut _9: i32; -- let mut _10: !; -- let _11: (); -- let mut _12: !; -+ let mut _4: bool; -+ let _5: i32; - scope 1 { -- debug temp => _6; -+ debug temp => _5; - } - - bb0: { - goto -> bb1; - } - - bb1: { -- StorageLive(_5); -- _5 = cond() -> [return: bb2, unwind unreachable]; -+ StorageLive(_4); -+ _4 = cond() -> [return: bb2, unwind unreachable]; - } - - bb2: { -- switchInt(move _5) -> [0: bb4, otherwise: bb3]; -+ switchInt(move _4) -> [0: bb4, otherwise: bb3]; - } - - bb3: { -- StorageLive(_6); -- _6 = _3; -- StorageLive(_7); -- _7 = _2; -- _3 = move _7; -- StorageDead(_7); -- StorageLive(_8); -- _8 = _1; -- _2 = move _8; -- StorageDead(_8); -- StorageLive(_9); -- _9 = _6; -- _1 = move _9; -- StorageDead(_9); -- _4 = const (); -- StorageDead(_6); -+ StorageLive(_5); - StorageDead(_5); -+ StorageDead(_4); - goto -> bb1; - } - - bb4: { -- StorageLive(_11); - _0 = const (); -- StorageDead(_11); -- StorageDead(_5); -+ StorageDead(_4); - return; - } - } - diff --git a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-unwind.diff b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-unwind.diff deleted file mode 100644 index 4b922e05e..000000000 --- a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-unwind.diff +++ /dev/null @@ -1,73 +0,0 @@ -- // MIR for `cycle` before DeadStoreElimination -+ // MIR for `cycle` after DeadStoreElimination - - fn cycle(_1: i32, _2: i32, _3: i32) -> () { - debug x => _1; - debug y => _2; - debug z => _3; - let mut _0: (); -- let mut _4: (); -- let mut _5: bool; -- let _6: i32; -- let mut _7: i32; -- let mut _8: i32; -- let mut _9: i32; -- let mut _10: !; -- let _11: (); -- let mut _12: !; -+ let mut _4: bool; -+ let _5: i32; - scope 1 { -- debug temp => _6; -+ debug temp => _5; - } - - bb0: { - goto -> bb1; - } - - bb1: { -- StorageLive(_5); -- _5 = cond() -> [return: bb2, unwind continue]; -+ StorageLive(_4); -+ _4 = cond() -> [return: bb2, unwind continue]; - } - - bb2: { -- switchInt(move _5) -> [0: bb4, otherwise: bb3]; -+ switchInt(move _4) -> [0: bb4, otherwise: bb3]; - } - - bb3: { -- StorageLive(_6); -- _6 = _3; -- StorageLive(_7); -- _7 = _2; -- _3 = move _7; -- StorageDead(_7); -- StorageLive(_8); -- _8 = _1; -- _2 = move _8; -- StorageDead(_8); -- StorageLive(_9); -- _9 = _6; -- _1 = move _9; -- StorageDead(_9); -- _4 = const (); -- StorageDead(_6); -+ StorageLive(_5); - StorageDead(_5); -+ StorageDead(_4); - goto -> bb1; - } - - bb4: { -- StorageLive(_11); - _0 = const (); -- StorageDead(_11); -- StorageDead(_5); -+ StorageDead(_4); - return; - } - } - diff --git a/tests/mir-opt/dead-store-elimination/cycle.rs b/tests/mir-opt/dead-store-elimination/cycle.rs index cd34fe96e..8896f5ff3 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.rs +++ b/tests/mir-opt/dead-store-elimination/cycle.rs @@ -1,21 +1,41 @@ -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// skip-filecheck +// This example is interesting because the non-transitive version of `MaybeLiveLocals` would +// report that *all* of these stores are live. +// +// needs-unwind // unit-test: DeadStoreElimination +#![feature(core_intrinsics, custom_mir)] +use std::intrinsics::mir::*; + #[inline(never)] fn cond() -> bool { false } // EMIT_MIR cycle.cycle.DeadStoreElimination.diff +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] fn cycle(mut x: i32, mut y: i32, mut z: i32) { - // This example is interesting because the non-transitive version of `MaybeLiveLocals` would - // report that *all* of these stores are live. - while cond() { - let temp = z; - z = y; - y = x; - x = temp; - } + // We use custom MIR to avoid generating debuginfo, that would force to preserve writes. + mir!( + let condition: bool; + { + Call(condition = cond(), bb1) + } + bb1 = { + match condition { true => bb2, _ => ret } + } + bb2 = { + let temp = z; + z = y; + y = x; + x = temp; + Call(condition = cond(), bb1) + } + ret = { + Return() + } + ) } fn main() { diff --git a/tests/mir-opt/dead-store-elimination/place_mention.rs b/tests/mir-opt/dead-store-elimination/place_mention.rs index 59dc74454..4813cf7ee 100644 --- a/tests/mir-opt/dead-store-elimination/place_mention.rs +++ b/tests/mir-opt/dead-store-elimination/place_mention.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DeadStoreElimination // compile-flags: -Zmir-keep-place-mention diff --git a/tests/mir-opt/dead-store-elimination/provenance_soundness.rs b/tests/mir-opt/dead-store-elimination/provenance_soundness.rs index 11314e990..24ffbe980 100644 --- a/tests/mir-opt/dead-store-elimination/provenance_soundness.rs +++ b/tests/mir-opt/dead-store-elimination/provenance_soundness.rs @@ -1,3 +1,4 @@ +// skip-filecheck // unit-test: DeadStoreElimination // compile-flags: -Zmir-emit-retag |