diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /tests/mir-opt/copy-prop | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/copy-prop')
65 files changed, 1420 insertions, 797 deletions
diff --git a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff deleted file mode 100644 index 51707e716..000000000 --- a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff +++ /dev/null @@ -1,33 +0,0 @@ -- // MIR for `f` before CopyProp -+ // MIR for `f` after CopyProp - - fn f() -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/borrowed_local.rs:+0:11: +0:15 - let mut _1: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - let mut _2: &u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - let mut _3: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - let mut _4: &u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - - bb0: { - _1 = const 5_u8; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - _2 = &_1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - _3 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - _4 = &_3; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - _0 = cmp_ref(_2, _4) -> bb1; // scope 0 at $DIR/borrowed_local.rs:+8:13: +8:45 - // mir::Constant - // + span: $DIR/borrowed_local.rs:24:29: 24:36 - // + literal: Const { ty: for<'a, 'b> fn(&'a u8, &'b u8) -> bool {cmp_ref}, val: Value(<ZST>) } - } - - bb1: { - _0 = opaque::<u8>(_3) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38 - // mir::Constant - // + span: $DIR/borrowed_local.rs:28:28: 28:34 - // + literal: Const { ty: fn(u8) -> bool {opaque::<u8>}, val: Value(<ZST>) } - } - - bb2: { - return; // scope 0 at $DIR/borrowed_local.rs:+15:13: +15:21 - } - } - diff --git a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-abort.diff new file mode 100644 index 000000000..46534076c --- /dev/null +++ b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-abort.diff @@ -0,0 +1,27 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f() -> bool { + let mut _0: bool; + let mut _1: u8; + let mut _2: &u8; + let mut _3: u8; + let mut _4: &u8; + + bb0: { + _1 = const 5_u8; + _2 = &_1; + _3 = _1; + _4 = &_3; + _0 = cmp_ref(_2, _4) -> [return: bb1, unwind unreachable]; + } + + bb1: { + _0 = opaque::<u8>(_3) -> [return: bb2, unwind unreachable]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..b702e3b7d --- /dev/null +++ b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-unwind.diff @@ -0,0 +1,27 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f() -> bool { + let mut _0: bool; + let mut _1: u8; + let mut _2: &u8; + let mut _3: u8; + let mut _4: &u8; + + bb0: { + _1 = const 5_u8; + _2 = &_1; + _3 = _1; + _4 = &_3; + _0 = cmp_ref(_2, _4) -> [return: bb1, unwind continue]; + } + + bb1: { + _0 = opaque::<u8>(_3) -> [return: bb2, unwind continue]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs index 9186da5af..a89b64441 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.rs +++ b/tests/mir-opt/copy-prop/borrowed_local.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp #![feature(custom_mir, core_intrinsics)] diff --git a/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff b/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff deleted file mode 100644 index b78c19d78..000000000 --- a/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff +++ /dev/null @@ -1,65 +0,0 @@ -- // MIR for `foo` before CopyProp -+ // MIR for `foo` after CopyProp - - fn foo() -> i32 { - let mut _0: i32; // return place in scope 0 at $DIR/branch.rs:+0:13: +0:16 - let _1: i32; // in scope 0 at $DIR/branch.rs:+1:9: +1:10 - let mut _3: bool; // in scope 0 at $DIR/branch.rs:+3:16: +3:22 - let _4: i32; // in scope 0 at $DIR/branch.rs:+6:9: +6:14 - scope 1 { - debug x => _1; // in scope 1 at $DIR/branch.rs:+1:9: +1:10 - let _2: i32; // in scope 1 at $DIR/branch.rs:+3:9: +3:10 - scope 2 { - debug y => _2; // in scope 2 at $DIR/branch.rs:+3:9: +3:10 - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/branch.rs:+1:9: +1:10 - _1 = val() -> bb1; // scope 0 at $DIR/branch.rs:+1:13: +1:18 - // mir::Constant - // + span: $DIR/branch.rs:14:13: 14:16 - // + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) } - } - - bb1: { - StorageLive(_2); // scope 1 at $DIR/branch.rs:+3:9: +3:10 - StorageLive(_3); // scope 1 at $DIR/branch.rs:+3:16: +3:22 - _3 = cond() -> bb2; // scope 1 at $DIR/branch.rs:+3:16: +3:22 - // mir::Constant - // + span: $DIR/branch.rs:16:16: 16:20 - // + literal: Const { ty: fn() -> bool {cond}, val: Value(<ZST>) } - } - - bb2: { - switchInt(move _3) -> [0: bb4, otherwise: bb3]; // scope 1 at $DIR/branch.rs:+3:16: +3:22 - } - - bb3: { - _2 = _1; // scope 1 at $DIR/branch.rs:+4:9: +4:10 - goto -> bb6; // scope 1 at $DIR/branch.rs:+3:13: +8:6 - } - - bb4: { - StorageLive(_4); // scope 1 at $DIR/branch.rs:+6:9: +6:14 - _4 = val() -> bb5; // scope 1 at $DIR/branch.rs:+6:9: +6:14 - // mir::Constant - // + span: $DIR/branch.rs:19:9: 19:12 - // + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) } - } - - bb5: { - StorageDead(_4); // scope 1 at $DIR/branch.rs:+6:14: +6:15 - _2 = _1; // scope 1 at $DIR/branch.rs:+7:9: +7:10 - goto -> bb6; // scope 1 at $DIR/branch.rs:+3:13: +8:6 - } - - bb6: { - StorageDead(_3); // scope 1 at $DIR/branch.rs:+8:5: +8:6 - _0 = _2; // scope 2 at $DIR/branch.rs:+10:5: +10:6 - StorageDead(_2); // scope 1 at $DIR/branch.rs:+11:1: +11:2 - StorageDead(_1); // scope 0 at $DIR/branch.rs:+11:1: +11:2 - return; // scope 0 at $DIR/branch.rs:+11:2: +11:2 - } - } - diff --git a/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-abort.diff new file mode 100644 index 000000000..3334cdf92 --- /dev/null +++ b/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-abort.diff @@ -0,0 +1,56 @@ +- // MIR for `foo` before CopyProp ++ // MIR for `foo` after CopyProp + + fn foo() -> i32 { + let mut _0: i32; + let _1: i32; + let mut _3: bool; + let _4: i32; + scope 1 { + debug x => _1; + let _2: i32; + scope 2 { + debug y => _2; + } + } + + bb0: { + StorageLive(_1); + _1 = val() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageLive(_2); + StorageLive(_3); + _3 = cond() -> [return: bb2, unwind unreachable]; + } + + bb2: { + switchInt(move _3) -> [0: bb4, otherwise: bb3]; + } + + bb3: { + _2 = _1; + goto -> bb6; + } + + bb4: { + StorageLive(_4); + _4 = val() -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_4); + _2 = _1; + goto -> bb6; + } + + bb6: { + StorageDead(_3); + _0 = _2; + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..2f92d8818 --- /dev/null +++ b/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-unwind.diff @@ -0,0 +1,56 @@ +- // MIR for `foo` before CopyProp ++ // MIR for `foo` after CopyProp + + fn foo() -> i32 { + let mut _0: i32; + let _1: i32; + let mut _3: bool; + let _4: i32; + scope 1 { + debug x => _1; + let _2: i32; + scope 2 { + debug y => _2; + } + } + + bb0: { + StorageLive(_1); + _1 = val() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageLive(_2); + StorageLive(_3); + _3 = cond() -> [return: bb2, unwind continue]; + } + + bb2: { + switchInt(move _3) -> [0: bb4, otherwise: bb3]; + } + + bb3: { + _2 = _1; + goto -> bb6; + } + + bb4: { + StorageLive(_4); + _4 = val() -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_4); + _2 = _1; + goto -> bb6; + } + + bb6: { + StorageDead(_3); + _0 = _2; + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/branch.rs b/tests/mir-opt/copy-prop/branch.rs index 0a2e16946..c8af1aa7b 100644 --- a/tests/mir-opt/copy-prop/branch.rs +++ b/tests/mir-opt/copy-prop/branch.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that we bail out when there are multiple assignments to the same local. // unit-test: CopyProp fn val() -> i32 { diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff deleted file mode 100644 index 1c7b6494d..000000000 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff +++ /dev/null @@ -1,23 +0,0 @@ -- // MIR for `arg_src` before CopyProp -+ // MIR for `arg_src` after CopyProp - - fn arg_src(_1: i32) -> i32 { - debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:12: +0:17 - let mut _0: i32; // return place in scope 0 at $DIR/copy_propagation_arg.rs:+0:27: +0:30 - let _2: i32; // in scope 0 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 - scope 1 { -- debug y => _2; // in scope 1 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 -+ debug y => _0; // in scope 1 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 - } - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 -- _2 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 -+ _0 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 - _1 = const 123_i32; // scope 1 at $DIR/copy_propagation_arg.rs:+2:5: +2:12 -- _0 = _2; // scope 1 at $DIR/copy_propagation_arg.rs:+3:5: +3:6 -- StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+4:1: +4:2 - return; // scope 0 at $DIR/copy_propagation_arg.rs:+4:2: +4:2 - } - } - diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.panic-abort.diff new file mode 100644 index 000000000..70674a912 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.panic-abort.diff @@ -0,0 +1,23 @@ +- // MIR for `arg_src` before CopyProp ++ // MIR for `arg_src` after CopyProp + + fn arg_src(_1: i32) -> i32 { + debug x => _1; + let mut _0: i32; + let _2: i32; + scope 1 { +- debug y => _2; ++ debug y => _0; + } + + bb0: { +- StorageLive(_2); +- _2 = _1; ++ _0 = _1; + _1 = const 123_i32; +- _0 = _2; +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..70674a912 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.panic-unwind.diff @@ -0,0 +1,23 @@ +- // MIR for `arg_src` before CopyProp ++ // MIR for `arg_src` after CopyProp + + fn arg_src(_1: i32) -> i32 { + debug x => _1; + let mut _0: i32; + let _2: i32; + scope 1 { +- debug y => _2; ++ debug y => _0; + } + + bb0: { +- StorageLive(_2); +- _2 = _1; ++ _0 = _1; + _1 = const 123_i32; +- _0 = _2; +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff deleted file mode 100644 index 24bca3220..000000000 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff +++ /dev/null @@ -1,28 +0,0 @@ -- // MIR for `bar` before CopyProp -+ // MIR for `bar` after CopyProp - - fn bar(_1: u8) -> () { - debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:8: +0:13 - let mut _0: (); // return place in scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +0:19 - let _2: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:+1:5: +1:13 - let mut _3: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+1:5: +1:13 - StorageLive(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 - _3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 - _2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:5: +1:13 - // mir::Constant - // + span: $DIR/copy_propagation_arg.rs:17:5: 17:10 - // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+1:12: +1:13 - StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 - _1 = const 5_u8; // scope 0 at $DIR/copy_propagation_arg.rs:+2:5: +2:10 - _0 = const (); // scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +3:2 - return; // scope 0 at $DIR/copy_propagation_arg.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-abort.diff new file mode 100644 index 000000000..9ec014e2b --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-abort.diff @@ -0,0 +1,25 @@ +- // MIR for `bar` before CopyProp ++ // MIR for `bar` after CopyProp + + fn bar(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: u8; + let mut _3: u8; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; + _2 = dummy(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _1 = const 5_u8; + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..ef9c343a2 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-unwind.diff @@ -0,0 +1,25 @@ +- // MIR for `bar` before CopyProp ++ // MIR for `bar` after CopyProp + + fn bar(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: u8; + let mut _3: u8; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; + _2 = dummy(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _1 = const 5_u8; + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.diff deleted file mode 100644 index 7ab6ebb7d..000000000 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.diff +++ /dev/null @@ -1,18 +0,0 @@ -- // MIR for `baz` before CopyProp -+ // MIR for `baz` after CopyProp - - fn baz(_1: i32) -> i32 { - debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:8: +0:13 - let mut _0: i32; // return place in scope 0 at $DIR/copy_propagation_arg.rs:+0:23: +0:26 - let mut _2: i32; // in scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 - _2 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 - _1 = move _2; // scope 0 at $DIR/copy_propagation_arg.rs:+2:5: +2:10 - StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 - _0 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+3:5: +3:6 - return; // scope 0 at $DIR/copy_propagation_arg.rs:+4:2: +4:2 - } - } - diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.panic-abort.diff new file mode 100644 index 000000000..71facf91d --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.panic-abort.diff @@ -0,0 +1,18 @@ +- // MIR for `baz` before CopyProp ++ // MIR for `baz` after CopyProp + + fn baz(_1: i32) -> i32 { + debug x => _1; + let mut _0: i32; + let mut _2: i32; + + bb0: { + StorageLive(_2); + _2 = _1; + _1 = move _2; + StorageDead(_2); + _0 = _1; + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..71facf91d --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.panic-unwind.diff @@ -0,0 +1,18 @@ +- // MIR for `baz` before CopyProp ++ // MIR for `baz` after CopyProp + + fn baz(_1: i32) -> i32 { + debug x => _1; + let mut _0: i32; + let mut _2: i32; + + bb0: { + StorageLive(_2); + _2 = _1; + _1 = move _2; + StorageDead(_2); + _0 = _1; + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff deleted file mode 100644 index 87708f340..000000000 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff +++ /dev/null @@ -1,28 +0,0 @@ -- // MIR for `foo` before CopyProp -+ // MIR for `foo` after CopyProp - - fn foo(_1: u8) -> () { - debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:8: +0:13 - let mut _0: (); // return place in scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +0:19 - let mut _2: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 - let mut _3: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:+2:15: +2:16 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 - StorageLive(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+2:15: +2:16 - _3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:15: +2:16 - _2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 - // mir::Constant - // + span: $DIR/copy_propagation_arg.rs:12:9: 12:14 - // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+2:16: +2:17 - _1 = move _2; // scope 0 at $DIR/copy_propagation_arg.rs:+2:5: +2:17 - StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+2:16: +2:17 - _0 = const (); // scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +3:2 - return; // scope 0 at $DIR/copy_propagation_arg.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-abort.diff new file mode 100644 index 000000000..81b73e187 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-abort.diff @@ -0,0 +1,25 @@ +- // MIR for `foo` before CopyProp ++ // MIR for `foo` after CopyProp + + fn foo(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let mut _2: u8; + let mut _3: u8; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; + _2 = dummy(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + _1 = move _2; + StorageDead(_2); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..769089e16 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-unwind.diff @@ -0,0 +1,25 @@ +- // MIR for `foo` before CopyProp ++ // MIR for `foo` after CopyProp + + fn foo(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let mut _2: u8; + let mut _3: u8; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; + _2 = dummy(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + _1 = move _2; + StorageDead(_2); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.rs b/tests/mir-opt/copy-prop/copy_propagation_arg.rs index 1b65dcb01..671860da5 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.rs +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that CopyProp does not propagate an assignment to a function argument // (doing so can break usages of the original argument value) // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff deleted file mode 100644 index 160f47bdd..000000000 --- a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff +++ /dev/null @@ -1,31 +0,0 @@ -- // MIR for `f` before CopyProp -+ // MIR for `f` after CopyProp - - fn f(_1: NotCopy) -> () { - let mut _0: (); // return place in scope 0 at $DIR/custom_move_arg.rs:+0:19: +0:19 - let mut _2: NotCopy; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - let mut _3: NotCopy; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - - bb0: { -- _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL -- _0 = opaque::<NotCopy>(move _1) -> bb1; // scope 0 at $DIR/custom_move_arg.rs:+3:9: +3:41 -+ _0 = opaque::<NotCopy>(_1) -> bb1; // scope 0 at $DIR/custom_move_arg.rs:+3:9: +3:41 - // mir::Constant - // + span: $DIR/custom_move_arg.rs:16:24: 16:30 - // + literal: Const { ty: fn(NotCopy) {opaque::<NotCopy>}, val: Value(<ZST>) } - } - - bb1: { -- _3 = move _2; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL -- _0 = opaque::<NotCopy>(_3) -> bb2; // scope 0 at $DIR/custom_move_arg.rs:+7:9: +7:35 -+ _0 = opaque::<NotCopy>(_1) -> bb2; // scope 0 at $DIR/custom_move_arg.rs:+7:9: +7:35 - // mir::Constant - // + span: $DIR/custom_move_arg.rs:20:24: 20:30 - // + literal: Const { ty: fn(NotCopy) {opaque::<NotCopy>}, val: Value(<ZST>) } - } - - bb2: { - return; // scope 0 at $DIR/custom_move_arg.rs:+10:9: +10:17 - } - } - diff --git a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-abort.diff new file mode 100644 index 000000000..7ba853010 --- /dev/null +++ b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-abort.diff @@ -0,0 +1,25 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: NotCopy) -> () { + let mut _0: (); + let mut _2: NotCopy; + let mut _3: NotCopy; + + bb0: { +- _2 = _1; +- _0 = opaque::<NotCopy>(move _1) -> [return: bb1, unwind unreachable]; ++ _0 = opaque::<NotCopy>(_1) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- _3 = move _2; +- _0 = opaque::<NotCopy>(_3) -> [return: bb2, unwind unreachable]; ++ _0 = opaque::<NotCopy>(_1) -> [return: bb2, unwind unreachable]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..eb40183c1 --- /dev/null +++ b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-unwind.diff @@ -0,0 +1,25 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: NotCopy) -> () { + let mut _0: (); + let mut _2: NotCopy; + let mut _3: NotCopy; + + bb0: { +- _2 = _1; +- _0 = opaque::<NotCopy>(move _1) -> [return: bb1, unwind continue]; ++ _0 = opaque::<NotCopy>(_1) -> [return: bb1, unwind continue]; + } + + bb1: { +- _3 = move _2; +- _0 = opaque::<NotCopy>(_3) -> [return: bb2, unwind continue]; ++ _0 = opaque::<NotCopy>(_1) -> [return: bb2, unwind continue]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs index 29c368df8..a90db08fa 100644 --- a/tests/mir-opt/copy-prop/custom_move_arg.rs +++ b/tests/mir-opt/copy-prop/custom_move_arg.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp #![feature(custom_mir, core_intrinsics)] diff --git a/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff b/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff deleted file mode 100644 index 23d92ed1a..000000000 --- a/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff +++ /dev/null @@ -1,60 +0,0 @@ -- // MIR for `main` before CopyProp -+ // MIR for `main` after CopyProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/cycle.rs:+0:11: +0:11 - let mut _1: i32; // in scope 0 at $DIR/cycle.rs:+1:9: +1:14 - let mut _4: i32; // in scope 0 at $DIR/cycle.rs:+4:9: +4:10 - let _5: (); // in scope 0 at $DIR/cycle.rs:+6:5: +6:12 - let mut _6: i32; // in scope 0 at $DIR/cycle.rs:+6:10: +6:11 - scope 1 { - debug x => _1; // in scope 1 at $DIR/cycle.rs:+1:9: +1:14 - let _2: i32; // in scope 1 at $DIR/cycle.rs:+2:9: +2:10 - scope 2 { - debug y => _2; // in scope 2 at $DIR/cycle.rs:+2:9: +2:10 - let _3: i32; // in scope 2 at $DIR/cycle.rs:+3:9: +3:10 - scope 3 { -- debug z => _3; // in scope 3 at $DIR/cycle.rs:+3:9: +3:10 -+ debug z => _2; // in scope 3 at $DIR/cycle.rs:+3:9: +3:10 - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/cycle.rs:+1:9: +1:14 - _1 = val() -> bb1; // scope 0 at $DIR/cycle.rs:+1:17: +1:22 - // mir::Constant - // + span: $DIR/cycle.rs:10:17: 10:20 - // + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) } - } - - bb1: { -- StorageLive(_2); // scope 1 at $DIR/cycle.rs:+2:9: +2:10 - _2 = _1; // scope 1 at $DIR/cycle.rs:+2:13: +2:14 -- StorageLive(_3); // scope 2 at $DIR/cycle.rs:+3:9: +3:10 -- _3 = _2; // scope 2 at $DIR/cycle.rs:+3:13: +3:14 -- StorageLive(_4); // scope 3 at $DIR/cycle.rs:+4:9: +4:10 -- _4 = _3; // scope 3 at $DIR/cycle.rs:+4:9: +4:10 -- _1 = move _4; // scope 3 at $DIR/cycle.rs:+4:5: +4:10 -- StorageDead(_4); // scope 3 at $DIR/cycle.rs:+4:9: +4:10 -+ _1 = _2; // scope 3 at $DIR/cycle.rs:+4:5: +4:10 - StorageLive(_5); // scope 3 at $DIR/cycle.rs:+6:5: +6:12 - StorageLive(_6); // scope 3 at $DIR/cycle.rs:+6:10: +6:11 - _6 = _1; // scope 3 at $DIR/cycle.rs:+6:10: +6:11 - _5 = std::mem::drop::<i32>(move _6) -> bb2; // scope 3 at $DIR/cycle.rs:+6:5: +6:12 - // mir::Constant - // + span: $DIR/cycle.rs:15:5: 15:9 - // + literal: Const { ty: fn(i32) {std::mem::drop::<i32>}, val: Value(<ZST>) } - } - - bb2: { - StorageDead(_6); // scope 3 at $DIR/cycle.rs:+6:11: +6:12 - StorageDead(_5); // scope 3 at $DIR/cycle.rs:+6:12: +6:13 - _0 = const (); // scope 0 at $DIR/cycle.rs:+0:11: +7:2 -- StorageDead(_3); // scope 2 at $DIR/cycle.rs:+7:1: +7:2 -- StorageDead(_2); // scope 1 at $DIR/cycle.rs:+7:1: +7:2 - StorageDead(_1); // scope 0 at $DIR/cycle.rs:+7:1: +7:2 - return; // scope 0 at $DIR/cycle.rs:+7:2: +7:2 - } - } - diff --git a/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-abort.diff new file mode 100644 index 000000000..8f97c4e43 --- /dev/null +++ b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-abort.diff @@ -0,0 +1,54 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); + let mut _1: i32; + let mut _4: i32; + let _5: (); + let mut _6: i32; + scope 1 { + debug x => _1; + let _2: i32; + scope 2 { + debug y => _2; + let _3: i32; + scope 3 { +- debug z => _3; ++ debug z => _2; + } + } + } + + bb0: { + StorageLive(_1); + _1 = val() -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageLive(_2); + _2 = _1; +- StorageLive(_3); +- _3 = _2; +- StorageLive(_4); +- _4 = _3; +- _1 = move _4; +- StorageDead(_4); ++ _1 = _2; + StorageLive(_5); + StorageLive(_6); + _6 = _1; + _5 = std::mem::drop::<i32>(move _6) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + _0 = const (); +- StorageDead(_3); +- StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..e343b7892 --- /dev/null +++ b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff @@ -0,0 +1,54 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); + let mut _1: i32; + let mut _4: i32; + let _5: (); + let mut _6: i32; + scope 1 { + debug x => _1; + let _2: i32; + scope 2 { + debug y => _2; + let _3: i32; + scope 3 { +- debug z => _3; ++ debug z => _2; + } + } + } + + bb0: { + StorageLive(_1); + _1 = val() -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageLive(_2); + _2 = _1; +- StorageLive(_3); +- _3 = _2; +- StorageLive(_4); +- _4 = _3; +- _1 = move _4; +- StorageDead(_4); ++ _1 = _2; + StorageLive(_5); + StorageLive(_6); + _6 = _1; + _5 = std::mem::drop::<i32>(move _6) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + _0 = const (); +- StorageDead(_3); +- StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/cycle.rs b/tests/mir-opt/copy-prop/cycle.rs index da70f6bec..56ec75397 100644 --- a/tests/mir-opt/copy-prop/cycle.rs +++ b/tests/mir-opt/copy-prop/cycle.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that cyclic assignments don't hang CopyProp, and result in reasonable code. // unit-test: CopyProp fn val() -> i32 { diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir deleted file mode 100644 index c56418d88..000000000 --- a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir +++ /dev/null @@ -1,29 +0,0 @@ -// MIR for `f` after CopyProp - -fn f(_1: usize) -> usize { - debug a => _1; // in scope 0 at $DIR/dead_stores_79191.rs:+0:6: +0:11 - let mut _0: usize; // return place in scope 0 at $DIR/dead_stores_79191.rs:+0:23: +0:28 - let _2: usize; // in scope 0 at $DIR/dead_stores_79191.rs:+1:9: +1:10 - let mut _3: usize; // in scope 0 at $DIR/dead_stores_79191.rs:+3:9: +3:10 - let mut _4: usize; // in scope 0 at $DIR/dead_stores_79191.rs:+4:8: +4:9 - scope 1 { - debug b => _2; // in scope 1 at $DIR/dead_stores_79191.rs:+1:9: +1:10 - } - - bb0: { - _2 = _1; // scope 0 at $DIR/dead_stores_79191.rs:+1:13: +1:14 - _1 = const 5_usize; // scope 1 at $DIR/dead_stores_79191.rs:+2:5: +2:10 - _1 = _2; // scope 1 at $DIR/dead_stores_79191.rs:+3:5: +3:10 - StorageLive(_4); // scope 1 at $DIR/dead_stores_79191.rs:+4:8: +4:9 - _4 = _1; // scope 1 at $DIR/dead_stores_79191.rs:+4:8: +4:9 - _0 = id::<usize>(move _4) -> bb1; // scope 1 at $DIR/dead_stores_79191.rs:+4:5: +4:10 - // mir::Constant - // + span: $DIR/dead_stores_79191.rs:13:5: 13:7 - // + literal: Const { ty: fn(usize) -> usize {id::<usize>}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_4); // scope 1 at $DIR/dead_stores_79191.rs:+4:9: +4:10 - return; // scope 0 at $DIR/dead_stores_79191.rs:+5:2: +5:2 - } -} diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-abort.mir b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-abort.mir new file mode 100644 index 000000000..02b88d140 --- /dev/null +++ b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-abort.mir @@ -0,0 +1,26 @@ +// MIR for `f` after CopyProp + +fn f(_1: usize) -> usize { + debug a => _1; + let mut _0: usize; + let _2: usize; + let mut _3: usize; + let mut _4: usize; + scope 1 { + debug b => _2; + } + + bb0: { + _2 = _1; + _1 = const 5_usize; + _1 = _2; + StorageLive(_4); + _4 = _1; + _0 = id::<usize>(move _4) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_4); + return; + } +} diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir new file mode 100644 index 000000000..f8c285ff3 --- /dev/null +++ b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir @@ -0,0 +1,26 @@ +// MIR for `f` after CopyProp + +fn f(_1: usize) -> usize { + debug a => _1; + let mut _0: usize; + let _2: usize; + let mut _3: usize; + let mut _4: usize; + scope 1 { + debug b => _2; + } + + bb0: { + _2 = _1; + _1 = const 5_usize; + _1 = _2; + StorageLive(_4); + _4 = _1; + _0 = id::<usize>(move _4) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_4); + return; + } +} diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.rs b/tests/mir-opt/copy-prop/dead_stores_79191.rs index 84453c55e..4260d35b1 100644 --- a/tests/mir-opt/copy-prop/dead_stores_79191.rs +++ b/tests/mir-opt/copy-prop/dead_stores_79191.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp fn id<T>(x: T) -> T { diff --git a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir deleted file mode 100644 index f35542173..000000000 --- a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir +++ /dev/null @@ -1,29 +0,0 @@ -// MIR for `f` after CopyProp - -fn f(_1: usize) -> usize { - debug a => _1; // in scope 0 at $DIR/dead_stores_better.rs:+0:10: +0:15 - let mut _0: usize; // return place in scope 0 at $DIR/dead_stores_better.rs:+0:27: +0:32 - let _2: usize; // in scope 0 at $DIR/dead_stores_better.rs:+1:9: +1:10 - let mut _3: usize; // in scope 0 at $DIR/dead_stores_better.rs:+3:9: +3:10 - let mut _4: usize; // in scope 0 at $DIR/dead_stores_better.rs:+4:8: +4:9 - scope 1 { - debug b => _2; // in scope 1 at $DIR/dead_stores_better.rs:+1:9: +1:10 - } - - bb0: { - _2 = _1; // scope 0 at $DIR/dead_stores_better.rs:+1:13: +1:14 - _1 = const 5_usize; // scope 1 at $DIR/dead_stores_better.rs:+2:5: +2:10 - _1 = _2; // scope 1 at $DIR/dead_stores_better.rs:+3:5: +3:10 - StorageLive(_4); // scope 1 at $DIR/dead_stores_better.rs:+4:8: +4:9 - _4 = _1; // scope 1 at $DIR/dead_stores_better.rs:+4:8: +4:9 - _0 = id::<usize>(move _4) -> bb1; // scope 1 at $DIR/dead_stores_better.rs:+4:5: +4:10 - // mir::Constant - // + span: $DIR/dead_stores_better.rs:17:5: 17:7 - // + literal: Const { ty: fn(usize) -> usize {id::<usize>}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_4); // scope 1 at $DIR/dead_stores_better.rs:+4:9: +4:10 - return; // scope 0 at $DIR/dead_stores_better.rs:+5:2: +5:2 - } -} diff --git a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-abort.mir b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-abort.mir new file mode 100644 index 000000000..02b88d140 --- /dev/null +++ b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-abort.mir @@ -0,0 +1,26 @@ +// MIR for `f` after CopyProp + +fn f(_1: usize) -> usize { + debug a => _1; + let mut _0: usize; + let _2: usize; + let mut _3: usize; + let mut _4: usize; + scope 1 { + debug b => _2; + } + + bb0: { + _2 = _1; + _1 = const 5_usize; + _1 = _2; + StorageLive(_4); + _4 = _1; + _0 = id::<usize>(move _4) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_4); + return; + } +} diff --git a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir new file mode 100644 index 000000000..f8c285ff3 --- /dev/null +++ b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir @@ -0,0 +1,26 @@ +// MIR for `f` after CopyProp + +fn f(_1: usize) -> usize { + debug a => _1; + let mut _0: usize; + let _2: usize; + let mut _3: usize; + let mut _4: usize; + scope 1 { + debug b => _2; + } + + bb0: { + _2 = _1; + _1 = const 5_usize; + _1 = _2; + StorageLive(_4); + _4 = _1; + _0 = id::<usize>(move _4) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_4); + return; + } +} diff --git a/tests/mir-opt/copy-prop/dead_stores_better.rs b/tests/mir-opt/copy-prop/dead_stores_better.rs index 87b916fd3..c5962db6a 100644 --- a/tests/mir-opt/copy-prop/dead_stores_better.rs +++ b/tests/mir-opt/copy-prop/dead_stores_better.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // This is a copy of the `dead_stores_79191` test, except that we turn on DSE. This demonstrates // that that pass enables this one to do more optimizations. diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff deleted file mode 100644 index e09ccb831..000000000 --- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff +++ /dev/null @@ -1,138 +0,0 @@ -- // MIR for `main` before CopyProp -+ // MIR for `main` after CopyProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue_107511.rs:+0:11: +0:11 - let mut _1: i32; // in scope 0 at $DIR/issue_107511.rs:+1:9: +1:16 - let mut _3: std::ops::Range<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 - let mut _4: std::ops::Range<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 - let mut _5: usize; // in scope 0 at $DIR/issue_107511.rs:+6:17: +6:24 - let mut _6: &[i32]; // in scope 0 at $DIR/issue_107511.rs:+6:17: +6:24 - let mut _7: &[i32; 4]; // in scope 0 at $DIR/issue_107511.rs:+6:17: +6:24 - let mut _9: (); // in scope 0 at $DIR/issue_107511.rs:+0:1: +9:2 - let _10: (); // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 - let mut _11: std::option::Option<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 - let mut _12: &mut std::ops::Range<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 - let mut _13: &mut std::ops::Range<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 - let mut _14: isize; // in scope 0 at $DIR/issue_107511.rs:+6:5: +8:6 - let mut _15: !; // in scope 0 at $DIR/issue_107511.rs:+6:5: +8:6 - let mut _17: i32; // in scope 0 at $DIR/issue_107511.rs:+7:16: +7:20 - let _18: usize; // in scope 0 at $DIR/issue_107511.rs:+7:18: +7:19 - let mut _19: usize; // in scope 0 at $DIR/issue_107511.rs:+7:16: +7:20 - let mut _20: bool; // in scope 0 at $DIR/issue_107511.rs:+7:16: +7:20 - scope 1 { - debug sum => _1; // in scope 1 at $DIR/issue_107511.rs:+1:9: +1:16 - let _2: [i32; 4]; // in scope 1 at $DIR/issue_107511.rs:+2:9: +2:10 - scope 2 { - debug a => _2; // in scope 2 at $DIR/issue_107511.rs:+2:9: +2:10 - let mut _8: std::ops::Range<usize>; // in scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 - scope 3 { - debug iter => _8; // in scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - let _16: usize; // in scope 3 at $DIR/issue_107511.rs:+6:9: +6:10 - scope 4 { - debug i => _16; // in scope 4 at $DIR/issue_107511.rs:+6:9: +6:10 - } - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_107511.rs:+1:9: +1:16 - _1 = const 0_i32; // scope 0 at $DIR/issue_107511.rs:+1:19: +1:20 - StorageLive(_2); // scope 1 at $DIR/issue_107511.rs:+2:9: +2:10 - _2 = [const 0_i32, const 10_i32, const 20_i32, const 30_i32]; // scope 1 at $DIR/issue_107511.rs:+2:13: +2:28 - StorageLive(_3); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 - StorageLive(_4); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 - StorageLive(_5); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 - StorageLive(_6); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 - StorageLive(_7); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 - _7 = &_2; // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 - _6 = move _7 as &[i32] (Pointer(Unsize)); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 - StorageDead(_7); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:18 - _5 = core::slice::<impl [i32]>::len(move _6) -> bb1; // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 - // mir::Constant - // + span: $DIR/issue_107511.rs:11:19: 11:22 - // + literal: Const { ty: for<'a> fn(&'a [i32]) -> usize {core::slice::<impl [i32]>::len}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_6); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24 - _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _5 }; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 - StorageDead(_5); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24 - _3 = <std::ops::Range<usize> as IntoIterator>::into_iter(move _4) -> bb2; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 - // mir::Constant - // + span: $DIR/issue_107511.rs:11:14: 11:24 - // + literal: Const { ty: fn(std::ops::Range<usize>) -> <std::ops::Range<usize> as IntoIterator>::IntoIter {<std::ops::Range<usize> as IntoIterator>::into_iter}, val: Value(<ZST>) } - } - - bb2: { - StorageDead(_4); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24 - StorageLive(_8); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 - _8 = move _3; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 - goto -> bb3; // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6 - } - - bb3: { -- StorageLive(_10); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - StorageLive(_11); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - StorageLive(_12); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - StorageLive(_13); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - _13 = &mut _8; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - _12 = &mut (*_13); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - _11 = <std::ops::Range<usize> as Iterator>::next(move _12) -> bb4; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - // mir::Constant - // + span: $DIR/issue_107511.rs:11:14: 11:24 - // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<usize>) -> Option<<std::ops::Range<usize> as Iterator>::Item> {<std::ops::Range<usize> as Iterator>::next}, val: Value(<ZST>) } - } - - bb4: { - StorageDead(_12); // scope 3 at $DIR/issue_107511.rs:+6:23: +6:24 - _14 = discriminant(_11); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - switchInt(move _14) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - } - - bb5: { -- StorageLive(_16); // scope 3 at $DIR/issue_107511.rs:+6:9: +6:10 - _16 = ((_11 as Some).0: usize); // scope 3 at $DIR/issue_107511.rs:+6:9: +6:10 - StorageLive(_17); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 -- StorageLive(_18); // scope 4 at $DIR/issue_107511.rs:+7:18: +7:19 -- _18 = _16; // scope 4 at $DIR/issue_107511.rs:+7:18: +7:19 - _19 = Len(_2); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 -- _20 = Lt(_18, _19); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 -- assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _18) -> bb8; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 -+ _20 = Lt(_16, _19); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 -+ assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> bb8; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 - } - - bb6: { - unreachable; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 - } - - bb7: { - _0 = const (); // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6 - StorageDead(_13); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 - StorageDead(_11); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 -- StorageDead(_10); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 - StorageDead(_8); // scope 2 at $DIR/issue_107511.rs:+8:5: +8:6 - StorageDead(_3); // scope 2 at $DIR/issue_107511.rs:+8:5: +8:6 - StorageDead(_2); // scope 1 at $DIR/issue_107511.rs:+9:1: +9:2 - StorageDead(_1); // scope 0 at $DIR/issue_107511.rs:+9:1: +9:2 - return; // scope 0 at $DIR/issue_107511.rs:+9:2: +9:2 - } - - bb8: { -- _17 = _2[_18]; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 -+ _17 = _2[_16]; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 - _1 = Add(_1, move _17); // scope 4 at $DIR/issue_107511.rs:+7:9: +7:20 - StorageDead(_17); // scope 4 at $DIR/issue_107511.rs:+7:19: +7:20 -- StorageDead(_18); // scope 4 at $DIR/issue_107511.rs:+7:20: +7:21 -- _10 = const (); // scope 4 at $DIR/issue_107511.rs:+6:25: +8:6 -- StorageDead(_16); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 - StorageDead(_13); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 - StorageDead(_11); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 -- StorageDead(_10); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 -- _9 = const (); // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6 - goto -> bb3; // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6 - } - } - diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff new file mode 100644 index 000000000..a802d0256 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff @@ -0,0 +1,129 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); + let mut _1: i32; + let mut _3: std::ops::Range<usize>; + let mut _4: std::ops::Range<usize>; + let mut _5: usize; + let mut _6: &[i32]; + let mut _7: &[i32; 4]; + let mut _9: (); + let _10: (); + let mut _11: std::option::Option<usize>; + let mut _12: &mut std::ops::Range<usize>; + let mut _13: &mut std::ops::Range<usize>; + let mut _14: isize; + let mut _15: !; + let mut _17: i32; + let _18: usize; + let mut _19: usize; + let mut _20: bool; + scope 1 { + debug sum => _1; + let _2: [i32; 4]; + scope 2 { + debug a => _2; + let mut _8: std::ops::Range<usize>; + scope 3 { + debug iter => _8; + let _16: usize; + scope 4 { + debug i => _16; + } + } + } + } + + bb0: { + StorageLive(_1); + _1 = const 0_i32; + StorageLive(_2); + _2 = [const 0_i32, const 10_i32, const 20_i32, const 30_i32]; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); + _7 = &_2; + _6 = move _7 as &[i32] (PointerCoercion(Unsize)); + StorageDead(_7); + _5 = core::slice::<impl [i32]>::len(move _6) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_6); + _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _5 }; + StorageDead(_5); + _3 = <std::ops::Range<usize> as IntoIterator>::into_iter(move _4) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_4); + StorageLive(_8); + _8 = move _3; + goto -> bb3; + } + + bb3: { +- StorageLive(_10); + StorageLive(_11); + StorageLive(_12); + StorageLive(_13); + _13 = &mut _8; + _12 = &mut (*_13); + _11 = <std::ops::Range<usize> as Iterator>::next(move _12) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_12); + _14 = discriminant(_11); + switchInt(move _14) -> [0: bb7, 1: bb5, otherwise: bb6]; + } + + bb5: { +- StorageLive(_16); + _16 = ((_11 as Some).0: usize); + StorageLive(_17); +- StorageLive(_18); +- _18 = _16; + _19 = Len(_2); +- _20 = Lt(_18, _19); +- assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _18) -> [success: bb8, unwind unreachable]; ++ _20 = Lt(_16, _19); ++ assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> [success: bb8, unwind unreachable]; + } + + bb6: { + unreachable; + } + + bb7: { + _0 = const (); + StorageDead(_13); + StorageDead(_11); +- StorageDead(_10); + StorageDead(_8); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); + return; + } + + bb8: { +- _17 = _2[_18]; ++ _17 = _2[_16]; + _1 = Add(_1, move _17); + StorageDead(_17); +- StorageDead(_18); +- _10 = const (); +- StorageDead(_16); + StorageDead(_13); + StorageDead(_11); +- StorageDead(_10); +- _9 = const (); + goto -> bb3; + } + } + diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..35f852098 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff @@ -0,0 +1,129 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); + let mut _1: i32; + let mut _3: std::ops::Range<usize>; + let mut _4: std::ops::Range<usize>; + let mut _5: usize; + let mut _6: &[i32]; + let mut _7: &[i32; 4]; + let mut _9: (); + let _10: (); + let mut _11: std::option::Option<usize>; + let mut _12: &mut std::ops::Range<usize>; + let mut _13: &mut std::ops::Range<usize>; + let mut _14: isize; + let mut _15: !; + let mut _17: i32; + let _18: usize; + let mut _19: usize; + let mut _20: bool; + scope 1 { + debug sum => _1; + let _2: [i32; 4]; + scope 2 { + debug a => _2; + let mut _8: std::ops::Range<usize>; + scope 3 { + debug iter => _8; + let _16: usize; + scope 4 { + debug i => _16; + } + } + } + } + + bb0: { + StorageLive(_1); + _1 = const 0_i32; + StorageLive(_2); + _2 = [const 0_i32, const 10_i32, const 20_i32, const 30_i32]; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); + _7 = &_2; + _6 = move _7 as &[i32] (PointerCoercion(Unsize)); + StorageDead(_7); + _5 = core::slice::<impl [i32]>::len(move _6) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_6); + _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _5 }; + StorageDead(_5); + _3 = <std::ops::Range<usize> as IntoIterator>::into_iter(move _4) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_4); + StorageLive(_8); + _8 = move _3; + goto -> bb3; + } + + bb3: { +- StorageLive(_10); + StorageLive(_11); + StorageLive(_12); + StorageLive(_13); + _13 = &mut _8; + _12 = &mut (*_13); + _11 = <std::ops::Range<usize> as Iterator>::next(move _12) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_12); + _14 = discriminant(_11); + switchInt(move _14) -> [0: bb7, 1: bb5, otherwise: bb6]; + } + + bb5: { +- StorageLive(_16); + _16 = ((_11 as Some).0: usize); + StorageLive(_17); +- StorageLive(_18); +- _18 = _16; + _19 = Len(_2); +- _20 = Lt(_18, _19); +- assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _18) -> [success: bb8, unwind continue]; ++ _20 = Lt(_16, _19); ++ assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> [success: bb8, unwind continue]; + } + + bb6: { + unreachable; + } + + bb7: { + _0 = const (); + StorageDead(_13); + StorageDead(_11); +- StorageDead(_10); + StorageDead(_8); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); + return; + } + + bb8: { +- _17 = _2[_18]; ++ _17 = _2[_16]; + _1 = Add(_1, move _17); + StorageDead(_17); +- StorageDead(_18); +- _10 = const (); +- StorageDead(_16); + StorageDead(_13); + StorageDead(_11); +- StorageDead(_10); +- _9 = const (); + goto -> bb3; + } + } + diff --git a/tests/mir-opt/copy-prop/issue_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs index 2b00ff155..ce6fcc17b 100644 --- a/tests/mir-opt/copy-prop/issue_107511.rs +++ b/tests/mir-opt/copy-prop/issue_107511.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp // EMIT_MIR issue_107511.main.CopyProp.diff diff --git a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff deleted file mode 100644 index 650bd66a7..000000000 --- a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff +++ /dev/null @@ -1,40 +0,0 @@ -- // MIR for `f` before CopyProp -+ // MIR for `f` after CopyProp - - fn f(_1: T) -> () { - debug a => _1; // in scope 0 at $DIR/move_arg.rs:+0:19: +0:20 - let mut _0: (); // return place in scope 0 at $DIR/move_arg.rs:+0:25: +0:25 - let _2: T; // in scope 0 at $DIR/move_arg.rs:+1:9: +1:10 - let _3: (); // in scope 0 at $DIR/move_arg.rs:+2:5: +2:12 - let mut _4: T; // in scope 0 at $DIR/move_arg.rs:+2:7: +2:8 - let mut _5: T; // in scope 0 at $DIR/move_arg.rs:+2:10: +2:11 - scope 1 { -- debug b => _2; // in scope 1 at $DIR/move_arg.rs:+1:9: +1:10 -+ debug b => _1; // in scope 1 at $DIR/move_arg.rs:+1:9: +1:10 - } - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/move_arg.rs:+1:9: +1:10 -- _2 = _1; // scope 0 at $DIR/move_arg.rs:+1:13: +1:14 - StorageLive(_3); // scope 1 at $DIR/move_arg.rs:+2:5: +2:12 -- StorageLive(_4); // scope 1 at $DIR/move_arg.rs:+2:7: +2:8 -- _4 = _1; // scope 1 at $DIR/move_arg.rs:+2:7: +2:8 -- StorageLive(_5); // scope 1 at $DIR/move_arg.rs:+2:10: +2:11 -- _5 = _2; // scope 1 at $DIR/move_arg.rs:+2:10: +2:11 -- _3 = g::<T>(move _4, move _5) -> bb1; // scope 1 at $DIR/move_arg.rs:+2:5: +2:12 -+ _3 = g::<T>(_1, _1) -> bb1; // scope 1 at $DIR/move_arg.rs:+2:5: +2:12 - // mir::Constant - // + span: $DIR/move_arg.rs:8:5: 8:6 - // + literal: Const { ty: fn(T, T) {g::<T>}, val: Value(<ZST>) } - } - - bb1: { -- StorageDead(_5); // scope 1 at $DIR/move_arg.rs:+2:11: +2:12 -- StorageDead(_4); // scope 1 at $DIR/move_arg.rs:+2:11: +2:12 - StorageDead(_3); // scope 1 at $DIR/move_arg.rs:+2:12: +2:13 - _0 = const (); // scope 0 at $DIR/move_arg.rs:+0:25: +3:2 -- StorageDead(_2); // scope 0 at $DIR/move_arg.rs:+3:1: +3:2 - return; // scope 0 at $DIR/move_arg.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-abort.diff new file mode 100644 index 000000000..cf04f213e --- /dev/null +++ b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-abort.diff @@ -0,0 +1,37 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: T) -> () { + debug a => _1; + let mut _0: (); + let _2: T; + let _3: (); + let mut _4: T; + let mut _5: T; + scope 1 { +- debug b => _2; ++ debug b => _1; + } + + bb0: { +- StorageLive(_2); +- _2 = _1; + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- StorageLive(_5); +- _5 = _2; +- _3 = g::<T>(move _4, move _5) -> [return: bb1, unwind unreachable]; ++ _3 = g::<T>(_1, _1) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_5); +- StorageDead(_4); + StorageDead(_3); + _0 = const (); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..0c6a3c6d5 --- /dev/null +++ b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff @@ -0,0 +1,37 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: T) -> () { + debug a => _1; + let mut _0: (); + let _2: T; + let _3: (); + let mut _4: T; + let mut _5: T; + scope 1 { +- debug b => _2; ++ debug b => _1; + } + + bb0: { +- StorageLive(_2); +- _2 = _1; + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- StorageLive(_5); +- _5 = _2; +- _3 = g::<T>(move _4, move _5) -> [return: bb1, unwind continue]; ++ _3 = g::<T>(_1, _1) -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageDead(_5); +- StorageDead(_4); + StorageDead(_3); + _0 = const (); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/move_arg.rs b/tests/mir-opt/copy-prop/move_arg.rs index f88d9a9e7..a3a04e57b 100644 --- a/tests/mir-opt/copy-prop/move_arg.rs +++ b/tests/mir-opt/copy-prop/move_arg.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Test that we do not move multiple times from the same local. // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff deleted file mode 100644 index beb85d68a..000000000 --- a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff +++ /dev/null @@ -1,31 +0,0 @@ -- // MIR for `f` before CopyProp -+ // MIR for `f` after CopyProp - - fn f(_1: Foo) -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/move_projection.rs:+0:17: +0:21 - let mut _2: Foo; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - let mut _3: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - - bb0: { -- _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL -- _3 = move (_2.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL -- _0 = opaque::<Foo>(move _1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44 -+ _3 = (_1.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL -+ _0 = opaque::<Foo>(_1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44 - // mir::Constant - // + span: $DIR/move_projection.rs:20:28: 20:34 - // + literal: Const { ty: fn(Foo) -> bool {opaque::<Foo>}, val: Value(<ZST>) } - } - - bb1: { - _0 = opaque::<u8>(move _3) -> bb2; // scope 0 at $DIR/move_projection.rs:+9:13: +9:44 - // mir::Constant - // + span: $DIR/move_projection.rs:23:28: 23:34 - // + literal: Const { ty: fn(u8) -> bool {opaque::<u8>}, val: Value(<ZST>) } - } - - bb2: { - return; // scope 0 at $DIR/move_projection.rs:+12:13: +12:21 - } - } - diff --git a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-abort.diff new file mode 100644 index 000000000..b2b89968d --- /dev/null +++ b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-abort.diff @@ -0,0 +1,25 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: Foo) -> bool { + let mut _0: bool; + let mut _2: Foo; + let mut _3: u8; + + bb0: { +- _2 = _1; +- _3 = move (_2.0: u8); +- _0 = opaque::<Foo>(move _1) -> [return: bb1, unwind unreachable]; ++ _3 = (_1.0: u8); ++ _0 = opaque::<Foo>(_1) -> [return: bb1, unwind unreachable]; + } + + bb1: { + _0 = opaque::<u8>(move _3) -> [return: bb2, unwind unreachable]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..ad3889639 --- /dev/null +++ b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-unwind.diff @@ -0,0 +1,25 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: Foo) -> bool { + let mut _0: bool; + let mut _2: Foo; + let mut _3: u8; + + bb0: { +- _2 = _1; +- _3 = move (_2.0: u8); +- _0 = opaque::<Foo>(move _1) -> [return: bb1, unwind continue]; ++ _3 = (_1.0: u8); ++ _0 = opaque::<Foo>(_1) -> [return: bb1, unwind continue]; + } + + bb1: { + _0 = opaque::<u8>(move _3) -> [return: bb2, unwind continue]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs index c158c69e0..40f51ce84 100644 --- a/tests/mir-opt/copy-prop/move_projection.rs +++ b/tests/mir-opt/copy-prop/move_projection.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: CopyProp #![feature(custom_mir, core_intrinsics)] diff --git a/tests/mir-opt/copy-prop/mutate_through_pointer.f.CopyProp.diff b/tests/mir-opt/copy-prop/mutate_through_pointer.f.CopyProp.diff index 61fdd6f8c..7f6802bee 100644 --- a/tests/mir-opt/copy-prop/mutate_through_pointer.f.CopyProp.diff +++ b/tests/mir-opt/copy-prop/mutate_through_pointer.f.CopyProp.diff @@ -2,18 +2,18 @@ + // MIR for `f` after CopyProp fn f(_1: bool) -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/mutate_through_pointer.rs:+0:18: +0:22 - let mut _2: bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - let mut _3: *const bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - let mut _4: *mut bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _0: bool; + let mut _2: bool; + let mut _3: *const bool; + let mut _4: *mut bool; bb0: { - _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - _3 = &raw const _2; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - _4 = &raw mut (*_3); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - (*_4) = const false; // scope 0 at $DIR/mutate_through_pointer.rs:+5:9: +5:20 - _0 = _1; // scope 0 at $DIR/mutate_through_pointer.rs:+6:9: +6:16 - return; // scope 0 at $DIR/mutate_through_pointer.rs:+7:9: +7:17 + _2 = _1; + _3 = &raw const _2; + _4 = &raw mut (*_3); + (*_4) = const false; + _0 = _1; + return; } } diff --git a/tests/mir-opt/copy-prop/non_dominate.f.CopyProp.diff b/tests/mir-opt/copy-prop/non_dominate.f.CopyProp.diff index 9760fd374..5bf233594 100644 --- a/tests/mir-opt/copy-prop/non_dominate.f.CopyProp.diff +++ b/tests/mir-opt/copy-prop/non_dominate.f.CopyProp.diff @@ -2,28 +2,28 @@ + // MIR for `f` after CopyProp fn f(_1: bool) -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/non_dominate.rs:+0:18: +0:22 - let mut _2: bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL - let mut _3: bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _0: bool; + let mut _2: bool; + let mut _3: bool; bb0: { - goto -> bb1; // scope 0 at $DIR/non_dominate.rs:+4:11: +4:20 + goto -> bb1; } bb1: { - _3 = _1; // scope 0 at $DIR/non_dominate.rs:+5:17: +5:22 - switchInt(_3) -> [0: bb3, otherwise: bb2]; // scope 0 at $DIR/non_dominate.rs:+5:24: +5:58 + _3 = _1; + switchInt(_3) -> [0: bb3, otherwise: bb2]; } bb2: { - _2 = _3; // scope 0 at $DIR/non_dominate.rs:+8:17: +8:22 - _1 = const false; // scope 0 at $DIR/non_dominate.rs:+8:24: +8:33 - goto -> bb1; // scope 0 at $DIR/non_dominate.rs:+8:35: +8:44 + _2 = _3; + _1 = const false; + goto -> bb1; } bb3: { - _0 = _2; // scope 0 at $DIR/non_dominate.rs:+9:17: +9:24 - return; // scope 0 at $DIR/non_dominate.rs:+9:26: +9:34 + _0 = _2; + return; } } diff --git a/tests/mir-opt/copy-prop/partial_init.main.CopyProp.diff b/tests/mir-opt/copy-prop/partial_init.main.CopyProp.diff index 586643905..7094ee391 100644 --- a/tests/mir-opt/copy-prop/partial_init.main.CopyProp.diff +++ b/tests/mir-opt/copy-prop/partial_init.main.CopyProp.diff @@ -2,12 +2,12 @@ + // MIR for `main` after CopyProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/partial_init.rs:+0:15: +0:15 - let mut _1: (isize,); // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _0: (); + let mut _1: (isize,); bb0: { - (_1.0: isize) = const 1_isize; // scope 0 at $DIR/partial_init.rs:+4:13: +4:20 - return; // scope 0 at $DIR/partial_init.rs:+5:13: +5:21 + (_1.0: isize) = const 1_isize; + return; } } diff --git a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff deleted file mode 100644 index b4a248245..000000000 --- a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff +++ /dev/null @@ -1,56 +0,0 @@ -- // MIR for `demiraw` before CopyProp -+ // MIR for `demiraw` after CopyProp - - fn demiraw(_1: u8) -> () { - debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:12: +0:17 - let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:23: +0:23 - let _2: *mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 - let mut _4: &mut u8; // in scope 0 at $DIR/reborrow.rs:+2:22: +2:29 - let _6: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14 - let mut _7: *mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13 - scope 1 { - debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 - let _3: &mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 - scope 2 { - debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 - let _5: *mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 - scope 4 { -- debug c => _5; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 -+ debug c => _2; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 - } - } - scope 3 { - } - } - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 - _2 = &raw mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:23 - StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 - StorageLive(_4); // scope 1 at $DIR/reborrow.rs:+2:22: +2:29 - _4 = &mut (*_2); // scope 3 at $DIR/reborrow.rs:+2:22: +2:29 - _3 = &mut (*_4); // scope 1 at $DIR/reborrow.rs:+2:22: +2:29 - StorageDead(_4); // scope 1 at $DIR/reborrow.rs:+2:31: +2:32 -- StorageLive(_5); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 -- _5 = _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 - StorageLive(_6); // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 -- StorageLive(_7); // scope 4 at $DIR/reborrow.rs:+4:12: +4:13 -- _7 = _5; // scope 4 at $DIR/reborrow.rs:+4:12: +4:13 -- _6 = opaque::<*mut u8>(move _7) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 -+ _6 = opaque::<*mut u8>(_2) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 - // mir::Constant - // + span: $DIR/reborrow.rs:39:5: 39:11 - // + literal: Const { ty: fn(*mut u8) {opaque::<*mut u8>}, val: Value(<ZST>) } - } - - bb1: { -- StorageDead(_7); // scope 4 at $DIR/reborrow.rs:+4:13: +4:14 - StorageDead(_6); // scope 4 at $DIR/reborrow.rs:+4:14: +4:15 - _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:23: +5:2 -- StorageDead(_5); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2 - StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2 -- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2 - return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-abort.diff new file mode 100644 index 000000000..ffb0c4b23 --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-abort.diff @@ -0,0 +1,53 @@ +- // MIR for `demiraw` before CopyProp ++ // MIR for `demiraw` after CopyProp + + fn demiraw(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: *mut u8; + let mut _4: &mut u8; + let _6: (); + let mut _7: *mut u8; + scope 1 { + debug a => _2; + let _3: &mut u8; + scope 2 { + debug b => _3; + let _5: *mut u8; + scope 4 { +- debug c => _5; ++ debug c => _2; + } + } + scope 3 { + } + } + + bb0: { +- StorageLive(_2); + _2 = &raw mut _1; + StorageLive(_3); + StorageLive(_4); + _4 = &mut (*_2); + _3 = &mut (*_4); + StorageDead(_4); +- StorageLive(_5); +- _5 = _2; + StorageLive(_6); +- StorageLive(_7); +- _7 = _5; +- _6 = opaque::<*mut u8>(move _7) -> [return: bb1, unwind unreachable]; ++ _6 = opaque::<*mut u8>(_2) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_7); + StorageDead(_6); + _0 = const (); +- StorageDead(_5); + StorageDead(_3); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..66a0f49cf --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff @@ -0,0 +1,53 @@ +- // MIR for `demiraw` before CopyProp ++ // MIR for `demiraw` after CopyProp + + fn demiraw(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: *mut u8; + let mut _4: &mut u8; + let _6: (); + let mut _7: *mut u8; + scope 1 { + debug a => _2; + let _3: &mut u8; + scope 2 { + debug b => _3; + let _5: *mut u8; + scope 4 { +- debug c => _5; ++ debug c => _2; + } + } + scope 3 { + } + } + + bb0: { +- StorageLive(_2); + _2 = &raw mut _1; + StorageLive(_3); + StorageLive(_4); + _4 = &mut (*_2); + _3 = &mut (*_4); + StorageDead(_4); +- StorageLive(_5); +- _5 = _2; + StorageLive(_6); +- StorageLive(_7); +- _7 = _5; +- _6 = opaque::<*mut u8>(move _7) -> [return: bb1, unwind continue]; ++ _6 = opaque::<*mut u8>(_2) -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageDead(_7); + StorageDead(_6); + _0 = const (); +- StorageDead(_5); + StorageDead(_3); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff deleted file mode 100644 index a6a6c05b2..000000000 --- a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff +++ /dev/null @@ -1,52 +0,0 @@ -- // MIR for `miraw` before CopyProp -+ // MIR for `miraw` after CopyProp - - fn miraw(_1: u8) -> () { - debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15 - let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21 - let _2: *mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 - let _5: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14 - let mut _6: *mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13 - scope 1 { - debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 - let _3: *mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 - scope 2 { - debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 - let _4: *mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 - scope 4 { -- debug c => _4; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 -+ debug c => _2; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 - } - } - scope 3 { - } - } - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 - _2 = &raw mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:23 - StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 - _3 = &raw mut (*_2); // scope 3 at $DIR/reborrow.rs:+2:22: +2:33 -- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 -- _4 = _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 - StorageLive(_5); // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 -- StorageLive(_6); // scope 4 at $DIR/reborrow.rs:+4:12: +4:13 -- _6 = _4; // scope 4 at $DIR/reborrow.rs:+4:12: +4:13 -- _5 = opaque::<*mut u8>(move _6) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 -+ _5 = opaque::<*mut u8>(_2) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 - // mir::Constant - // + span: $DIR/reborrow.rs:31:5: 31:11 - // + literal: Const { ty: fn(*mut u8) {opaque::<*mut u8>}, val: Value(<ZST>) } - } - - bb1: { -- StorageDead(_6); // scope 4 at $DIR/reborrow.rs:+4:13: +4:14 - StorageDead(_5); // scope 4 at $DIR/reborrow.rs:+4:14: +4:15 - _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +5:2 -- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2 - StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2 -- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2 - return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-abort.diff new file mode 100644 index 000000000..0777a9135 --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-abort.diff @@ -0,0 +1,49 @@ +- // MIR for `miraw` before CopyProp ++ // MIR for `miraw` after CopyProp + + fn miraw(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: *mut u8; + let _5: (); + let mut _6: *mut u8; + scope 1 { + debug a => _2; + let _3: *mut u8; + scope 2 { + debug b => _3; + let _4: *mut u8; + scope 4 { +- debug c => _4; ++ debug c => _2; + } + } + scope 3 { + } + } + + bb0: { +- StorageLive(_2); + _2 = &raw mut _1; + StorageLive(_3); + _3 = &raw mut (*_2); +- StorageLive(_4); +- _4 = _2; + StorageLive(_5); +- StorageLive(_6); +- _6 = _4; +- _5 = opaque::<*mut u8>(move _6) -> [return: bb1, unwind unreachable]; ++ _5 = opaque::<*mut u8>(_2) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_6); + StorageDead(_5); + _0 = const (); +- StorageDead(_4); + StorageDead(_3); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..f5a512b89 --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff @@ -0,0 +1,49 @@ +- // MIR for `miraw` before CopyProp ++ // MIR for `miraw` after CopyProp + + fn miraw(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: *mut u8; + let _5: (); + let mut _6: *mut u8; + scope 1 { + debug a => _2; + let _3: *mut u8; + scope 2 { + debug b => _3; + let _4: *mut u8; + scope 4 { +- debug c => _4; ++ debug c => _2; + } + } + scope 3 { + } + } + + bb0: { +- StorageLive(_2); + _2 = &raw mut _1; + StorageLive(_3); + _3 = &raw mut (*_2); +- StorageLive(_4); +- _4 = _2; + StorageLive(_5); +- StorageLive(_6); +- _6 = _4; +- _5 = opaque::<*mut u8>(move _6) -> [return: bb1, unwind continue]; ++ _5 = opaque::<*mut u8>(_2) -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageDead(_6); + StorageDead(_5); + _0 = const (); +- StorageDead(_4); + StorageDead(_3); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff deleted file mode 100644 index f3d26cc6e..000000000 --- a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff +++ /dev/null @@ -1,50 +0,0 @@ -- // MIR for `remut` before CopyProp -+ // MIR for `remut` after CopyProp - - fn remut(_1: u8) -> () { - debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15 - let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21 - let _2: &mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 - let _5: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14 - let mut _6: &mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13 - scope 1 { - debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 - let _3: &mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 - scope 2 { - debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 - let _4: &mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 - scope 3 { -- debug c => _4; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 -+ debug c => _2; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 - } - } - } - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 - _2 = &mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:19 - StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 - _3 = &mut (*_2); // scope 1 at $DIR/reborrow.rs:+2:13: +2:20 -- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 -- _4 = move _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 - StorageLive(_5); // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 -- StorageLive(_6); // scope 3 at $DIR/reborrow.rs:+4:12: +4:13 -- _6 = move _4; // scope 3 at $DIR/reborrow.rs:+4:12: +4:13 -- _5 = opaque::<&mut u8>(move _6) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 -+ _5 = opaque::<&mut u8>(move _2) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 - // mir::Constant - // + span: $DIR/reborrow.rs:15:5: 15:11 - // + literal: Const { ty: fn(&mut u8) {opaque::<&mut u8>}, val: Value(<ZST>) } - } - - bb1: { -- StorageDead(_6); // scope 3 at $DIR/reborrow.rs:+4:13: +4:14 - StorageDead(_5); // scope 3 at $DIR/reborrow.rs:+4:14: +4:15 - _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +5:2 -- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2 - StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2 -- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2 - return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff new file mode 100644 index 000000000..2026c1982 --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff @@ -0,0 +1,47 @@ +- // MIR for `remut` before CopyProp ++ // MIR for `remut` after CopyProp + + fn remut(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: &mut u8; + let _5: (); + let mut _6: &mut u8; + scope 1 { + debug a => _2; + let _3: &mut u8; + scope 2 { + debug b => _3; + let _4: &mut u8; + scope 3 { +- debug c => _4; ++ debug c => _2; + } + } + } + + bb0: { +- StorageLive(_2); + _2 = &mut _1; + StorageLive(_3); + _3 = &mut (*_2); +- StorageLive(_4); +- _4 = move _2; + StorageLive(_5); +- StorageLive(_6); +- _6 = move _4; +- _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind unreachable]; ++ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_6); + StorageDead(_5); + _0 = const (); +- StorageDead(_4); + StorageDead(_3); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..67763fdce --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff @@ -0,0 +1,47 @@ +- // MIR for `remut` before CopyProp ++ // MIR for `remut` after CopyProp + + fn remut(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: &mut u8; + let _5: (); + let mut _6: &mut u8; + scope 1 { + debug a => _2; + let _3: &mut u8; + scope 2 { + debug b => _3; + let _4: &mut u8; + scope 3 { +- debug c => _4; ++ debug c => _2; + } + } + } + + bb0: { +- StorageLive(_2); + _2 = &mut _1; + StorageLive(_3); + _3 = &mut (*_2); +- StorageLive(_4); +- _4 = move _2; + StorageLive(_5); +- StorageLive(_6); +- _6 = move _4; +- _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind continue]; ++ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageDead(_6); + StorageDead(_5); + _0 = const (); +- StorageDead(_4); + StorageDead(_3); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff deleted file mode 100644 index 63e42b4dc..000000000 --- a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff +++ /dev/null @@ -1,50 +0,0 @@ -- // MIR for `reraw` before CopyProp -+ // MIR for `reraw` after CopyProp - - fn reraw(_1: u8) -> () { - debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15 - let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21 - let _2: &mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 - let _5: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14 - let mut _6: &mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13 - scope 1 { - debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 - let _3: *mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 - scope 2 { - debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 - let _4: &mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 - scope 3 { -- debug c => _4; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 -+ debug c => _2; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 - } - } - } - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 - _2 = &mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:19 - StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 - _3 = &raw mut (*_2); // scope 1 at $DIR/reborrow.rs:+2:13: +2:24 -- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 -- _4 = move _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 - StorageLive(_5); // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 -- StorageLive(_6); // scope 3 at $DIR/reborrow.rs:+4:12: +4:13 -- _6 = move _4; // scope 3 at $DIR/reborrow.rs:+4:12: +4:13 -- _5 = opaque::<&mut u8>(move _6) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 -+ _5 = opaque::<&mut u8>(move _2) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 - // mir::Constant - // + span: $DIR/reborrow.rs:23:5: 23:11 - // + literal: Const { ty: fn(&mut u8) {opaque::<&mut u8>}, val: Value(<ZST>) } - } - - bb1: { -- StorageDead(_6); // scope 3 at $DIR/reborrow.rs:+4:13: +4:14 - StorageDead(_5); // scope 3 at $DIR/reborrow.rs:+4:14: +4:15 - _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +5:2 -- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2 - StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2 -- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2 - return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff new file mode 100644 index 000000000..dfc8dd097 --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff @@ -0,0 +1,47 @@ +- // MIR for `reraw` before CopyProp ++ // MIR for `reraw` after CopyProp + + fn reraw(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: &mut u8; + let _5: (); + let mut _6: &mut u8; + scope 1 { + debug a => _2; + let _3: *mut u8; + scope 2 { + debug b => _3; + let _4: &mut u8; + scope 3 { +- debug c => _4; ++ debug c => _2; + } + } + } + + bb0: { +- StorageLive(_2); + _2 = &mut _1; + StorageLive(_3); + _3 = &raw mut (*_2); +- StorageLive(_4); +- _4 = move _2; + StorageLive(_5); +- StorageLive(_6); +- _6 = move _4; +- _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind unreachable]; ++ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_6); + StorageDead(_5); + _0 = const (); +- StorageDead(_4); + StorageDead(_3); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff new file mode 100644 index 000000000..becc42563 --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff @@ -0,0 +1,47 @@ +- // MIR for `reraw` before CopyProp ++ // MIR for `reraw` after CopyProp + + fn reraw(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: &mut u8; + let _5: (); + let mut _6: &mut u8; + scope 1 { + debug a => _2; + let _3: *mut u8; + scope 2 { + debug b => _3; + let _4: &mut u8; + scope 3 { +- debug c => _4; ++ debug c => _2; + } + } + } + + bb0: { +- StorageLive(_2); + _2 = &mut _1; + StorageLive(_3); + _3 = &raw mut (*_2); +- StorageLive(_4); +- _4 = move _2; + StorageLive(_5); +- StorageLive(_6); +- _6 = move _4; +- _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind continue]; ++ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageDead(_6); + StorageDead(_5); + _0 = const (); +- StorageDead(_4); + StorageDead(_3); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.rs b/tests/mir-opt/copy-prop/reborrow.rs index 91b77966b..c37ba5e5c 100644 --- a/tests/mir-opt/copy-prop/reborrow.rs +++ b/tests/mir-opt/copy-prop/reborrow.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that CopyProp considers reborrows as not mutating the pointer. // unit-test: CopyProp |