diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
commit | a0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch) | |
tree | fc451898ccaf445814e26b46664d78702178101d /tests/mir-opt/const_prop | |
parent | Adding debian version 1.71.1+dfsg1-2. (diff) | |
download | rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/const_prop')
165 files changed, 3326 insertions, 2002 deletions
diff --git a/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff b/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff index d50b12044..6b96c24d4 100644 --- a/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff +++ b/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff @@ -2,45 +2,45 @@ + // MIR for `fn0` after ConstProp fn fn0() -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/address_of_pair.rs:+0:17: +0:21 - let mut _1: !; // in scope 0 at $DIR/address_of_pair.rs:+0:22: +9:2 - let mut _2: (i32, bool); // in scope 0 at $DIR/address_of_pair.rs:+1:9: +1:17 - let _4: (); // in scope 0 at $DIR/address_of_pair.rs:+4:5: +6:6 - let mut _6: bool; // in scope 0 at $DIR/address_of_pair.rs:+7:16: +7:22 + let mut _0: bool; + let mut _1: !; + let mut _2: (i32, bool); + let _4: (); + let mut _6: bool; scope 1 { - debug pair => _2; // in scope 1 at $DIR/address_of_pair.rs:+1:9: +1:17 - let _3: *mut bool; // in scope 1 at $DIR/address_of_pair.rs:+2:9: +2:12 + debug pair => _2; + let _3: *mut bool; scope 2 { - debug ptr => _3; // in scope 2 at $DIR/address_of_pair.rs:+2:9: +2:12 - let _5: bool; // in scope 2 at $DIR/address_of_pair.rs:+7:9: +7:12 + debug ptr => _3; + let _5: bool; scope 3 { } scope 4 { - debug ret => _5; // in scope 4 at $DIR/address_of_pair.rs:+7:9: +7:12 + debug ret => _5; } } } bb0: { - StorageLive(_2); // scope 0 at $DIR/address_of_pair.rs:+1:9: +1:17 - _2 = (const 1_i32, const false); // scope 0 at $DIR/address_of_pair.rs:+1:20: +1:30 - StorageLive(_3); // scope 1 at $DIR/address_of_pair.rs:+2:9: +2:12 - _3 = &raw mut (_2.1: bool); // scope 1 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - _2 = (const 1_i32, const false); // scope 2 at $DIR/address_of_pair.rs:+3:5: +3:22 - StorageLive(_4); // scope 2 at $DIR/address_of_pair.rs:+4:5: +6:6 - (*_3) = const true; // scope 3 at $DIR/address_of_pair.rs:+5:9: +5:20 - _4 = const (); // scope 3 at $DIR/address_of_pair.rs:+4:5: +6:6 - StorageDead(_4); // scope 2 at $DIR/address_of_pair.rs:+6:5: +6:6 - StorageLive(_5); // scope 2 at $DIR/address_of_pair.rs:+7:9: +7:12 - StorageLive(_6); // scope 2 at $DIR/address_of_pair.rs:+7:16: +7:22 - _6 = (_2.1: bool); // scope 2 at $DIR/address_of_pair.rs:+7:16: +7:22 - _5 = Not(move _6); // scope 2 at $DIR/address_of_pair.rs:+7:15: +7:22 - StorageDead(_6); // scope 2 at $DIR/address_of_pair.rs:+7:21: +7:22 - _0 = _5; // scope 4 at $DIR/address_of_pair.rs:+8:12: +8:15 - StorageDead(_5); // scope 2 at $DIR/address_of_pair.rs:+9:1: +9:2 - StorageDead(_3); // scope 1 at $DIR/address_of_pair.rs:+9:1: +9:2 - StorageDead(_2); // scope 0 at $DIR/address_of_pair.rs:+9:1: +9:2 - return; // scope 0 at $DIR/address_of_pair.rs:+9:2: +9:2 + StorageLive(_2); + _2 = (const 1_i32, const false); + StorageLive(_3); + _3 = &raw mut (_2.1: bool); + _2 = (const 1_i32, const false); + StorageLive(_4); + (*_3) = const true; + _4 = const (); + StorageDead(_4); + StorageLive(_5); + StorageLive(_6); + _6 = (_2.1: bool); + _5 = Not(move _6); + StorageDead(_6); + _0 = _5; + StorageDead(_5); + StorageDead(_3); + StorageDead(_2); + return; } } diff --git a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.diff b/tests/mir-opt/const_prop/aggregate.foo.ConstProp.diff deleted file mode 100644 index 6ac460db8..000000000 --- a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.diff +++ /dev/null @@ -1,55 +0,0 @@ -- // MIR for `foo` before ConstProp -+ // MIR for `foo` after ConstProp - - fn foo(_1: u8) -> () { - debug x => _1; // in scope 0 at $DIR/aggregate.rs:+0:8: +0:9 - let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:+0:15: +0:15 - let _2: i32; // in scope 0 at $DIR/aggregate.rs:+2:9: +2:14 - let mut _3: i32; // in scope 0 at $DIR/aggregate.rs:+2:17: +2:25 - let mut _4: (i32, u8); // in scope 0 at $DIR/aggregate.rs:+2:17: +2:23 - let mut _5: u8; // in scope 0 at $DIR/aggregate.rs:+2:21: +2:22 - let mut _7: i32; // in scope 0 at $DIR/aggregate.rs:+3:18: +3:26 - let mut _8: (u8, i32); // in scope 0 at $DIR/aggregate.rs:+3:18: +3:24 - let mut _9: u8; // in scope 0 at $DIR/aggregate.rs:+3:19: +3:20 - scope 1 { - debug first => _2; // in scope 1 at $DIR/aggregate.rs:+2:9: +2:14 - let _6: i32; // in scope 1 at $DIR/aggregate.rs:+3:9: +3:15 - scope 2 { - debug second => _6; // in scope 2 at $DIR/aggregate.rs:+3:9: +3:15 - } - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/aggregate.rs:+2:9: +2:14 - StorageLive(_3); // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 - StorageLive(_4); // scope 0 at $DIR/aggregate.rs:+2:17: +2:23 - StorageLive(_5); // scope 0 at $DIR/aggregate.rs:+2:21: +2:22 - _5 = _1; // scope 0 at $DIR/aggregate.rs:+2:21: +2:22 - _4 = (const 0_i32, move _5); // scope 0 at $DIR/aggregate.rs:+2:17: +2:23 - StorageDead(_5); // scope 0 at $DIR/aggregate.rs:+2:22: +2:23 -- _3 = (_4.0: i32); // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 -- _2 = Add(move _3, const 1_i32); // scope 0 at $DIR/aggregate.rs:+2:17: +2:29 -+ _3 = const 0_i32; // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 -+ _2 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+2:17: +2:29 - StorageDead(_3); // scope 0 at $DIR/aggregate.rs:+2:28: +2:29 - StorageDead(_4); // scope 0 at $DIR/aggregate.rs:+2:29: +2:30 - StorageLive(_6); // scope 1 at $DIR/aggregate.rs:+3:9: +3:15 - StorageLive(_7); // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 - StorageLive(_8); // scope 1 at $DIR/aggregate.rs:+3:18: +3:24 - StorageLive(_9); // scope 1 at $DIR/aggregate.rs:+3:19: +3:20 - _9 = _1; // scope 1 at $DIR/aggregate.rs:+3:19: +3:20 - _8 = (move _9, const 1_i32); // scope 1 at $DIR/aggregate.rs:+3:18: +3:24 - StorageDead(_9); // scope 1 at $DIR/aggregate.rs:+3:23: +3:24 -- _7 = (_8.1: i32); // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 -- _6 = Add(move _7, const 2_i32); // scope 1 at $DIR/aggregate.rs:+3:18: +3:30 -+ _7 = const 1_i32; // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 -+ _6 = const 3_i32; // scope 1 at $DIR/aggregate.rs:+3:18: +3:30 - StorageDead(_7); // scope 1 at $DIR/aggregate.rs:+3:29: +3:30 - StorageDead(_8); // scope 1 at $DIR/aggregate.rs:+3:30: +3:31 - _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:15: +4:2 - StorageDead(_6); // scope 1 at $DIR/aggregate.rs:+4:1: +4:2 - StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+4:1: +4:2 - return; // scope 0 at $DIR/aggregate.rs:+4:2: +4:2 - } - } - diff --git a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-abort.diff new file mode 100644 index 000000000..5e2db148d --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-abort.diff @@ -0,0 +1,55 @@ +- // MIR for `foo` before ConstProp ++ // MIR for `foo` after ConstProp + + fn foo(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: i32; + let mut _3: i32; + let mut _4: (i32, u8); + let mut _5: u8; + let mut _7: i32; + let mut _8: (u8, i32); + let mut _9: u8; + scope 1 { + debug first => _2; + let _6: i32; + scope 2 { + debug second => _6; + } + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + _4 = (const 0_i32, move _5); + StorageDead(_5); +- _3 = (_4.0: i32); +- _2 = Add(move _3, const 1_i32); ++ _3 = const 0_i32; ++ _2 = const 1_i32; + StorageDead(_3); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + _9 = _1; + _8 = (move _9, const 1_i32); + StorageDead(_9); +- _7 = (_8.1: i32); +- _6 = Add(move _7, const 2_i32); ++ _7 = const 1_i32; ++ _6 = const 3_i32; + StorageDead(_7); + StorageDead(_8); + _0 = const (); + StorageDead(_6); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..5e2db148d --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-unwind.diff @@ -0,0 +1,55 @@ +- // MIR for `foo` before ConstProp ++ // MIR for `foo` after ConstProp + + fn foo(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: i32; + let mut _3: i32; + let mut _4: (i32, u8); + let mut _5: u8; + let mut _7: i32; + let mut _8: (u8, i32); + let mut _9: u8; + scope 1 { + debug first => _2; + let _6: i32; + scope 2 { + debug second => _6; + } + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + _4 = (const 0_i32, move _5); + StorageDead(_5); +- _3 = (_4.0: i32); +- _2 = Add(move _3, const 1_i32); ++ _3 = const 0_i32; ++ _2 = const 1_i32; + StorageDead(_3); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + _9 = _1; + _8 = (move _9, const 1_i32); + StorageDead(_9); +- _7 = (_8.1: i32); +- _6 = Add(move _7, const 2_i32); ++ _7 = const 1_i32; ++ _6 = const 3_i32; + StorageDead(_7); + StorageDead(_8); + _0 = const (); + StorageDead(_6); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.mir b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.mir deleted file mode 100644 index 2ef6d74e5..000000000 --- a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.mir +++ /dev/null @@ -1,49 +0,0 @@ -// MIR for `foo` after PreCodegen - -fn foo(_1: u8) -> () { - debug x => _1; // in scope 0 at $DIR/aggregate.rs:+0:8: +0:9 - let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:+0:15: +0:15 - let _2: i32; // in scope 0 at $DIR/aggregate.rs:+2:9: +2:14 - let mut _3: i32; // in scope 0 at $DIR/aggregate.rs:+2:17: +2:25 - let mut _4: (i32, u8); // in scope 0 at $DIR/aggregate.rs:+2:17: +2:23 - let mut _5: u8; // in scope 0 at $DIR/aggregate.rs:+2:21: +2:22 - let mut _7: i32; // in scope 0 at $DIR/aggregate.rs:+3:18: +3:26 - let mut _8: (u8, i32); // in scope 0 at $DIR/aggregate.rs:+3:18: +3:24 - let mut _9: u8; // in scope 0 at $DIR/aggregate.rs:+3:19: +3:20 - scope 1 { - debug first => _2; // in scope 1 at $DIR/aggregate.rs:+2:9: +2:14 - let _6: i32; // in scope 1 at $DIR/aggregate.rs:+3:9: +3:15 - scope 2 { - debug second => _6; // in scope 2 at $DIR/aggregate.rs:+3:9: +3:15 - } - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/aggregate.rs:+2:9: +2:14 - StorageLive(_3); // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 - StorageLive(_4); // scope 0 at $DIR/aggregate.rs:+2:17: +2:23 - StorageLive(_5); // scope 0 at $DIR/aggregate.rs:+2:21: +2:22 - _5 = _1; // scope 0 at $DIR/aggregate.rs:+2:21: +2:22 - _4 = (const 0_i32, move _5); // scope 0 at $DIR/aggregate.rs:+2:17: +2:23 - StorageDead(_5); // scope 0 at $DIR/aggregate.rs:+2:22: +2:23 - _3 = const 0_i32; // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 - _2 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+2:17: +2:29 - StorageDead(_3); // scope 0 at $DIR/aggregate.rs:+2:28: +2:29 - StorageDead(_4); // scope 0 at $DIR/aggregate.rs:+2:29: +2:30 - StorageLive(_6); // scope 1 at $DIR/aggregate.rs:+3:9: +3:15 - StorageLive(_7); // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 - StorageLive(_8); // scope 1 at $DIR/aggregate.rs:+3:18: +3:24 - StorageLive(_9); // scope 1 at $DIR/aggregate.rs:+3:19: +3:20 - _9 = _1; // scope 1 at $DIR/aggregate.rs:+3:19: +3:20 - _8 = (move _9, const 1_i32); // scope 1 at $DIR/aggregate.rs:+3:18: +3:24 - StorageDead(_9); // scope 1 at $DIR/aggregate.rs:+3:23: +3:24 - _7 = const 1_i32; // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 - _6 = const 3_i32; // scope 1 at $DIR/aggregate.rs:+3:18: +3:30 - StorageDead(_7); // scope 1 at $DIR/aggregate.rs:+3:29: +3:30 - StorageDead(_8); // scope 1 at $DIR/aggregate.rs:+3:30: +3:31 - _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:15: +4:2 - StorageDead(_6); // scope 1 at $DIR/aggregate.rs:+4:1: +4:2 - StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+4:1: +4:2 - return; // scope 0 at $DIR/aggregate.rs:+4:2: +4:2 - } -} diff --git a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir new file mode 100644 index 000000000..b9c5859ca --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir @@ -0,0 +1,49 @@ +// MIR for `foo` after PreCodegen + +fn foo(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: i32; + let mut _3: i32; + let mut _4: (i32, u8); + let mut _5: u8; + let mut _7: i32; + let mut _8: (u8, i32); + let mut _9: u8; + scope 1 { + debug first => _2; + let _6: i32; + scope 2 { + debug second => _6; + } + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + _4 = (const 0_i32, move _5); + StorageDead(_5); + _3 = const 0_i32; + _2 = const 1_i32; + StorageDead(_3); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + _9 = _1; + _8 = (move _9, const 1_i32); + StorageDead(_9); + _7 = const 1_i32; + _6 = const 3_i32; + StorageDead(_7); + StorageDead(_8); + _0 = const (); + StorageDead(_6); + StorageDead(_2); + return; + } +} diff --git a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir new file mode 100644 index 000000000..b9c5859ca --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,49 @@ +// MIR for `foo` after PreCodegen + +fn foo(_1: u8) -> () { + debug x => _1; + let mut _0: (); + let _2: i32; + let mut _3: i32; + let mut _4: (i32, u8); + let mut _5: u8; + let mut _7: i32; + let mut _8: (u8, i32); + let mut _9: u8; + scope 1 { + debug first => _2; + let _6: i32; + scope 2 { + debug second => _6; + } + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + _4 = (const 0_i32, move _5); + StorageDead(_5); + _3 = const 0_i32; + _2 = const 1_i32; + StorageDead(_3); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + _9 = _1; + _8 = (move _9, const 1_i32); + StorageDead(_9); + _7 = const 1_i32; + _6 = const 3_i32; + StorageDead(_7); + StorageDead(_8); + _0 = const (); + StorageDead(_6); + StorageDead(_2); + return; + } +} diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff deleted file mode 100644 index 041197266..000000000 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff +++ /dev/null @@ -1,44 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:+0:11: +0:11 - let _1: u8; // in scope 0 at $DIR/aggregate.rs:+1:9: +1:10 - let mut _2: u8; // in scope 0 at $DIR/aggregate.rs:+1:13: +1:24 - let mut _3: (i32, u8, i32); // in scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - let _4: (); // in scope 0 at $DIR/aggregate.rs:+2:5: +2:11 - let mut _5: u8; // in scope 0 at $DIR/aggregate.rs:+2:9: +2:10 - scope 1 { - debug x => _1; // in scope 1 at $DIR/aggregate.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/aggregate.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 - StorageLive(_3); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - _3 = (const 0_i32, const 1_u8, const 2_i32); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 -- _2 = (_3.1: u8); // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 -- _1 = Add(move _2, const 0_u8); // scope 0 at $DIR/aggregate.rs:+1:13: +1:28 -+ _2 = const 1_u8; // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 -+ _1 = const 1_u8; // scope 0 at $DIR/aggregate.rs:+1:13: +1:28 - StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+1:27: +1:28 - StorageDead(_3); // scope 0 at $DIR/aggregate.rs:+1:28: +1:29 - StorageLive(_4); // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 - StorageLive(_5); // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 -- _5 = _1; // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 -+ _5 = const 1_u8; // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 - _4 = foo(move _5) -> bb1; // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 - // mir::Constant - // + span: $DIR/aggregate.rs:9:5: 9:8 - // + literal: Const { ty: fn(u8) {foo}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_5); // scope 1 at $DIR/aggregate.rs:+2:10: +2:11 - StorageDead(_4); // scope 1 at $DIR/aggregate.rs:+2:11: +2:12 - _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:11: +3:2 - StorageDead(_1); // scope 0 at $DIR/aggregate.rs:+3:1: +3:2 - return; // scope 0 at $DIR/aggregate.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..0fad23104 --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff @@ -0,0 +1,41 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: u8; + let mut _3: (i32, u8, i32); + let _4: (); + let mut _5: u8; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = (const 0_i32, const 1_u8, const 2_i32); +- _2 = (_3.1: u8); +- _1 = Add(move _2, const 0_u8); ++ _2 = const 1_u8; ++ _1 = const 1_u8; + StorageDead(_2); + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); +- _5 = _1; ++ _5 = const 1_u8; + _4 = foo(move _5) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..e4650046b --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff @@ -0,0 +1,41 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: u8; + let mut _3: (i32, u8, i32); + let _4: (); + let mut _5: u8; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = (const 0_i32, const 1_u8, const 2_i32); +- _2 = (_3.1: u8); +- _1 = Add(move _2, const 0_u8); ++ _2 = const 1_u8; ++ _1 = const 1_u8; + StorageDead(_2); + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); +- _5 = _1; ++ _5 = const 1_u8; + _4 = foo(move _5) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir deleted file mode 100644 index 05d4bf8b5..000000000 --- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir +++ /dev/null @@ -1,39 +0,0 @@ -// MIR for `main` after PreCodegen - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:+0:11: +0:11 - let _1: u8; // in scope 0 at $DIR/aggregate.rs:+1:9: +1:10 - let mut _2: u8; // in scope 0 at $DIR/aggregate.rs:+1:13: +1:24 - let mut _3: (i32, u8, i32); // in scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - let _4: (); // in scope 0 at $DIR/aggregate.rs:+2:5: +2:11 - let mut _5: u8; // in scope 0 at $DIR/aggregate.rs:+2:9: +2:10 - scope 1 { - debug x => _1; // in scope 1 at $DIR/aggregate.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/aggregate.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 - StorageLive(_3); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - _3 = (const 0_i32, const 1_u8, const 2_i32); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - _2 = const 1_u8; // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 - _1 = const 1_u8; // scope 0 at $DIR/aggregate.rs:+1:13: +1:28 - StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+1:27: +1:28 - StorageDead(_3); // scope 0 at $DIR/aggregate.rs:+1:28: +1:29 - StorageLive(_4); // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 - StorageLive(_5); // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 - _5 = const 1_u8; // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 - _4 = foo(move _5) -> bb1; // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 - // mir::Constant - // + span: $DIR/aggregate.rs:9:5: 9:8 - // + literal: Const { ty: fn(u8) {foo}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_5); // scope 1 at $DIR/aggregate.rs:+2:10: +2:11 - StorageDead(_4); // scope 1 at $DIR/aggregate.rs:+2:11: +2:12 - _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:11: +3:2 - StorageDead(_1); // scope 0 at $DIR/aggregate.rs:+3:1: +3:2 - return; // scope 0 at $DIR/aggregate.rs:+3:2: +3:2 - } -} diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir new file mode 100644 index 000000000..2ab6c1bf3 --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir @@ -0,0 +1,36 @@ +// MIR for `main` after PreCodegen + +fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: u8; + let mut _3: (i32, u8, i32); + let _4: (); + let mut _5: u8; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = (const 0_i32, const 1_u8, const 2_i32); + _2 = const 1_u8; + _1 = const 1_u8; + StorageDead(_2); + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); + _5 = const 1_u8; + _4 = foo(move _5) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } +} diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir new file mode 100644 index 000000000..9590c7f90 --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,36 @@ +// MIR for `main` after PreCodegen + +fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: u8; + let mut _3: (i32, u8, i32); + let _4: (); + let mut _5: u8; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = (const 0_i32, const 1_u8, const 2_i32); + _2 = const 1_u8; + _1 = const 1_u8; + StorageDead(_2); + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); + _5 = const 1_u8; + _4 = foo(move _5) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } +} diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs index ed5a4ab59..62cd3dd68 100644 --- a/tests/mir-opt/const_prop/aggregate.rs +++ b/tests/mir-opt/const_prop/aggregate.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -O diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff deleted file mode 100644 index 439b2a3e1..000000000 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff +++ /dev/null @@ -1,39 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/array_index.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/array_index.rs:+1:9: +1:10 - let mut _2: [u32; 4]; // in scope 0 at $DIR/array_index.rs:+1:18: +1:30 - let _3: usize; // in scope 0 at $DIR/array_index.rs:+1:31: +1:32 - let mut _4: usize; // in scope 0 at $DIR/array_index.rs:+1:18: +1:33 - let mut _5: bool; // in scope 0 at $DIR/array_index.rs:+1:18: +1:33 - scope 1 { - debug x => _1; // in scope 1 at $DIR/array_index.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/array_index.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/array_index.rs:+1:18: +1:30 - _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; // scope 0 at $DIR/array_index.rs:+1:18: +1:30 - StorageLive(_3); // scope 0 at $DIR/array_index.rs:+1:31: +1:32 - _3 = const 2_usize; // scope 0 at $DIR/array_index.rs:+1:31: +1:32 -- _4 = Len(_2); // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -- _5 = Lt(_3, _4); // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -+ _4 = const 4_usize; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -+ _5 = const true; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 - } - - bb1: { -- _1 = _2[_3]; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -+ _1 = const 2_u32; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 - StorageDead(_3); // scope 0 at $DIR/array_index.rs:+1:33: +1:34 - StorageDead(_2); // scope 0 at $DIR/array_index.rs:+1:33: +1:34 - _0 = const (); // scope 0 at $DIR/array_index.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/array_index.rs:+2:1: +2:2 - return; // scope 0 at $DIR/array_index.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff new file mode 100644 index 000000000..012b11e0e --- /dev/null +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: [u32; 4]; + let _3: usize; + let mut _4: usize; + let mut _5: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; + StorageLive(_3); + _3 = const 2_usize; +- _4 = Len(_2); +- _5 = Lt(_3, _4); +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; ++ _4 = const 4_usize; ++ _5 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = _2[_3]; ++ _1 = const 2_u32; + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff new file mode 100644 index 000000000..ec11395c3 --- /dev/null +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: [u32; 4]; + let _3: usize; + let mut _4: usize; + let mut _5: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; + StorageLive(_3); + _3 = const 2_usize; +- _4 = Len(_2); +- _5 = Lt(_3, _4); +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; ++ _4 = const 4_usize; ++ _5 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = _2[_3]; ++ _1 = const 2_u32; + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff deleted file mode 100644 index 439b2a3e1..000000000 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff +++ /dev/null @@ -1,39 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/array_index.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/array_index.rs:+1:9: +1:10 - let mut _2: [u32; 4]; // in scope 0 at $DIR/array_index.rs:+1:18: +1:30 - let _3: usize; // in scope 0 at $DIR/array_index.rs:+1:31: +1:32 - let mut _4: usize; // in scope 0 at $DIR/array_index.rs:+1:18: +1:33 - let mut _5: bool; // in scope 0 at $DIR/array_index.rs:+1:18: +1:33 - scope 1 { - debug x => _1; // in scope 1 at $DIR/array_index.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/array_index.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/array_index.rs:+1:18: +1:30 - _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; // scope 0 at $DIR/array_index.rs:+1:18: +1:30 - StorageLive(_3); // scope 0 at $DIR/array_index.rs:+1:31: +1:32 - _3 = const 2_usize; // scope 0 at $DIR/array_index.rs:+1:31: +1:32 -- _4 = Len(_2); // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -- _5 = Lt(_3, _4); // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -+ _4 = const 4_usize; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -+ _5 = const true; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 - } - - bb1: { -- _1 = _2[_3]; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 -+ _1 = const 2_u32; // scope 0 at $DIR/array_index.rs:+1:18: +1:33 - StorageDead(_3); // scope 0 at $DIR/array_index.rs:+1:33: +1:34 - StorageDead(_2); // scope 0 at $DIR/array_index.rs:+1:33: +1:34 - _0 = const (); // scope 0 at $DIR/array_index.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/array_index.rs:+2:1: +2:2 - return; // scope 0 at $DIR/array_index.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff new file mode 100644 index 000000000..012b11e0e --- /dev/null +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: [u32; 4]; + let _3: usize; + let mut _4: usize; + let mut _5: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; + StorageLive(_3); + _3 = const 2_usize; +- _4 = Len(_2); +- _5 = Lt(_3, _4); +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; ++ _4 = const 4_usize; ++ _5 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = _2[_3]; ++ _1 = const 2_u32; + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff new file mode 100644 index 000000000..ec11395c3 --- /dev/null +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: [u32; 4]; + let _3: usize; + let mut _4: usize; + let mut _5: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; + StorageLive(_3); + _3 = const 2_usize; +- _4 = Len(_2); +- _5 = Lt(_3, _4); +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; ++ _4 = const 4_usize; ++ _5 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = _2[_3]; ++ _1 = const 2_u32; + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/array_index.rs b/tests/mir-opt/const_prop/array_index.rs index f36cf2213..f85d23b97 100644 --- a/tests/mir-opt/const_prop/array_index.rs +++ b/tests/mir-opt/const_prop/array_index.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff deleted file mode 100644 index 900061a48..000000000 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff +++ /dev/null @@ -1,53 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/bad_op_div_by_zero.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/bad_op_div_by_zero.rs:+1:9: +1:10 - let mut _3: i32; // in scope 0 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19 - let mut _4: bool; // in scope 0 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 - let mut _5: bool; // in scope 0 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 - let mut _6: bool; // in scope 0 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 - let mut _7: bool; // in scope 0 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 - scope 1 { - debug y => _1; // in scope 1 at $DIR/bad_op_div_by_zero.rs:+1:9: +1:10 - let _2: i32; // in scope 1 at $DIR/bad_op_div_by_zero.rs:+2:9: +2:11 - scope 2 { - debug _z => _2; // in scope 2 at $DIR/bad_op_div_by_zero.rs:+2:9: +2:11 - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/bad_op_div_by_zero.rs:+1:9: +1:10 - _1 = const 0_i32; // scope 0 at $DIR/bad_op_div_by_zero.rs:+1:13: +1:14 - StorageLive(_2); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:9: +2:11 - StorageLive(_3); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19 -- _3 = _1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19 -- _4 = Eq(_3, const 0_i32); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -- assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -+ _3 = const 0_i32; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19 -+ _4 = const true; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -+ assert(!const true, "attempt to divide `{}` by zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 - } - - bb1: { -- _5 = Eq(_3, const -1_i32); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -- _6 = Eq(const 1_i32, const i32::MIN); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -- _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -- assert(!move _7, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -+ _5 = const false; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -+ _6 = const false; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -+ _7 = const false; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 -+ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 - } - - bb2: { - _2 = Div(const 1_i32, move _3); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 - StorageDead(_3); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19 - _0 = const (); // scope 0 at $DIR/bad_op_div_by_zero.rs:+0:11: +3:2 - StorageDead(_2); // scope 1 at $DIR/bad_op_div_by_zero.rs:+3:1: +3:2 - StorageDead(_1); // scope 0 at $DIR/bad_op_div_by_zero.rs:+3:1: +3:2 - return; // scope 0 at $DIR/bad_op_div_by_zero.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..34163d4d8 --- /dev/null +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff @@ -0,0 +1,53 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _3: i32; + let mut _4: bool; + let mut _5: bool; + let mut _6: bool; + let mut _7: bool; + scope 1 { + debug y => _1; + let _2: i32; + scope 2 { + debug _z => _2; + } + } + + bb0: { + StorageLive(_1); + _1 = const 0_i32; + StorageLive(_2); + StorageLive(_3); +- _3 = _1; +- _4 = Eq(_3, const 0_i32); +- assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> [success: bb1, unwind unreachable]; ++ _3 = const 0_i32; ++ _4 = const true; ++ assert(!const true, "attempt to divide `{}` by zero", const 1_i32) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _5 = Eq(_3, const -1_i32); +- _6 = Eq(const 1_i32, const i32::MIN); +- _7 = BitAnd(move _5, move _6); +- assert(!move _7, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind unreachable]; ++ _5 = const false; ++ _6 = const false; ++ _7 = const false; ++ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind unreachable]; + } + + bb2: { + _2 = Div(const 1_i32, move _3); + StorageDead(_3); + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..a5b51681e --- /dev/null +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff @@ -0,0 +1,53 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _3: i32; + let mut _4: bool; + let mut _5: bool; + let mut _6: bool; + let mut _7: bool; + scope 1 { + debug y => _1; + let _2: i32; + scope 2 { + debug _z => _2; + } + } + + bb0: { + StorageLive(_1); + _1 = const 0_i32; + StorageLive(_2); + StorageLive(_3); +- _3 = _1; +- _4 = Eq(_3, const 0_i32); +- assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> [success: bb1, unwind continue]; ++ _3 = const 0_i32; ++ _4 = const true; ++ assert(!const true, "attempt to divide `{}` by zero", const 1_i32) -> [success: bb1, unwind continue]; + } + + bb1: { +- _5 = Eq(_3, const -1_i32); +- _6 = Eq(const 1_i32, const i32::MIN); +- _7 = BitAnd(move _5, move _6); +- assert(!move _7, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; ++ _5 = const false; ++ _6 = const false; ++ _7 = const false; ++ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; + } + + bb2: { + _2 = Div(const 1_i32, move _3); + StorageDead(_3); + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs index 38f1a993d..963084bf7 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff #[allow(unconditional_panic)] diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff deleted file mode 100644 index 85d6b5e3d..000000000 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff +++ /dev/null @@ -1,53 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/bad_op_mod_by_zero.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:9: +1:10 - let mut _3: i32; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 - let mut _4: bool; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - let mut _5: bool; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - let mut _6: bool; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - let mut _7: bool; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - scope 1 { - debug y => _1; // in scope 1 at $DIR/bad_op_mod_by_zero.rs:+1:9: +1:10 - let _2: i32; // in scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:9: +2:11 - scope 2 { - debug _z => _2; // in scope 2 at $DIR/bad_op_mod_by_zero.rs:+2:9: +2:11 - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:9: +1:10 - _1 = const 0_i32; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:13: +1:14 - StorageLive(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:9: +2:11 - StorageLive(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 -- _3 = _1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 -- _4 = Eq(_3, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -- assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ _3 = const 0_i32; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 -+ _4 = const true; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - } - - bb1: { -- _5 = Eq(_3, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -- _6 = Eq(const 1_i32, const i32::MIN); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -- _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ _5 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ _6 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ _7 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - } - - bb2: { - _2 = Rem(const 1_i32, move _3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 - _0 = const (); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+0:11: +3:2 - StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 - StorageDead(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 - return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..eb1c7d34f --- /dev/null +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff @@ -0,0 +1,53 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _3: i32; + let mut _4: bool; + let mut _5: bool; + let mut _6: bool; + let mut _7: bool; + scope 1 { + debug y => _1; + let _2: i32; + scope 2 { + debug _z => _2; + } + } + + bb0: { + StorageLive(_1); + _1 = const 0_i32; + StorageLive(_2); + StorageLive(_3); +- _3 = _1; +- _4 = Eq(_3, const 0_i32); +- assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> [success: bb1, unwind unreachable]; ++ _3 = const 0_i32; ++ _4 = const true; ++ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _5 = Eq(_3, const -1_i32); +- _6 = Eq(const 1_i32, const i32::MIN); +- _7 = BitAnd(move _5, move _6); +- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind unreachable]; ++ _5 = const false; ++ _6 = const false; ++ _7 = const false; ++ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind unreachable]; + } + + bb2: { + _2 = Rem(const 1_i32, move _3); + StorageDead(_3); + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..4afddf3c9 --- /dev/null +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff @@ -0,0 +1,53 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _3: i32; + let mut _4: bool; + let mut _5: bool; + let mut _6: bool; + let mut _7: bool; + scope 1 { + debug y => _1; + let _2: i32; + scope 2 { + debug _z => _2; + } + } + + bb0: { + StorageLive(_1); + _1 = const 0_i32; + StorageLive(_2); + StorageLive(_3); +- _3 = _1; +- _4 = Eq(_3, const 0_i32); +- assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> [success: bb1, unwind continue]; ++ _3 = const 0_i32; ++ _4 = const true; ++ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> [success: bb1, unwind continue]; + } + + bb1: { +- _5 = Eq(_3, const -1_i32); +- _6 = Eq(const 1_i32, const i32::MIN); +- _7 = BitAnd(move _5, move _6); +- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; ++ _5 = const false; ++ _6 = const false; ++ _7 = const false; ++ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; + } + + bb2: { + _2 = Rem(const 1_i32, move _3); + StorageDead(_3); + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs index 93d558250..9d7d2aa10 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs @@ -1,5 +1,5 @@ // unit-test: ConstProp -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff #[allow(unconditional_panic)] fn main() { diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff deleted file mode 100644 index d72675c2d..000000000 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff +++ /dev/null @@ -1,57 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+0:11: +0:11 - let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 - let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35 - let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - scope 1 { - debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 - scope 2 { - let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - scope 3 { - debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - // mir::Constant - // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:9:25: 9:35 - // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _3 = &(*_9); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 - StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36 - StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _7 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - } - - bb1: { -- _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _5 = (*_1)[3 of 4]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 - _0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6 - StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 - StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2 - return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff new file mode 100644 index 000000000..30402df47 --- /dev/null +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff @@ -0,0 +1,54 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: *const [i32]; + let mut _2: *const [i32; 3]; + let _3: &[i32; 3]; + let _4: [i32; 3]; + let _6: usize; + let mut _7: usize; + let mut _8: bool; + let mut _9: &[i32; 3]; + scope 1 { + debug a => _1; + scope 2 { + let _5: i32; + scope 3 { + debug _b => _5; + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _9 = const _; + _3 = &(*_9); + _2 = &raw const (*_3); + _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); + StorageDead(_2); + StorageDead(_3); + StorageLive(_5); + StorageLive(_6); + _6 = const 3_usize; + _7 = const 3_usize; +- _8 = Lt(_6, _7); +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; ++ _8 = const false; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _5 = (*_1)[_6]; ++ _5 = (*_1)[3 of 4]; + StorageDead(_6); + _0 = const (); + StorageDead(_5); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff new file mode 100644 index 000000000..16d62daed --- /dev/null +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff @@ -0,0 +1,54 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: *const [i32]; + let mut _2: *const [i32; 3]; + let _3: &[i32; 3]; + let _4: [i32; 3]; + let _6: usize; + let mut _7: usize; + let mut _8: bool; + let mut _9: &[i32; 3]; + scope 1 { + debug a => _1; + scope 2 { + let _5: i32; + scope 3 { + debug _b => _5; + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _9 = const _; + _3 = &(*_9); + _2 = &raw const (*_3); + _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); + StorageDead(_2); + StorageDead(_3); + StorageLive(_5); + StorageLive(_6); + _6 = const 3_usize; + _7 = const 3_usize; +- _8 = Lt(_6, _7); +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; ++ _8 = const false; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + } + + bb1: { +- _5 = (*_1)[_6]; ++ _5 = (*_1)[3 of 4]; + StorageDead(_6); + _0 = const (); + StorageDead(_5); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff deleted file mode 100644 index d72675c2d..000000000 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff +++ /dev/null @@ -1,57 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+0:11: +0:11 - let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 - let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35 - let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - scope 1 { - debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 - scope 2 { - let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - scope 3 { - debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - // mir::Constant - // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:9:25: 9:35 - // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _3 = &(*_9); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 - StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36 - StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _7 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - } - - bb1: { -- _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _5 = (*_1)[3 of 4]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 - _0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6 - StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 - StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2 - return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff new file mode 100644 index 000000000..30402df47 --- /dev/null +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff @@ -0,0 +1,54 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: *const [i32]; + let mut _2: *const [i32; 3]; + let _3: &[i32; 3]; + let _4: [i32; 3]; + let _6: usize; + let mut _7: usize; + let mut _8: bool; + let mut _9: &[i32; 3]; + scope 1 { + debug a => _1; + scope 2 { + let _5: i32; + scope 3 { + debug _b => _5; + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _9 = const _; + _3 = &(*_9); + _2 = &raw const (*_3); + _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); + StorageDead(_2); + StorageDead(_3); + StorageLive(_5); + StorageLive(_6); + _6 = const 3_usize; + _7 = const 3_usize; +- _8 = Lt(_6, _7); +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; ++ _8 = const false; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _5 = (*_1)[_6]; ++ _5 = (*_1)[3 of 4]; + StorageDead(_6); + _0 = const (); + StorageDead(_5); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff new file mode 100644 index 000000000..16d62daed --- /dev/null +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff @@ -0,0 +1,54 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: *const [i32]; + let mut _2: *const [i32; 3]; + let _3: &[i32; 3]; + let _4: [i32; 3]; + let _6: usize; + let mut _7: usize; + let mut _8: bool; + let mut _9: &[i32; 3]; + scope 1 { + debug a => _1; + scope 2 { + let _5: i32; + scope 3 { + debug _b => _5; + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _9 = const _; + _3 = &(*_9); + _2 = &raw const (*_3); + _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); + StorageDead(_2); + StorageDead(_3); + StorageLive(_5); + StorageLive(_6); + _6 = const 3_usize; + _7 = const 3_usize; +- _8 = Lt(_6, _7); +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; ++ _8 = const false; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + } + + bb1: { +- _5 = (*_1)[_6]; ++ _5 = (*_1)[3 of 4]; + StorageDead(_6); + _0 = const (); + StorageDead(_5); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs index ef148d16d..7931c4f02 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs @@ -1,5 +1,5 @@ // unit-test: ConstProp -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zmir-enable-passes=+NormalizeArrayLen // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff b/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff index 549b4711e..d80534199 100644 --- a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff @@ -2,26 +2,26 @@ + // MIR for `test` after ConstProp fn test(_1: bool, _2: bool) -> bool { - debug x => _1; // in scope 0 at $DIR/boolean_identities.rs:+0:13: +0:14 - debug y => _2; // in scope 0 at $DIR/boolean_identities.rs:+0:22: +0:23 - let mut _0: bool; // return place in scope 0 at $DIR/boolean_identities.rs:+0:34: +0:38 - let mut _3: bool; // in scope 0 at $DIR/boolean_identities.rs:+1:5: +1:15 - let mut _4: bool; // in scope 0 at $DIR/boolean_identities.rs:+1:6: +1:7 - let mut _5: bool; // in scope 0 at $DIR/boolean_identities.rs:+1:18: +1:29 - let mut _6: bool; // in scope 0 at $DIR/boolean_identities.rs:+1:19: +1:20 + debug x => _1; + debug y => _2; + let mut _0: bool; + let mut _3: bool; + let mut _4: bool; + let mut _5: bool; + let mut _6: bool; bb0: { - StorageLive(_3); // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:15 -- _3 = BitOr(_2, const true); // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:15 -+ _3 = const true; // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:15 - StorageLive(_5); // scope 0 at $DIR/boolean_identities.rs:+1:18: +1:29 -- _5 = BitAnd(_1, const false); // scope 0 at $DIR/boolean_identities.rs:+1:18: +1:29 -- _0 = BitAnd(move _3, move _5); // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:29 -+ _5 = const false; // scope 0 at $DIR/boolean_identities.rs:+1:18: +1:29 -+ _0 = const false; // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:29 - StorageDead(_5); // scope 0 at $DIR/boolean_identities.rs:+1:28: +1:29 - StorageDead(_3); // scope 0 at $DIR/boolean_identities.rs:+1:28: +1:29 - return; // scope 0 at $DIR/boolean_identities.rs:+2:2: +2:2 + StorageLive(_3); +- _3 = BitOr(_2, const true); ++ _3 = const true; + StorageLive(_5); +- _5 = BitAnd(_1, const false); +- _0 = BitAnd(move _3, move _5); ++ _5 = const false; ++ _0 = const false; + StorageDead(_5); + StorageDead(_3); + return; } } diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.diff b/tests/mir-opt/const_prop/boxes.main.ConstProp.diff deleted file mode 100644 index b0e86e753..000000000 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.diff +++ /dev/null @@ -1,60 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/boxes.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/boxes.rs:+1:9: +1:10 - let mut _2: i32; // in scope 0 at $DIR/boxes.rs:+1:13: +2:18 - let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 - let mut _4: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 - let mut _5: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 - let mut _6: *mut u8; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 - let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 - let mut _8: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 - let mut _9: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 - scope 1 { - debug x => _1; // in scope 1 at $DIR/boxes.rs:+1:9: +1:10 - } - scope 2 { - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/boxes.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/boxes.rs:+1:13: +2:18 - StorageLive(_3); // scope 0 at $DIR/boxes.rs:+1:14: +2:18 -- _4 = SizeOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +2:18 -- _5 = AlignOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +2:18 -+ _4 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +2:18 -+ _5 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +2:18 - _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +2:18 - // mir::Constant - // + span: $DIR/boxes.rs:13:14: 14:18 - // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } - } - - bb1: { - StorageLive(_7); // scope 0 at $DIR/boxes.rs:+1:14: +2:18 - _7 = ShallowInitBox(move _6, i32); // scope 0 at $DIR/boxes.rs:+1:14: +2:18 - _8 = (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+2:14: +2:16 - (*_8) = const 42_i32; // scope 0 at $DIR/boxes.rs:+2:14: +2:16 - _3 = move _7; // scope 0 at $DIR/boxes.rs:+1:14: +2:18 - StorageDead(_7); // scope 0 at $DIR/boxes.rs:+2:17: +2:18 - _9 = (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+1:13: +2:18 - _2 = (*_9); // scope 0 at $DIR/boxes.rs:+1:13: +2:18 - _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/boxes.rs:+1:13: +3:12 - StorageDead(_2); // scope 0 at $DIR/boxes.rs:+3:11: +3:12 - drop(_3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/boxes.rs:+3:12: +3:13 - } - - bb2: { - StorageDead(_3); // scope 0 at $DIR/boxes.rs:+3:12: +3:13 - _0 = const (); // scope 0 at $DIR/boxes.rs:+0:11: +4:2 - StorageDead(_1); // scope 0 at $DIR/boxes.rs:+4:1: +4:2 - return; // scope 0 at $DIR/boxes.rs:+4:2: +4:2 - } - - bb3 (cleanup): { - resume; // scope 0 at $DIR/boxes.rs:+0:1: +4:2 - } - } - diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..24b479694 --- /dev/null +++ b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff @@ -0,0 +1,53 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _2: i32; + let mut _3: std::boxed::Box<i32>; + let mut _4: usize; + let mut _5: usize; + let mut _6: *mut u8; + let mut _7: std::boxed::Box<i32>; + let mut _8: *const i32; + let mut _9: *const i32; + scope 1 { + debug x => _1; + } + scope 2 { + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); +- _4 = SizeOf(i32); +- _5 = AlignOf(i32); ++ _4 = const 4_usize; ++ _5 = const 4_usize; + _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageLive(_7); + _7 = ShallowInitBox(move _6, i32); + _8 = (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); + (*_8) = const 42_i32; + _3 = move _7; + StorageDead(_7); + _9 = (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); + _2 = (*_9); + _1 = Add(move _2, const 0_i32); + StorageDead(_2); + drop(_3) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..6214766c7 --- /dev/null +++ b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff @@ -0,0 +1,57 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _2: i32; + let mut _3: std::boxed::Box<i32>; + let mut _4: usize; + let mut _5: usize; + let mut _6: *mut u8; + let mut _7: std::boxed::Box<i32>; + let mut _8: *const i32; + let mut _9: *const i32; + scope 1 { + debug x => _1; + } + scope 2 { + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); +- _4 = SizeOf(i32); +- _5 = AlignOf(i32); ++ _4 = const 4_usize; ++ _5 = const 4_usize; + _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageLive(_7); + _7 = ShallowInitBox(move _6, i32); + _8 = (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); + (*_8) = const 42_i32; + _3 = move _7; + StorageDead(_7); + _9 = (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); + _2 = (*_9); + _1 = Add(move _2, const 0_i32); + StorageDead(_2); + drop(_3) -> [return: bb2, unwind: bb3]; + } + + bb2: { + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; + } + + bb3 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs index 66e8c24d4..9407759cb 100644 --- a/tests/mir-opt/const_prop/boxes.rs +++ b/tests/mir-opt/const_prop/boxes.rs @@ -1,7 +1,7 @@ // unit-test: ConstProp // compile-flags: -O // ignore-emscripten compiled with panic=abort by default -// ignore-wasm32 +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // ignore-wasm64 #![feature(rustc_attrs, stmt_expr_attributes)] diff --git a/tests/mir-opt/const_prop/cast.main.ConstProp.diff b/tests/mir-opt/const_prop/cast.main.ConstProp.diff index 1d4dfc29f..c63adcf11 100644 --- a/tests/mir-opt/const_prop/cast.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/cast.main.ConstProp.diff @@ -2,27 +2,27 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/cast.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/cast.rs:+1:9: +1:10 + let mut _0: (); + let _1: u32; scope 1 { - debug x => _1; // in scope 1 at $DIR/cast.rs:+1:9: +1:10 - let _2: u8; // in scope 1 at $DIR/cast.rs:+3:9: +3:10 + debug x => _1; + let _2: u8; scope 2 { - debug y => _2; // in scope 2 at $DIR/cast.rs:+3:9: +3:10 + debug y => _2; } } bb0: { - StorageLive(_1); // scope 0 at $DIR/cast.rs:+1:9: +1:10 -- _1 = const 42_u8 as u32 (IntToInt); // scope 0 at $DIR/cast.rs:+1:13: +1:24 -+ _1 = const 42_u32; // scope 0 at $DIR/cast.rs:+1:13: +1:24 - StorageLive(_2); // scope 1 at $DIR/cast.rs:+3:9: +3:10 -- _2 = const 42_u32 as u8 (IntToInt); // scope 1 at $DIR/cast.rs:+3:13: +3:24 -+ _2 = const 42_u8; // scope 1 at $DIR/cast.rs:+3:13: +3:24 - _0 = const (); // scope 0 at $DIR/cast.rs:+0:11: +4:2 - StorageDead(_2); // scope 1 at $DIR/cast.rs:+4:1: +4:2 - StorageDead(_1); // scope 0 at $DIR/cast.rs:+4:1: +4:2 - return; // scope 0 at $DIR/cast.rs:+4:2: +4:2 + StorageLive(_1); +- _1 = const 42_u8 as u32 (IntToInt); ++ _1 = const 42_u32; + StorageLive(_2); +- _2 = const 42_u32 as u8 (IntToInt); ++ _2 = const 42_u8; + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.diff b/tests/mir-opt/const_prop/checked_add.main.ConstProp.diff deleted file mode 100644 index 96d0d2566..000000000 --- a/tests/mir-opt/const_prop/checked_add.main.ConstProp.diff +++ /dev/null @@ -1,28 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/checked_add.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/checked_add.rs:+1:9: +1:10 - let mut _2: (u32, bool); // in scope 0 at $DIR/checked_add.rs:+1:18: +1:23 - scope 1 { - debug x => _1; // in scope 1 at $DIR/checked_add.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/checked_add.rs:+1:9: +1:10 -- _2 = CheckedAdd(const 1_u32, const 1_u32); // scope 0 at $DIR/checked_add.rs:+1:18: +1:23 -- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> bb1; // scope 0 at $DIR/checked_add.rs:+1:18: +1:23 -+ _2 = const (2_u32, false); // scope 0 at $DIR/checked_add.rs:+1:18: +1:23 -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> bb1; // scope 0 at $DIR/checked_add.rs:+1:18: +1:23 - } - - bb1: { -- _1 = move (_2.0: u32); // scope 0 at $DIR/checked_add.rs:+1:18: +1:23 -+ _1 = const 2_u32; // scope 0 at $DIR/checked_add.rs:+1:18: +1:23 - _0 = const (); // scope 0 at $DIR/checked_add.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/checked_add.rs:+2:1: +2:2 - return; // scope 0 at $DIR/checked_add.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..6daef87dd --- /dev/null +++ b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff @@ -0,0 +1,28 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: (u32, bool); + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); +- _2 = CheckedAdd(const 1_u32, const 1_u32); +- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind unreachable]; ++ _2 = const (2_u32, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = move (_2.0: u32); ++ _1 = const 2_u32; + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..125407bf2 --- /dev/null +++ b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff @@ -0,0 +1,28 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: (u32, bool); + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); +- _2 = CheckedAdd(const 1_u32, const 1_u32); +- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue]; ++ _2 = const (2_u32, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = move (_2.0: u32); ++ _1 = const 2_u32; + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs index 007defd10..fd40876cb 100644 --- a/tests/mir-opt/const_prop/checked_add.rs +++ b/tests/mir-opt/const_prop/checked_add.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff deleted file mode 100644 index d75fae30b..000000000 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff +++ /dev/null @@ -1,44 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/const_prop_fails_gracefully.rs:+0:11: +0:11 - let _1: usize; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:9: +2:10 - let mut _2: *const i32; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:30 - let _3: &i32; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:16 - let _4: (); // in scope 0 at $DIR/const_prop_fails_gracefully.rs:+3:5: +3:12 - let mut _5: usize; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:+3:10: +3:11 - scope 1 { - debug x => _1; // in scope 1 at $DIR/const_prop_fails_gracefully.rs:+2:9: +2:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:9: +2:10 - StorageLive(_2); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:30 - StorageLive(_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:16 - _3 = const _; // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:16 - // mir::Constant - // + span: $DIR/const_prop_fails_gracefully.rs:9:13: 9:16 - // + literal: Const { ty: &i32, val: Unevaluated(FOO, [], None) } - _2 = &raw const (*_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:16 - _1 = move _2 as usize (PointerExposeAddress); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:39 - StorageDead(_2); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:38: +2:39 - StorageDead(_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:39: +2:40 - StorageLive(_4); // scope 1 at $DIR/const_prop_fails_gracefully.rs:+3:5: +3:12 - StorageLive(_5); // scope 1 at $DIR/const_prop_fails_gracefully.rs:+3:10: +3:11 - _5 = _1; // scope 1 at $DIR/const_prop_fails_gracefully.rs:+3:10: +3:11 - _4 = read(move _5) -> bb1; // scope 1 at $DIR/const_prop_fails_gracefully.rs:+3:5: +3:12 - // mir::Constant - // + span: $DIR/const_prop_fails_gracefully.rs:10:5: 10:9 - // + literal: Const { ty: fn(usize) {read}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_5); // scope 1 at $DIR/const_prop_fails_gracefully.rs:+3:11: +3:12 - StorageDead(_4); // scope 1 at $DIR/const_prop_fails_gracefully.rs:+3:12: +3:13 - _0 = const (); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+0:11: +4:2 - StorageDead(_1); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+4:1: +4:2 - return; // scope 0 at $DIR/const_prop_fails_gracefully.rs:+4:2: +4:2 - } - } - diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..bd1de7476 --- /dev/null +++ b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff @@ -0,0 +1,38 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: usize; + let mut _2: *const i32; + let _3: &i32; + let _4: (); + let mut _5: usize; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = const _; + _2 = &raw const (*_3); + _1 = move _2 as usize (PointerExposeAddress); + StorageDead(_2); + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + _4 = read(move _5) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..850b743fe --- /dev/null +++ b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff @@ -0,0 +1,38 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: usize; + let mut _2: *const i32; + let _3: &i32; + let _4: (); + let mut _5: usize; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = const _; + _2 = &raw const (*_3); + _1 = move _2 as usize (PointerExposeAddress); + StorageDead(_2); + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + _4 = read(move _5) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs index 44d487842..c92831f92 100644 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs +++ b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp #[inline(never)] fn read(_: usize) { } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff deleted file mode 100644 index 7e77c18d5..000000000 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff +++ /dev/null @@ -1,31 +0,0 @@ -- // MIR for `hello` before ConstProp -+ // MIR for `hello` after ConstProp - - fn hello() -> () { - let mut _0: (); // return place in scope 0 at $DIR/control_flow_simplification.rs:+0:14: +0:14 - let mut _1: bool; // in scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 - let mut _2: !; // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL - - bb0: { - StorageLive(_1); // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 - _1 = const _; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 -- switchInt(move _1) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 -+ switchInt(const false) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 - } - - bb1: { - _2 = begin_panic::<&str>(const "explicit panic"); // scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/std/src/panic.rs:LL:COL - // + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value(<ZST>) } - // mir::Constant - // + span: $SRC_DIR/std/src/panic.rs:LL:COL - // + literal: Const { ty: &str, val: Value(Slice(..)) } - } - - bb2: { - StorageDead(_1); // scope 0 at $DIR/control_flow_simplification.rs:+3:5: +3:6 - return; // scope 0 at $DIR/control_flow_simplification.rs:+4:2: +4:2 - } - } - diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff new file mode 100644 index 000000000..e77c09848 --- /dev/null +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff @@ -0,0 +1,25 @@ +- // MIR for `hello` before ConstProp ++ // MIR for `hello` after ConstProp + + fn hello() -> () { + let mut _0: (); + let mut _1: bool; + let mut _2: !; + + bb0: { + StorageLive(_1); + _1 = const _; +- switchInt(move _1) -> [0: bb2, otherwise: bb1]; ++ switchInt(const false) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + _2 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + } + + bb2: { + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..7496d2543 --- /dev/null +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff @@ -0,0 +1,25 @@ +- // MIR for `hello` before ConstProp ++ // MIR for `hello` after ConstProp + + fn hello() -> () { + let mut _0: (); + let mut _1: bool; + let mut _2: !; + + bb0: { + StorageLive(_1); + _1 = const _; +- switchInt(move _1) -> [0: bb2, otherwise: bb1]; ++ switchInt(const false) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + _2 = begin_panic::<&str>(const "explicit panic") -> unwind continue; + } + + bb2: { + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir b/tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir deleted file mode 100644 index 9f7528f0c..000000000 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir +++ /dev/null @@ -1,9 +0,0 @@ -// MIR for `hello` before PreCodegen - -fn hello() -> () { - let mut _0: (); // return place in scope 0 at $DIR/control_flow_simplification.rs:+0:14: +0:14 - - bb0: { - return; // scope 0 at $DIR/control_flow_simplification.rs:+4:2: +4:2 - } -} diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.panic-abort.mir b/tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.panic-abort.mir new file mode 100644 index 000000000..2b90410f9 --- /dev/null +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.panic-abort.mir @@ -0,0 +1,9 @@ +// MIR for `hello` before PreCodegen + +fn hello() -> () { + let mut _0: (); + + bb0: { + return; + } +} diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.panic-unwind.mir b/tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.panic-unwind.mir new file mode 100644 index 000000000..2b90410f9 --- /dev/null +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.panic-unwind.mir @@ -0,0 +1,9 @@ +// MIR for `hello` before PreCodegen + +fn hello() -> () { + let mut _0: (); + + bb0: { + return; + } +} diff --git a/tests/mir-opt/const_prop/control_flow_simplification.rs b/tests/mir-opt/const_prop/control_flow_simplification.rs index b2ca045e8..21d727b3e 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.rs +++ b/tests/mir-opt/const_prop/control_flow_simplification.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Zmir-opt-level=1 diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff index 6d8738aa6..e02e7f320 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff @@ -2,54 +2,51 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/discriminant.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/discriminant.rs:+1:9: +1:10 - let mut _2: i32; // in scope 0 at $DIR/discriminant.rs:+1:13: +1:64 - let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:+1:34: +1:44 - let mut _4: isize; // in scope 0 at $DIR/discriminant.rs:+1:21: +1:31 + let mut _0: (); + let _1: i32; + let mut _2: i32; + let mut _3: std::option::Option<bool>; + let mut _4: isize; scope 1 { - debug x => _1; // in scope 1 at $DIR/discriminant.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/discriminant.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 - StorageLive(_3); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 -- _3 = Option::<bool>::Some(const true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 -- _4 = discriminant(_3); // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 -- switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 -+ _3 = const Option::<bool>::Some(true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: Option<bool>, val: Value(Scalar(0x01)) } -+ _4 = const 1_isize; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 -+ switchInt(const 1_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); +- _3 = Option::<bool>::Some(const true); +- _4 = discriminant(_3); +- switchInt(move _4) -> [1: bb1, otherwise: bb3]; ++ _3 = const Option::<bool>::Some(true); ++ _4 = const 1_isize; ++ switchInt(const 1_isize) -> [1: bb1, otherwise: bb3]; } bb1: { -- switchInt(((_3 as Some).0: bool)) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 -+ switchInt(const true) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 +- switchInt(((_3 as Some).0: bool)) -> [0: bb3, otherwise: bb2]; ++ switchInt(const true) -> [0: bb3, otherwise: bb2]; } bb2: { - _2 = const 42_i32; // scope 2 at $DIR/discriminant.rs:+1:47: +1:49 - goto -> bb4; // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 + _2 = const 42_i32; + goto -> bb4; } bb3: { - _2 = const 10_i32; // scope 0 at $DIR/discriminant.rs:+1:59: +1:61 - goto -> bb4; // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 + _2 = const 10_i32; + goto -> bb4; } bb4: { - _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/discriminant.rs:+1:13: +1:68 - StorageDead(_2); // scope 0 at $DIR/discriminant.rs:+1:67: +1:68 - StorageDead(_3); // scope 0 at $DIR/discriminant.rs:+1:68: +1:69 - _0 = const (); // scope 0 at $DIR/discriminant.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/discriminant.rs:+2:1: +2:2 - return; // scope 0 at $DIR/discriminant.rs:+2:2: +2:2 + _1 = Add(move _2, const 0_i32); + StorageDead(_2); + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff index 6d8738aa6..e02e7f320 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff @@ -2,54 +2,51 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/discriminant.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/discriminant.rs:+1:9: +1:10 - let mut _2: i32; // in scope 0 at $DIR/discriminant.rs:+1:13: +1:64 - let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:+1:34: +1:44 - let mut _4: isize; // in scope 0 at $DIR/discriminant.rs:+1:21: +1:31 + let mut _0: (); + let _1: i32; + let mut _2: i32; + let mut _3: std::option::Option<bool>; + let mut _4: isize; scope 1 { - debug x => _1; // in scope 1 at $DIR/discriminant.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/discriminant.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 - StorageLive(_3); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 -- _3 = Option::<bool>::Some(const true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 -- _4 = discriminant(_3); // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 -- switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 -+ _3 = const Option::<bool>::Some(true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: Option<bool>, val: Value(Scalar(0x01)) } -+ _4 = const 1_isize; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 -+ switchInt(const 1_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); +- _3 = Option::<bool>::Some(const true); +- _4 = discriminant(_3); +- switchInt(move _4) -> [1: bb1, otherwise: bb3]; ++ _3 = const Option::<bool>::Some(true); ++ _4 = const 1_isize; ++ switchInt(const 1_isize) -> [1: bb1, otherwise: bb3]; } bb1: { -- switchInt(((_3 as Some).0: bool)) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 -+ switchInt(const true) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 +- switchInt(((_3 as Some).0: bool)) -> [0: bb3, otherwise: bb2]; ++ switchInt(const true) -> [0: bb3, otherwise: bb2]; } bb2: { - _2 = const 42_i32; // scope 2 at $DIR/discriminant.rs:+1:47: +1:49 - goto -> bb4; // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 + _2 = const 42_i32; + goto -> bb4; } bb3: { - _2 = const 10_i32; // scope 0 at $DIR/discriminant.rs:+1:59: +1:61 - goto -> bb4; // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 + _2 = const 10_i32; + goto -> bb4; } bb4: { - _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/discriminant.rs:+1:13: +1:68 - StorageDead(_2); // scope 0 at $DIR/discriminant.rs:+1:67: +1:68 - StorageDead(_3); // scope 0 at $DIR/discriminant.rs:+1:68: +1:69 - _0 = const (); // scope 0 at $DIR/discriminant.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/discriminant.rs:+2:1: +2:2 - return; // scope 0 at $DIR/discriminant.rs:+2:2: +2:2 + _1 = Add(move _2, const 0_i32); + StorageDead(_2); + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.diff b/tests/mir-opt/const_prop/indirect.main.ConstProp.diff deleted file mode 100644 index f4c0c5c5e..000000000 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.diff +++ /dev/null @@ -1,33 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/indirect.rs:+0:11: +0:11 - let _1: u8; // in scope 0 at $DIR/indirect.rs:+1:9: +1:10 - let mut _2: u8; // in scope 0 at $DIR/indirect.rs:+1:13: +1:25 - let mut _3: (u8, bool); // in scope 0 at $DIR/indirect.rs:+1:13: +1:29 - scope 1 { - debug x => _1; // in scope 1 at $DIR/indirect.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/indirect.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/indirect.rs:+1:13: +1:25 -- _2 = const 2_u32 as u8 (IntToInt); // scope 0 at $DIR/indirect.rs:+1:13: +1:25 -- _3 = CheckedAdd(_2, const 1_u8); // scope 0 at $DIR/indirect.rs:+1:13: +1:29 -- assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> bb1; // scope 0 at $DIR/indirect.rs:+1:13: +1:29 -+ _2 = const 2_u8; // scope 0 at $DIR/indirect.rs:+1:13: +1:25 -+ _3 = const (3_u8, false); // scope 0 at $DIR/indirect.rs:+1:13: +1:29 -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> bb1; // scope 0 at $DIR/indirect.rs:+1:13: +1:29 - } - - bb1: { -- _1 = move (_3.0: u8); // scope 0 at $DIR/indirect.rs:+1:13: +1:29 -+ _1 = const 3_u8; // scope 0 at $DIR/indirect.rs:+1:13: +1:29 - StorageDead(_2); // scope 0 at $DIR/indirect.rs:+1:28: +1:29 - _0 = const (); // scope 0 at $DIR/indirect.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/indirect.rs:+2:1: +2:2 - return; // scope 0 at $DIR/indirect.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..eef9282c2 --- /dev/null +++ b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff @@ -0,0 +1,33 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: u8; + let mut _3: (u8, bool); + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); +- _2 = const 2_u32 as u8 (IntToInt); +- _3 = CheckedAdd(_2, const 1_u8); +- assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind unreachable]; ++ _2 = const 2_u8; ++ _3 = const (3_u8, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = move (_3.0: u8); ++ _1 = const 3_u8; + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..ccfa35f00 --- /dev/null +++ b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff @@ -0,0 +1,33 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: u8; + let mut _3: (u8, bool); + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); +- _2 = const 2_u32 as u8 (IntToInt); +- _3 = CheckedAdd(_2, const 1_u8); +- assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind continue]; ++ _2 = const 2_u8; ++ _3 = const (3_u8, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = move (_3.0: u8); ++ _1 = const 3_u8; + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/indirect.rs b/tests/mir-opt/const_prop/indirect.rs index 46fd8082d..72af6cd95 100644 --- a/tests/mir-opt/const_prop/indirect.rs +++ b/tests/mir-opt/const_prop/indirect.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff deleted file mode 100644 index 0ac7fa43d..000000000 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff +++ /dev/null @@ -1,39 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inherit_overflow.rs:+0:11: +0:11 - let mut _1: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - let mut _2: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - let mut _3: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - scope 1 { - } - scope 2 (inlined <u8 as Add>::add) { // at $DIR/inherit_overflow.rs:9:13: 9:47 - debug self => _2; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - debug other => _3; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - let mut _4: (u8, bool); // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - StorageLive(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - _2 = const u8::MAX; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - StorageLive(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - _3 = const 1_u8; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 -- _4 = CheckedAdd(_2, _3); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL -- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL -+ _4 = const (0_u8, true); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL -+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - } - - bb1: { -- _1 = move (_4.0: u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL -+ _1 = const 0_u8; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - StorageDead(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - StorageDead(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:47: +3:48 - _0 = const (); // scope 0 at $DIR/inherit_overflow.rs:+0:11: +4:2 - return; // scope 0 at $DIR/inherit_overflow.rs:+4:2: +4:2 - } - } - diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..e0467e3fc --- /dev/null +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let mut _1: u8; + let mut _2: u8; + let mut _3: u8; + scope 1 { + } + scope 2 (inlined <u8 as Add>::add) { + debug self => _2; + debug other => _3; + let mut _4: (u8, bool); + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = const u8::MAX; + StorageLive(_3); + _3 = const 1_u8; +- _4 = CheckedAdd(_2, _3); +- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind unreachable]; ++ _4 = const (0_u8, true); ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = move (_4.0: u8); ++ _1 = const 0_u8; + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..4f8e0f0f5 --- /dev/null +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let mut _1: u8; + let mut _2: u8; + let mut _3: u8; + scope 1 { + } + scope 2 (inlined <u8 as Add>::add) { + debug self => _2; + debug other => _3; + let mut _4: (u8, bool); + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = const u8::MAX; + StorageLive(_3); + _3 = const 1_u8; +- _4 = CheckedAdd(_2, _3); +- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue]; ++ _4 = const (0_u8, true); ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = move (_4.0: u8); ++ _1 = const 0_u8; + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/const_prop/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs index 4e905d00d..6ebd36412 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.rs +++ b/tests/mir-opt/const_prop/inherit_overflow.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+Inline diff --git a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff index 1752d222f..0c9d1f4a3 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff @@ -2,24 +2,24 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/invalid_constant.rs:+0:11: +0:11 - let _1: char; // in scope 0 at $DIR/invalid_constant.rs:+6:9: +6:22 - let mut _2: main::InvalidChar; // in scope 0 at $DIR/invalid_constant.rs:+6:34: +6:63 - let mut _4: E; // in scope 0 at $DIR/invalid_constant.rs:+13:25: +13:59 - let mut _5: main::InvalidTag; // in scope 0 at $DIR/invalid_constant.rs:+13:34: +13:55 - let mut _7: Empty; // in scope 0 at $DIR/invalid_constant.rs:+20:35: +20:73 - let mut _8: main::NoVariants; // in scope 0 at $DIR/invalid_constant.rs:+20:44: +20:65 + let mut _0: (); + let _1: char; + let mut _2: main::InvalidChar; + let mut _4: E; + let mut _5: main::InvalidTag; + let mut _7: Empty; + let mut _8: main::NoVariants; scope 1 { - debug _invalid_char => _1; // in scope 1 at $DIR/invalid_constant.rs:+6:9: +6:22 - let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 + debug _invalid_char => _1; + let _3: [E; 1]; scope 3 { - debug _invalid_tag => _3; // in scope 3 at $DIR/invalid_constant.rs:+13:9: +13:21 - let _6: [Empty; 1]; // in scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 + debug _invalid_tag => _3; + let _6: [Empty; 1]; scope 5 { - debug _enum_without_variants => const [ZeroSized: Empty]; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 - let _9: main::Str<"���">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 + debug _enum_without_variants => const [ZeroSized: Empty]; + let _9: main::Str<"���">; scope 7 { - debug _non_utf8_str => const Str::<"���">; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 + debug _non_utf8_str => const Str::<"���">; } } scope 6 { @@ -32,39 +32,36 @@ } bb0: { - StorageLive(_1); // scope 0 at $DIR/invalid_constant.rs:+6:9: +6:22 - StorageLive(_2); // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 - _2 = InvalidChar { int: const 1114113_u32 }; // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 -- _1 = (_2.1: char); // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:67 -+ _1 = const {transmute(0x00110001): char}; // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:67 - StorageDead(_2); // scope 0 at $DIR/invalid_constant.rs:+6:69: +6:70 - StorageLive(_3); // scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 - StorageLive(_4); // scope 1 at $DIR/invalid_constant.rs:+13:25: +13:59 - StorageLive(_5); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 - _5 = InvalidTag { int: const 4_u32 }; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 -- _4 = (_5.1: E); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 -+ _4 = const Scalar(0x00000004): E; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) } - _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 - StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60 - StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61 - nop; // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 - nop; // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 - StorageLive(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 - _8 = NoVariants { int: const 0_u32 }; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 - nop; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71 - nop; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74 - nop; // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 - StorageDead(_8); // scope 3 at $DIR/invalid_constant.rs:+20:74: +20:75 - nop; // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 - nop; // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2 - nop; // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 - nop; // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 - StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2 - StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2 - return; // scope 0 at $DIR/invalid_constant.rs:+27:2: +27:2 + StorageLive(_1); + StorageLive(_2); + _2 = InvalidChar { int: const 1114113_u32 }; +- _1 = (_2.1: char); ++ _1 = const {transmute(0x00110001): char}; + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _5 = InvalidTag { int: const 4_u32 }; +- _4 = (_5.1: E); ++ _4 = const Scalar(0x00000004): E; + _3 = [move _4]; + StorageDead(_4); + StorageDead(_5); + nop; + nop; + StorageLive(_8); + _8 = NoVariants { int: const 0_u32 }; + nop; + nop; + nop; + StorageDead(_8); + nop; + nop; + nop; + nop; + StorageDead(_3); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff index e31c2bc39..455c2375e 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff @@ -2,26 +2,26 @@ + // MIR for `main` after RemoveZsts fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/invalid_constant.rs:+0:11: +0:11 - let _1: char; // in scope 0 at $DIR/invalid_constant.rs:+6:9: +6:22 - let mut _2: main::InvalidChar; // in scope 0 at $DIR/invalid_constant.rs:+6:34: +6:63 - let mut _4: E; // in scope 0 at $DIR/invalid_constant.rs:+13:25: +13:59 - let mut _5: main::InvalidTag; // in scope 0 at $DIR/invalid_constant.rs:+13:34: +13:55 - let mut _7: Empty; // in scope 0 at $DIR/invalid_constant.rs:+20:35: +20:73 - let mut _8: main::NoVariants; // in scope 0 at $DIR/invalid_constant.rs:+20:44: +20:65 + let mut _0: (); + let _1: char; + let mut _2: main::InvalidChar; + let mut _4: E; + let mut _5: main::InvalidTag; + let mut _7: Empty; + let mut _8: main::NoVariants; scope 1 { - debug _invalid_char => _1; // in scope 1 at $DIR/invalid_constant.rs:+6:9: +6:22 - let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 + debug _invalid_char => _1; + let _3: [E; 1]; scope 3 { - debug _invalid_tag => _3; // in scope 3 at $DIR/invalid_constant.rs:+13:9: +13:21 - let _6: [Empty; 1]; // in scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 + debug _invalid_tag => _3; + let _6: [Empty; 1]; scope 5 { -- debug _enum_without_variants => _6; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 -+ debug _enum_without_variants => const [ZeroSized: Empty]; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 - let _9: main::Str<"���">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 +- debug _enum_without_variants => _6; ++ debug _enum_without_variants => const [ZeroSized: Empty]; + let _9: main::Str<"���">; scope 7 { -- debug _non_utf8_str => _9; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 -+ debug _non_utf8_str => const Str::<"���">; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 +- debug _non_utf8_str => _9; ++ debug _non_utf8_str => const Str::<"���">; } } scope 6 { @@ -34,43 +34,43 @@ } bb0: { - StorageLive(_1); // scope 0 at $DIR/invalid_constant.rs:+6:9: +6:22 - StorageLive(_2); // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 - _2 = InvalidChar { int: const 1114113_u32 }; // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 - _1 = (_2.1: char); // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:67 - StorageDead(_2); // scope 0 at $DIR/invalid_constant.rs:+6:69: +6:70 - StorageLive(_3); // scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 - StorageLive(_4); // scope 1 at $DIR/invalid_constant.rs:+13:25: +13:59 - StorageLive(_5); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 - _5 = InvalidTag { int: const 4_u32 }; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 - _4 = (_5.1: E); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 - _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 - StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60 - StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61 -- StorageLive(_6); // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 -- StorageLive(_7); // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 -+ nop; // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 -+ nop; // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 - StorageLive(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 - _8 = NoVariants { int: const 0_u32 }; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 -- _7 = (_8.1: Empty); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71 -- _6 = [move _7]; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74 -- StorageDead(_7); // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 -+ nop; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71 -+ nop; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74 -+ nop; // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 - StorageDead(_8); // scope 3 at $DIR/invalid_constant.rs:+20:74: +20:75 -- StorageLive(_9); // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 -- _0 = const (); // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2 -- StorageDead(_9); // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 -- StorageDead(_6); // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 -+ nop; // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 -+ nop; // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2 -+ nop; // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 -+ nop; // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 - StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2 - StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2 - return; // scope 0 at $DIR/invalid_constant.rs:+27:2: +27:2 + StorageLive(_1); + StorageLive(_2); + _2 = InvalidChar { int: const 1114113_u32 }; + _1 = (_2.1: char); + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _5 = InvalidTag { int: const 4_u32 }; + _4 = (_5.1: E); + _3 = [move _4]; + StorageDead(_4); + StorageDead(_5); +- StorageLive(_6); +- StorageLive(_7); ++ nop; ++ nop; + StorageLive(_8); + _8 = NoVariants { int: const 0_u32 }; +- _7 = (_8.1: Empty); +- _6 = [move _7]; +- StorageDead(_7); ++ nop; ++ nop; ++ nop; + StorageDead(_8); +- StorageLive(_9); +- _0 = const (); +- StorageDead(_9); +- StorageDead(_6); ++ nop; ++ nop; ++ nop; ++ nop; + StorageDead(_3); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff deleted file mode 100644 index 265269409..000000000 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff +++ /dev/null @@ -1,23 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue_66971.rs:+0:11: +0:11 - let _1: (); // in scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 - let mut _2: ((), u8, u8); // in scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - _2 = (const (), const 0_u8, const 0_u8); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - _1 = encode(move _2) -> bb1; // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 - // mir::Constant - // + span: $DIR/issue_66971.rs:18:5: 18:11 - // + literal: Const { ty: fn(((), u8, u8)) {encode}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_2); // scope 0 at $DIR/issue_66971.rs:+1:22: +1:23 - return; // scope 0 at $DIR/issue_66971.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..516f13586 --- /dev/null +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff @@ -0,0 +1,20 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: (); + let mut _2: ((), u8, u8); + + bb0: { + StorageLive(_2); + _2 = (const (), const 0_u8, const 0_u8); + _1 = encode(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..5e3443228 --- /dev/null +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff @@ -0,0 +1,20 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: (); + let mut _2: ((), u8, u8); + + bb0: { + StorageLive(_2); + _2 = (const (), const 0_u8, const 0_u8); + _1 = encode(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/const_prop/issue_66971.rs b/tests/mir-opt/const_prop/issue_66971.rs index af95c9ca2..a0242ec63 100644 --- a/tests/mir-opt/const_prop/issue_66971.rs +++ b/tests/mir-opt/const_prop/issue_66971.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Z mir-opt-level=3 diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff deleted file mode 100644 index 54c9200d6..000000000 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff +++ /dev/null @@ -1,28 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue_67019.rs:+0:11: +0:11 - let _1: (); // in scope 0 at $DIR/issue_67019.rs:+1:5: +1:20 - let mut _2: ((u8, u8),); // in scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 - let mut _3: (u8, u8); // in scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 - StorageLive(_3); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 -- _3 = (const 1_u8, const 2_u8); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 -+ _3 = const (1_u8, 2_u8); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 - _2 = (move _3,); // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 - StorageDead(_3); // scope 0 at $DIR/issue_67019.rs:+1:18: +1:19 - _1 = test(move _2) -> bb1; // scope 0 at $DIR/issue_67019.rs:+1:5: +1:20 - // mir::Constant - // + span: $DIR/issue_67019.rs:13:5: 13:9 - // + literal: Const { ty: fn(((u8, u8),)) {test}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_2); // scope 0 at $DIR/issue_67019.rs:+1:19: +1:20 - return; // scope 0 at $DIR/issue_67019.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..96b409372 --- /dev/null +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff @@ -0,0 +1,25 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: (); + let mut _2: ((u8, u8),); + let mut _3: (u8, u8); + + bb0: { + StorageLive(_2); + StorageLive(_3); +- _3 = (const 1_u8, const 2_u8); ++ _3 = const (1_u8, 2_u8); + _2 = (move _3,); + StorageDead(_3); + _1 = test(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..957760301 --- /dev/null +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff @@ -0,0 +1,25 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: (); + let mut _2: ((u8, u8),); + let mut _3: (u8, u8); + + bb0: { + StorageLive(_2); + StorageLive(_3); +- _3 = (const 1_u8, const 2_u8); ++ _3 = const (1_u8, 2_u8); + _2 = (move _3,); + StorageDead(_3); + _1 = test(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/const_prop/issue_67019.rs b/tests/mir-opt/const_prop/issue_67019.rs index 08c7d4805..66b577f5b 100644 --- a/tests/mir-opt/const_prop/issue_67019.rs +++ b/tests/mir-opt/const_prop/issue_67019.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Z mir-opt-level=3 diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff deleted file mode 100644 index 33bbad2f4..000000000 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff +++ /dev/null @@ -1,39 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/large_array_index.rs:+0:11: +0:11 - let _1: u8; // in scope 0 at $DIR/large_array_index.rs:+2:9: +2:10 - let mut _2: [u8; 5000]; // in scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 - let _3: usize; // in scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 - let mut _4: usize; // in scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - let mut _5: bool; // in scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - scope 1 { - debug x => _1; // in scope 1 at $DIR/large_array_index.rs:+2:9: +2:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/large_array_index.rs:+2:9: +2:10 - StorageLive(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 - _2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 - StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 - _3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 -- _4 = Len(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -- _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - } - - bb1: { -- _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ _1 = _2[2 of 3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 - StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 - _0 = const (); // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2 - StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2 - return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff new file mode 100644 index 000000000..61ba52fb0 --- /dev/null +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: [u8; 5000]; + let _3: usize; + let mut _4: usize; + let mut _5: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = [const 0_u8; 5000]; + StorageLive(_3); + _3 = const 2_usize; +- _4 = Len(_2); +- _5 = Lt(_3, _4); +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; ++ _4 = const 5000_usize; ++ _5 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = _2[_3]; ++ _1 = _2[2 of 3]; + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff new file mode 100644 index 000000000..658607116 --- /dev/null +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: [u8; 5000]; + let _3: usize; + let mut _4: usize; + let mut _5: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = [const 0_u8; 5000]; + StorageLive(_3); + _3 = const 2_usize; +- _4 = Len(_2); +- _5 = Lt(_3, _4); +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; ++ _4 = const 5000_usize; ++ _5 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = _2[_3]; ++ _1 = _2[2 of 3]; + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff deleted file mode 100644 index 33bbad2f4..000000000 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff +++ /dev/null @@ -1,39 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/large_array_index.rs:+0:11: +0:11 - let _1: u8; // in scope 0 at $DIR/large_array_index.rs:+2:9: +2:10 - let mut _2: [u8; 5000]; // in scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 - let _3: usize; // in scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 - let mut _4: usize; // in scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - let mut _5: bool; // in scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - scope 1 { - debug x => _1; // in scope 1 at $DIR/large_array_index.rs:+2:9: +2:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/large_array_index.rs:+2:9: +2:10 - StorageLive(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 - _2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 - StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 - _3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 -- _4 = Len(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -- _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - } - - bb1: { -- _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ _1 = _2[2 of 3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 - StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 - _0 = const (); // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2 - StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2 - return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff new file mode 100644 index 000000000..61ba52fb0 --- /dev/null +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: [u8; 5000]; + let _3: usize; + let mut _4: usize; + let mut _5: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = [const 0_u8; 5000]; + StorageLive(_3); + _3 = const 2_usize; +- _4 = Len(_2); +- _5 = Lt(_3, _4); +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; ++ _4 = const 5000_usize; ++ _5 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = _2[_3]; ++ _1 = _2[2 of 3]; + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff new file mode 100644 index 000000000..658607116 --- /dev/null +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u8; + let mut _2: [u8; 5000]; + let _3: usize; + let mut _4: usize; + let mut _5: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = [const 0_u8; 5000]; + StorageLive(_3); + _3 = const 2_usize; +- _4 = Len(_2); +- _5 = Lt(_3, _4); +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; ++ _4 = const 5000_usize; ++ _5 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = _2[_3]; ++ _1 = _2[2 of 3]; + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/large_array_index.rs b/tests/mir-opt/const_prop/large_array_index.rs index 0876445bf..6c03fe9d9 100644 --- a/tests/mir-opt/const_prop/large_array_index.rs +++ b/tests/mir-opt/const_prop/large_array_index.rs @@ -1,5 +1,5 @@ // unit-test: ConstProp -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zmir-enable-passes=+NormalizeArrayLen // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff b/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff index 629c8e601..73b1da064 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff @@ -2,17 +2,17 @@ + // MIR for `test` after ConstProp fn test(_1: i32) -> i32 { - debug x => _1; // in scope 0 at $DIR/mult_by_zero.rs:+0:9: +0:10 - let mut _0: i32; // return place in scope 0 at $DIR/mult_by_zero.rs:+0:21: +0:24 - let mut _2: i32; // in scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 + debug x => _1; + let mut _0: i32; + let mut _2: i32; bb0: { - StorageLive(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 - _2 = _1; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 -- _0 = Mul(move _2, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 -+ _0 = const 0_i32; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 - StorageDead(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:7: +1:8 - return; // scope 0 at $DIR/mult_by_zero.rs:+2:2: +2:2 + StorageLive(_2); + _2 = _1; +- _0 = Mul(move _2, const 0_i32); ++ _0 = const 0_i32; + StorageDead(_2); + return; } } diff --git a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff index bd010e7b1..ad8d9ddb0 100644 --- a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff @@ -2,27 +2,27 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/mutable_variable.rs:+0:11: +0:11 - let mut _1: i32; // in scope 0 at $DIR/mutable_variable.rs:+1:9: +1:14 + let mut _0: (); + let mut _1: i32; scope 1 { - debug x => _1; // in scope 1 at $DIR/mutable_variable.rs:+1:9: +1:14 - let _2: i32; // in scope 1 at $DIR/mutable_variable.rs:+3:9: +3:10 + debug x => _1; + let _2: i32; scope 2 { - debug y => _2; // in scope 2 at $DIR/mutable_variable.rs:+3:9: +3:10 + debug y => _2; } } bb0: { - StorageLive(_1); // scope 0 at $DIR/mutable_variable.rs:+1:9: +1:14 - _1 = const 42_i32; // scope 0 at $DIR/mutable_variable.rs:+1:17: +1:19 - _1 = const 99_i32; // scope 1 at $DIR/mutable_variable.rs:+2:5: +2:11 - StorageLive(_2); // scope 1 at $DIR/mutable_variable.rs:+3:9: +3:10 -- _2 = _1; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 -+ _2 = const 99_i32; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 - _0 = const (); // scope 0 at $DIR/mutable_variable.rs:+0:11: +4:2 - StorageDead(_2); // scope 1 at $DIR/mutable_variable.rs:+4:1: +4:2 - StorageDead(_1); // scope 0 at $DIR/mutable_variable.rs:+4:1: +4:2 - return; // scope 0 at $DIR/mutable_variable.rs:+4:2: +4:2 + StorageLive(_1); + _1 = const 42_i32; + _1 = const 99_i32; + StorageLive(_2); +- _2 = _1; ++ _2 = const 99_i32; + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff index 539f6dd94..0f118c7f5 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff @@ -2,28 +2,28 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +0:11 - let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 + let mut _0: (); + let mut _1: (i32, i32); scope 1 { - debug x => _1; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 - let _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 + debug x => _1; + let _2: (i32, i32); scope 2 { - debug y => _2; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 + debug y => _2; } } bb0: { - StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 -- _1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 -+ _1 = const (42_i32, 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 - (_1.1: i32) = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13 - StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 -- _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 -+ _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 - _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +4:2 - StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 - StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 - return; // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:2: +4:2 + StorageLive(_1); +- _1 = (const 42_i32, const 43_i32); ++ _1 = const (42_i32, 43_i32); + (_1.1: i32) = const 99_i32; + StorageLive(_2); +- _2 = _1; ++ _2 = const (42_i32, 99_i32); + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff index bec641ecf..106e27f8f 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff @@ -2,33 +2,33 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+0:11: +0:11 - let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+1:9: +1:14 + let mut _0: (); + let mut _1: (i32, i32); scope 1 { - debug x => _1; // in scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+1:9: +1:14 - let _2: &mut (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 + debug x => _1; + let _2: &mut (i32, i32); scope 2 { - debug z => _2; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 - let _3: (i32, i32); // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + debug z => _2; + let _3: (i32, i32); scope 3 { - debug y => _3; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + debug y => _3; } } } bb0: { - StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+1:9: +1:14 - _1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+1:17: +1:25 - StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 - _2 = &mut _1; // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:13: +2:19 - ((*_2).1: i32) = const 99_i32; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+3:5: +3:13 - StorageLive(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 - _3 = _1; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 - _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+0:11: +5:2 - StorageDead(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 - StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 - StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 - return; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:2: +5:2 + StorageLive(_1); + _1 = (const 42_i32, const 43_i32); + StorageLive(_2); + _2 = &mut _1; + ((*_2).1: i32) = const 99_i32; + StorageLive(_3); + _3 = _1; + _0 = const (); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff deleted file mode 100644 index 374151057..000000000 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff +++ /dev/null @@ -1,35 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+0:11: +0:11 - let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:9: +1:14 - scope 1 { - debug x => _1; // in scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:9: +1:14 - let _2: i32; // in scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:9: +4:10 - scope 2 { - debug y => _2; // in scope 2 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:9: +4:10 - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:9: +1:14 - _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:29: +1:34 - // mir::Constant - // + span: $DIR/mutable_variable_aggregate_partial_read.rs:6:29: 6:32 - // + literal: Const { ty: fn() -> (i32, i32) {foo}, val: Value(<ZST>) } - } - - bb1: { - (_1.1: i32) = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+2:5: +2:13 - (_1.0: i32) = const 42_i32; // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+3:5: +3:13 - StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:9: +4:10 -- _2 = (_1.1: i32); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 -+ _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 - _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+0:11: +5:2 - StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 - StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 - return; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..34288c62f --- /dev/null +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-abort.diff @@ -0,0 +1,32 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let mut _1: (i32, i32); + scope 1 { + debug x => _1; + let _2: i32; + scope 2 { + debug y => _2; + } + } + + bb0: { + StorageLive(_1); + _1 = foo() -> [return: bb1, unwind unreachable]; + } + + bb1: { + (_1.1: i32) = const 99_i32; + (_1.0: i32) = const 42_i32; + StorageLive(_2); +- _2 = (_1.1: i32); ++ _2 = const 99_i32; + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..7ba2b483d --- /dev/null +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff @@ -0,0 +1,32 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let mut _1: (i32, i32); + scope 1 { + debug x => _1; + let _2: i32; + scope 2 { + debug y => _2; + } + } + + bb0: { + StorageLive(_1); + _1 = foo() -> [return: bb1, unwind continue]; + } + + bb1: { + (_1.1: i32) = const 99_i32; + (_1.0: i32) = const 42_i32; + StorageLive(_2); +- _2 = (_1.1: i32); ++ _2 = const 99_i32; + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs index 0e823e9dc..30ea5714a 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff index fab810630..ac26f8ef4 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff @@ -2,43 +2,40 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +0:11 - let mut _1: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 - let _2: (); // in scope 0 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 - let mut _3: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - let mut _4: *mut u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + let mut _0: (); + let mut _1: u32; + let _2: (); + let mut _3: u32; + let mut _4: *mut u32; scope 1 { - debug x => _1; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 - let _5: u32; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + debug x => _1; + let _5: u32; scope 2 { } scope 3 { - debug y => _5; // in scope 3 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + debug y => _5; } } bb0: { - StorageLive(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 - _1 = const 42_u32; // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:17: +1:19 - StorageLive(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 - StorageLive(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - StorageLive(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - _4 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - // mir::Constant - // + span: $DIR/mutable_variable_no_prop.rs:9:13: 9:19 - // + literal: Const { ty: *mut u32, val: Value(Scalar(alloc1)) } - _3 = (*_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - _1 = move _3; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19 - StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:18: +3:19 - StorageDead(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:19: +3:20 - _2 = const (); // scope 2 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 - StorageDead(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+4:5: +4:6 - StorageLive(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 - _5 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:13: +5:14 - _0 = const (); // scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +6:2 - StorageDead(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 - StorageDead(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 - return; // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:2: +6:2 + StorageLive(_1); + _1 = const 42_u32; + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _4 = const {alloc1: *mut u32}; + _3 = (*_4); + _1 = move _3; + StorageDead(_3); + StorageDead(_4); + _2 = const (); + StorageDead(_2); + StorageLive(_5); + _5 = _1; + _0 = const (); + StorageDead(_5); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff deleted file mode 100644 index 3048122d8..000000000 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff +++ /dev/null @@ -1,53 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 - let mut _3: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - scope 1 { - debug a => _1; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 - let mut _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - scope 2 { - debug x => _2; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - let _4: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - scope 3 { - debug y => _4; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - let _5: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 - scope 4 { - debug z => _5; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 - } - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 - _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:13: +1:18 - // mir::Constant - // + span: $DIR/mutable_variable_unprop_assign.rs:6:13: 6:16 - // + literal: Const { ty: fn() -> i32 {foo}, val: Value(<ZST>) } - } - - bb1: { - StorageLive(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 -- _2 = (const 1_i32, const 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 -+ _2 = const (1_i32, 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - _3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - (_2.1: i32) = move _3; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 - StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - StorageLive(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - _4 = (_2.1: i32); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 - StorageLive(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 -- _5 = (_2.0: i32); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 -+ _5 = const 1_i32; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 - _0 = const (); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +6:2 - StorageDead(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - StorageDead(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - StorageDead(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - StorageDead(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - return; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:2: +6:2 - } - } - diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..a85dcf9c7 --- /dev/null +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff @@ -0,0 +1,50 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _3: i32; + scope 1 { + debug a => _1; + let mut _2: (i32, i32); + scope 2 { + debug x => _2; + let _4: i32; + scope 3 { + debug y => _4; + let _5: i32; + scope 4 { + debug z => _5; + } + } + } + } + + bb0: { + StorageLive(_1); + _1 = foo() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageLive(_2); +- _2 = (const 1_i32, const 2_i32); ++ _2 = const (1_i32, 2_i32); + StorageLive(_3); + _3 = _1; + (_2.1: i32) = move _3; + StorageDead(_3); + StorageLive(_4); + _4 = (_2.1: i32); + StorageLive(_5); +- _5 = (_2.0: i32); ++ _5 = const 1_i32; + _0 = const (); + StorageDead(_5); + StorageDead(_4); + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..15ef0fa4d --- /dev/null +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff @@ -0,0 +1,50 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _3: i32; + scope 1 { + debug a => _1; + let mut _2: (i32, i32); + scope 2 { + debug x => _2; + let _4: i32; + scope 3 { + debug y => _4; + let _5: i32; + scope 4 { + debug z => _5; + } + } + } + } + + bb0: { + StorageLive(_1); + _1 = foo() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageLive(_2); +- _2 = (const 1_i32, const 2_i32); ++ _2 = const (1_i32, 2_i32); + StorageLive(_3); + _3 = _1; + (_2.1: i32) = move _3; + StorageDead(_3); + StorageLive(_4); + _4 = (_2.1: i32); + StorageLive(_5); +- _5 = (_2.0: i32); ++ _5 = const 1_i32; + _0 = const (); + StorageDead(_5); + StorageDead(_4); + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs index 5577f78a9..4e7c0597a 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff deleted file mode 100644 index e3757941c..000000000 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff +++ /dev/null @@ -1,44 +0,0 @@ -- // MIR for `concrete` before ConstProp -+ // MIR for `concrete` after ConstProp - - fn concrete() -> () { - let mut _0: (); // return place in scope 0 at $DIR/offset_of.rs:+0:15: +0:15 - let _1: usize; // in scope 0 at $DIR/offset_of.rs:+1:9: +1:10 - scope 1 { - debug x => _1; // in scope 1 at $DIR/offset_of.rs:+1:9: +1:10 - let _2: usize; // in scope 1 at $DIR/offset_of.rs:+2:9: +2:10 - scope 2 { - debug y => _2; // in scope 2 at $DIR/offset_of.rs:+2:9: +2:10 - let _3: usize; // in scope 2 at $DIR/offset_of.rs:+3:9: +3:11 - scope 3 { - debug z0 => _3; // in scope 3 at $DIR/offset_of.rs:+3:9: +3:11 - let _4: usize; // in scope 3 at $DIR/offset_of.rs:+4:9: +4:11 - scope 4 { - debug z1 => _4; // in scope 4 at $DIR/offset_of.rs:+4:9: +4:11 - } - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/offset_of.rs:+1:9: +1:10 -- _1 = OffsetOf(Alpha, [0]); // scope 0 at $SRC_DIR/core/src/mem/mod.rs:LL:COL -+ _1 = const 4_usize; // scope 0 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_2); // scope 1 at $DIR/offset_of.rs:+2:9: +2:10 -- _2 = OffsetOf(Alpha, [1]); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL -+ _2 = const 0_usize; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_3); // scope 2 at $DIR/offset_of.rs:+3:9: +3:11 -- _3 = OffsetOf(Alpha, [2, 0]); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL -+ _3 = const 2_usize; // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11 -- _4 = OffsetOf(Alpha, [2, 1]); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL -+ _4 = const 3_usize; // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - _0 = const (); // scope 0 at $DIR/offset_of.rs:+0:15: +5:2 - StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2 - StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2 - StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2 - StorageDead(_1); // scope 0 at $DIR/offset_of.rs:+5:1: +5:2 - return; // scope 0 at $DIR/offset_of.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff new file mode 100644 index 000000000..046a79b4b --- /dev/null +++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff @@ -0,0 +1,72 @@ +- // MIR for `concrete` before ConstProp ++ // MIR for `concrete` after ConstProp + + fn concrete() -> () { + let mut _0: (); + let _1: usize; + let mut _2: usize; + let mut _4: usize; + let mut _6: usize; + let mut _8: usize; + scope 1 { + debug x => _1; + let _3: usize; + scope 2 { + debug y => _3; + let _5: usize; + scope 3 { + debug z0 => _5; + let _7: usize; + scope 4 { + debug z1 => _7; + } + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); +- _2 = OffsetOf(Alpha, [0]); ++ _2 = const 4_usize; + _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); +- _4 = OffsetOf(Alpha, [1]); ++ _4 = const 0_usize; + _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_4); + StorageLive(_5); + StorageLive(_6); +- _6 = OffsetOf(Alpha, [2, 0]); ++ _6 = const 2_usize; + _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_6); + StorageLive(_7); + StorageLive(_8); +- _8 = OffsetOf(Alpha, [2, 1]); ++ _8 = const 3_usize; + _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_8); + _0 = const (); + StorageDead(_7); + StorageDead(_5); + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..bbb807d8f --- /dev/null +++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff @@ -0,0 +1,72 @@ +- // MIR for `concrete` before ConstProp ++ // MIR for `concrete` after ConstProp + + fn concrete() -> () { + let mut _0: (); + let _1: usize; + let mut _2: usize; + let mut _4: usize; + let mut _6: usize; + let mut _8: usize; + scope 1 { + debug x => _1; + let _3: usize; + scope 2 { + debug y => _3; + let _5: usize; + scope 3 { + debug z0 => _5; + let _7: usize; + scope 4 { + debug z1 => _7; + } + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); +- _2 = OffsetOf(Alpha, [0]); ++ _2 = const 4_usize; + _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); +- _4 = OffsetOf(Alpha, [1]); ++ _4 = const 0_usize; + _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_4); + StorageLive(_5); + StorageLive(_6); +- _6 = OffsetOf(Alpha, [2, 0]); ++ _6 = const 2_usize; + _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_6); + StorageLive(_7); + StorageLive(_8); +- _8 = OffsetOf(Alpha, [2, 1]); ++ _8 = const 3_usize; + _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_8); + _0 = const (); + StorageDead(_7); + StorageDead(_5); + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff deleted file mode 100644 index 4a655604c..000000000 --- a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff +++ /dev/null @@ -1,40 +0,0 @@ -- // MIR for `generic` before ConstProp -+ // MIR for `generic` after ConstProp - - fn generic() -> () { - let mut _0: (); // return place in scope 0 at $DIR/offset_of.rs:+0:17: +0:17 - let _1: usize; // in scope 0 at $DIR/offset_of.rs:+1:9: +1:11 - scope 1 { - debug gx => _1; // in scope 1 at $DIR/offset_of.rs:+1:9: +1:11 - let _2: usize; // in scope 1 at $DIR/offset_of.rs:+2:9: +2:11 - scope 2 { - debug gy => _2; // in scope 2 at $DIR/offset_of.rs:+2:9: +2:11 - let _3: usize; // in scope 2 at $DIR/offset_of.rs:+3:9: +3:11 - scope 3 { - debug dx => _3; // in scope 3 at $DIR/offset_of.rs:+3:9: +3:11 - let _4: usize; // in scope 3 at $DIR/offset_of.rs:+4:9: +4:11 - scope 4 { - debug dy => _4; // in scope 4 at $DIR/offset_of.rs:+4:9: +4:11 - } - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/offset_of.rs:+1:9: +1:11 - _1 = OffsetOf(Gamma<T>, [0]); // scope 0 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_2); // scope 1 at $DIR/offset_of.rs:+2:9: +2:11 - _2 = OffsetOf(Gamma<T>, [1]); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_3); // scope 2 at $DIR/offset_of.rs:+3:9: +3:11 - _3 = OffsetOf(Delta<T>, [1]); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11 - _4 = OffsetOf(Delta<T>, [2]); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - _0 = const (); // scope 0 at $DIR/offset_of.rs:+0:17: +5:2 - StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2 - StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2 - StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2 - StorageDead(_1); // scope 0 at $DIR/offset_of.rs:+5:1: +5:2 - return; // scope 0 at $DIR/offset_of.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff new file mode 100644 index 000000000..7519331f6 --- /dev/null +++ b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff @@ -0,0 +1,68 @@ +- // MIR for `generic` before ConstProp ++ // MIR for `generic` after ConstProp + + fn generic() -> () { + let mut _0: (); + let _1: usize; + let mut _2: usize; + let mut _4: usize; + let mut _6: usize; + let mut _8: usize; + scope 1 { + debug gx => _1; + let _3: usize; + scope 2 { + debug gy => _3; + let _5: usize; + scope 3 { + debug dx => _5; + let _7: usize; + scope 4 { + debug dy => _7; + } + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = OffsetOf(Gamma<T>, [0]); + _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); + _4 = OffsetOf(Gamma<T>, [1]); + _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_4); + StorageLive(_5); + StorageLive(_6); + _6 = OffsetOf(Delta<T>, [1]); + _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_6); + StorageLive(_7); + StorageLive(_8); + _8 = OffsetOf(Delta<T>, [2]); + _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_8); + _0 = const (); + StorageDead(_7); + StorageDead(_5); + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..fd5206e46 --- /dev/null +++ b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff @@ -0,0 +1,68 @@ +- // MIR for `generic` before ConstProp ++ // MIR for `generic` after ConstProp + + fn generic() -> () { + let mut _0: (); + let _1: usize; + let mut _2: usize; + let mut _4: usize; + let mut _6: usize; + let mut _8: usize; + scope 1 { + debug gx => _1; + let _3: usize; + scope 2 { + debug gy => _3; + let _5: usize; + scope 3 { + debug dx => _5; + let _7: usize; + scope 4 { + debug dy => _7; + } + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = OffsetOf(Gamma<T>, [0]); + _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); + _4 = OffsetOf(Gamma<T>, [1]); + _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_4); + StorageLive(_5); + StorageLive(_6); + _6 = OffsetOf(Delta<T>, [1]); + _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_6); + StorageLive(_7); + StorageLive(_8); + _8 = OffsetOf(Delta<T>, [2]); + _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_8); + _0 = const (); + StorageDead(_7); + StorageDead(_5); + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/offset_of.rs b/tests/mir-opt/const_prop/offset_of.rs index 4cdcd28ee..164db5957 100644 --- a/tests/mir-opt/const_prop/offset_of.rs +++ b/tests/mir-opt/const_prop/offset_of.rs @@ -1,4 +1,5 @@ // unit-test: ConstProp +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![feature(offset_of)] diff --git a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff b/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff index c290fba56..29c455f35 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff @@ -2,43 +2,37 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/read_immutable_static.rs:+0:11: +0:11 - let _1: u8; // in scope 0 at $DIR/read_immutable_static.rs:+1:9: +1:10 - let mut _2: u8; // in scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 - let mut _3: &u8; // in scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 - let mut _4: u8; // in scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 - let mut _5: &u8; // in scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 + let mut _0: (); + let _1: u8; + let mut _2: u8; + let mut _3: &u8; + let mut _4: u8; + let mut _5: &u8; scope 1 { - debug x => _1; // in scope 1 at $DIR/read_immutable_static.rs:+1:9: +1:10 + debug x => _1; } bb0: { - StorageLive(_1); // scope 0 at $DIR/read_immutable_static.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 - StorageLive(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 - _3 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 - // mir::Constant - // + span: $DIR/read_immutable_static.rs:7:13: 7:16 - // + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) } -- _2 = (*_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 -+ _2 = const 2_u8; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 - StorageLive(_4); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 - StorageLive(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 - _5 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 - // mir::Constant - // + span: $DIR/read_immutable_static.rs:7:19: 7:22 - // + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) } -- _4 = (*_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 -- _1 = Add(move _2, move _4); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:22 -+ _4 = const 2_u8; // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 -+ _1 = const 4_u8; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:22 - StorageDead(_4); // scope 0 at $DIR/read_immutable_static.rs:+1:21: +1:22 - StorageDead(_2); // scope 0 at $DIR/read_immutable_static.rs:+1:21: +1:22 - StorageDead(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 - StorageDead(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 - _0 = const (); // scope 0 at $DIR/read_immutable_static.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/read_immutable_static.rs:+2:1: +2:2 - return; // scope 0 at $DIR/read_immutable_static.rs:+2:2: +2:2 + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = const {alloc1: &u8}; +- _2 = (*_3); ++ _2 = const 2_u8; + StorageLive(_4); + StorageLive(_5); + _5 = const {alloc1: &u8}; +- _4 = (*_5); +- _1 = Add(move _2, move _4); ++ _4 = const 2_u8; ++ _1 = const 4_u8; + StorageDead(_4); + StorageDead(_2); + StorageDead(_5); + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff index 924a267f3..6b897a881 100644 --- a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff @@ -2,25 +2,22 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/ref_deref.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 - let mut _2: &i32; // in scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 - let _3: i32; // in scope 0 at $DIR/ref_deref.rs:+1:8: +1:9 - let mut _4: &i32; // in scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 + let mut _0: (); + let _1: i32; + let mut _2: &i32; + let _3: i32; + let mut _4: &i32; bb0: { - StorageLive(_1); // scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 - StorageLive(_2); // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 - _4 = const _; // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 - // mir::Constant - // + span: $DIR/ref_deref.rs:5:6: 5:10 - // + literal: Const { ty: &i32, val: Unevaluated(main, [], Some(promoted[0])) } - _2 = &(*_4); // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 - _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 - StorageDead(_2); // scope 0 at $DIR/ref_deref.rs:+1:10: +1:11 - StorageDead(_1); // scope 0 at $DIR/ref_deref.rs:+1:10: +1:11 - _0 = const (); // scope 0 at $DIR/ref_deref.rs:+0:11: +2:2 - return; // scope 0 at $DIR/ref_deref.rs:+2:2: +2:2 + StorageLive(_1); + StorageLive(_2); + _4 = const _; + _2 = &(*_4); + _1 = (*_2); + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; } } diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff index 59095b448..7f6161665 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff @@ -2,25 +2,22 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/ref_deref_project.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/ref_deref_project.rs:+1:5: +1:17 - let mut _2: &i32; // in scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 - let _3: (i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:+1:8: +1:14 - let mut _4: &(i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 + let mut _0: (); + let _1: i32; + let mut _2: &i32; + let _3: (i32, i32); + let mut _4: &(i32, i32); bb0: { - StorageLive(_1); // scope 0 at $DIR/ref_deref_project.rs:+1:5: +1:17 - StorageLive(_2); // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 - _4 = const _; // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 - // mir::Constant - // + span: $DIR/ref_deref_project.rs:5:6: 5:17 - // + literal: Const { ty: &(i32, i32), val: Unevaluated(main, [], Some(promoted[0])) } - _2 = &((*_4).1: i32); // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 - _1 = (*_2); // scope 0 at $DIR/ref_deref_project.rs:+1:5: +1:17 - StorageDead(_2); // scope 0 at $DIR/ref_deref_project.rs:+1:17: +1:18 - StorageDead(_1); // scope 0 at $DIR/ref_deref_project.rs:+1:17: +1:18 - _0 = const (); // scope 0 at $DIR/ref_deref_project.rs:+0:11: +2:2 - return; // scope 0 at $DIR/ref_deref_project.rs:+2:2: +2:2 + StorageLive(_1); + StorageLive(_2); + _4 = const _; + _2 = &((*_4).1: i32); + _1 = (*_2); + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; } } diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff b/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff index 077b9bf83..e7aa015d0 100644 --- a/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff @@ -2,28 +2,25 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +0:11 - let mut _1: *const fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41 - let mut _2: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 - let mut _3: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 + let mut _0: (); + let mut _1: *const fn(); + let mut _2: usize; + let mut _3: fn(); scope 1 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41 - StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 - StorageLive(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 - _3 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 - // mir::Constant - // + span: $DIR/reify_fn_ptr.rs:5:13: 5:17 - // + literal: Const { ty: fn() {main}, val: Value(<ZST>) } - _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 - StorageDead(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:25: +1:26 - _1 = move _2 as *const fn() (PointerFromExposedAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41 - StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:40: +1:41 - StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:41: +1:42 - _0 = const (); // scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +2:2 - return; // scope 0 at $DIR/reify_fn_ptr.rs:+2:2: +2:2 + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = main as fn() (PointerCoercion(ReifyFnPointer)); + _2 = move _3 as usize (PointerExposeAddress); + StorageDead(_3); + _1 = move _2 as *const fn() (PointerFromExposedAddress); + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; } } diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff deleted file mode 100644 index 6641220db..000000000 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff +++ /dev/null @@ -1,44 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/repeat.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/repeat.rs:+1:9: +1:10 - let mut _2: u32; // in scope 0 at $DIR/repeat.rs:+1:18: +1:28 - let mut _3: [u32; 8]; // in scope 0 at $DIR/repeat.rs:+1:18: +1:25 - let _4: usize; // in scope 0 at $DIR/repeat.rs:+1:26: +1:27 - let mut _5: usize; // in scope 0 at $DIR/repeat.rs:+1:18: +1:28 - let mut _6: bool; // in scope 0 at $DIR/repeat.rs:+1:18: +1:28 - scope 1 { - debug x => _1; // in scope 1 at $DIR/repeat.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/repeat.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - StorageLive(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:25 - _3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25 - StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27 - _4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27 -- _5 = Len(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -- _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - } - - bb1: { -- _2 = _3[_4]; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -- _1 = Add(move _2, const 0_u32); // scope 0 at $DIR/repeat.rs:+1:18: +1:32 -+ _2 = const 42_u32; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ _1 = const 42_u32; // scope 0 at $DIR/repeat.rs:+1:18: +1:32 - StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32 - StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 - StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 - _0 = const (); // scope 0 at $DIR/repeat.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2 - return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff new file mode 100644 index 000000000..e095dd01d --- /dev/null +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff @@ -0,0 +1,44 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: u32; + let mut _3: [u32; 8]; + let _4: usize; + let mut _5: usize; + let mut _6: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = [const 42_u32; 8]; + StorageLive(_4); + _4 = const 2_usize; +- _5 = Len(_3); +- _6 = Lt(_4, _5); +- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; ++ _5 = const 8_usize; ++ _6 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _2 = _3[_4]; +- _1 = Add(move _2, const 0_u32); ++ _2 = const 42_u32; ++ _1 = const 42_u32; + StorageDead(_2); + StorageDead(_4); + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff new file mode 100644 index 000000000..571f279a8 --- /dev/null +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff @@ -0,0 +1,44 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: u32; + let mut _3: [u32; 8]; + let _4: usize; + let mut _5: usize; + let mut _6: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = [const 42_u32; 8]; + StorageLive(_4); + _4 = const 2_usize; +- _5 = Len(_3); +- _6 = Lt(_4, _5); +- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; ++ _5 = const 8_usize; ++ _6 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; + } + + bb1: { +- _2 = _3[_4]; +- _1 = Add(move _2, const 0_u32); ++ _2 = const 42_u32; ++ _1 = const 42_u32; + StorageDead(_2); + StorageDead(_4); + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff deleted file mode 100644 index 6641220db..000000000 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff +++ /dev/null @@ -1,44 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/repeat.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/repeat.rs:+1:9: +1:10 - let mut _2: u32; // in scope 0 at $DIR/repeat.rs:+1:18: +1:28 - let mut _3: [u32; 8]; // in scope 0 at $DIR/repeat.rs:+1:18: +1:25 - let _4: usize; // in scope 0 at $DIR/repeat.rs:+1:26: +1:27 - let mut _5: usize; // in scope 0 at $DIR/repeat.rs:+1:18: +1:28 - let mut _6: bool; // in scope 0 at $DIR/repeat.rs:+1:18: +1:28 - scope 1 { - debug x => _1; // in scope 1 at $DIR/repeat.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/repeat.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - StorageLive(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:25 - _3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25 - StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27 - _4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27 -- _5 = Len(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -- _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - } - - bb1: { -- _2 = _3[_4]; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -- _1 = Add(move _2, const 0_u32); // scope 0 at $DIR/repeat.rs:+1:18: +1:32 -+ _2 = const 42_u32; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ _1 = const 42_u32; // scope 0 at $DIR/repeat.rs:+1:18: +1:32 - StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32 - StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 - StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 - _0 = const (); // scope 0 at $DIR/repeat.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2 - return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff new file mode 100644 index 000000000..e095dd01d --- /dev/null +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff @@ -0,0 +1,44 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: u32; + let mut _3: [u32; 8]; + let _4: usize; + let mut _5: usize; + let mut _6: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = [const 42_u32; 8]; + StorageLive(_4); + _4 = const 2_usize; +- _5 = Len(_3); +- _6 = Lt(_4, _5); +- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; ++ _5 = const 8_usize; ++ _6 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _2 = _3[_4]; +- _1 = Add(move _2, const 0_u32); ++ _2 = const 42_u32; ++ _1 = const 42_u32; + StorageDead(_2); + StorageDead(_4); + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff new file mode 100644 index 000000000..571f279a8 --- /dev/null +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff @@ -0,0 +1,44 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: u32; + let mut _3: [u32; 8]; + let _4: usize; + let mut _5: usize; + let mut _6: bool; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = [const 42_u32; 8]; + StorageLive(_4); + _4 = const 2_usize; +- _5 = Len(_3); +- _6 = Lt(_4, _5); +- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; ++ _5 = const 8_usize; ++ _6 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; + } + + bb1: { +- _2 = _3[_4]; +- _1 = Add(move _2, const 0_u32); ++ _2 = const 42_u32; ++ _1 = const 42_u32; + StorageDead(_2); + StorageDead(_4); + StorageDead(_3); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs index 9c11dbc5b..21dba84af 100644 --- a/tests/mir-opt/const_prop/repeat.rs +++ b/tests/mir-opt/const_prop/repeat.rs @@ -1,5 +1,5 @@ // unit-test: ConstProp -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zmir-enable-passes=+NormalizeArrayLen // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.diff b/tests/mir-opt/const_prop/return_place.add.ConstProp.diff deleted file mode 100644 index 5ebd8a520..000000000 --- a/tests/mir-opt/const_prop/return_place.add.ConstProp.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `add` before ConstProp -+ // MIR for `add` after ConstProp - - fn add() -> u32 { - let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:+0:13: +0:16 - let mut _1: (u32, bool); // in scope 0 at $DIR/return_place.rs:+1:5: +1:10 - - bb0: { -- _1 = CheckedAdd(const 2_u32, const 2_u32); // scope 0 at $DIR/return_place.rs:+1:5: +1:10 -- assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; // scope 0 at $DIR/return_place.rs:+1:5: +1:10 -+ _1 = const (4_u32, false); // scope 0 at $DIR/return_place.rs:+1:5: +1:10 -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; // scope 0 at $DIR/return_place.rs:+1:5: +1:10 - } - - bb1: { -- _0 = move (_1.0: u32); // scope 0 at $DIR/return_place.rs:+1:5: +1:10 -+ _0 = const 4_u32; // scope 0 at $DIR/return_place.rs:+1:5: +1:10 - return; // scope 0 at $DIR/return_place.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff new file mode 100644 index 000000000..f3b30e0dc --- /dev/null +++ b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff @@ -0,0 +1,21 @@ +- // MIR for `add` before ConstProp ++ // MIR for `add` after ConstProp + + fn add() -> u32 { + let mut _0: u32; + let mut _1: (u32, bool); + + bb0: { +- _1 = CheckedAdd(const 2_u32, const 2_u32); +- assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind unreachable]; ++ _1 = const (4_u32, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _0 = move (_1.0: u32); ++ _0 = const 4_u32; + return; + } + } + diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..79f85fcef --- /dev/null +++ b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff @@ -0,0 +1,21 @@ +- // MIR for `add` before ConstProp ++ // MIR for `add` after ConstProp + + fn add() -> u32 { + let mut _0: u32; + let mut _1: (u32, bool); + + bb0: { +- _1 = CheckedAdd(const 2_u32, const 2_u32); +- assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind continue]; ++ _1 = const (4_u32, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind continue]; + } + + bb1: { +- _0 = move (_1.0: u32); ++ _0 = const 4_u32; + return; + } + } + diff --git a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.mir b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.mir deleted file mode 100644 index b12d84fa4..000000000 --- a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.mir +++ /dev/null @@ -1,16 +0,0 @@ -// MIR for `add` before PreCodegen - -fn add() -> u32 { - let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:+0:13: +0:16 - let mut _1: (u32, bool); // in scope 0 at $DIR/return_place.rs:+1:5: +1:10 - - bb0: { - _1 = const (4_u32, false); // scope 0 at $DIR/return_place.rs:+1:5: +1:10 - assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; // scope 0 at $DIR/return_place.rs:+1:5: +1:10 - } - - bb1: { - _0 = const 4_u32; // scope 0 at $DIR/return_place.rs:+1:5: +1:10 - return; // scope 0 at $DIR/return_place.rs:+2:2: +2:2 - } -} diff --git a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir new file mode 100644 index 000000000..c8f3f641a --- /dev/null +++ b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir @@ -0,0 +1,16 @@ +// MIR for `add` before PreCodegen + +fn add() -> u32 { + let mut _0: u32; + let mut _1: (u32, bool); + + bb0: { + _1 = const (4_u32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind unreachable]; + } + + bb1: { + _0 = const 4_u32; + return; + } +} diff --git a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir new file mode 100644 index 000000000..9a0646974 --- /dev/null +++ b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir @@ -0,0 +1,16 @@ +// MIR for `add` before PreCodegen + +fn add() -> u32 { + let mut _0: u32; + let mut _1: (u32, bool); + + bb0: { + _1 = const (4_u32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind continue]; + } + + bb1: { + _0 = const 4_u32; + return; + } +} diff --git a/tests/mir-opt/const_prop/return_place.rs b/tests/mir-opt/const_prop/return_place.rs index 0e68309f0..0576b02a8 100644 --- a/tests/mir-opt/const_prop/return_place.rs +++ b/tests/mir-opt/const_prop/return_place.rs @@ -1,5 +1,5 @@ // unit-test: ConstProp -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -C overflow-checks=on // EMIT_MIR return_place.add.ConstProp.diff diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff deleted file mode 100644 index c2f97a0f6..000000000 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff +++ /dev/null @@ -1,34 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/scalar_literal_propagation.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/scalar_literal_propagation.rs:+1:9: +1:10 - let _2: (); // in scope 0 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 - let mut _3: u32; // in scope 0 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 - scope 1 { - debug x => _1; // in scope 1 at $DIR/scalar_literal_propagation.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+1:9: +1:10 - _1 = const 1_u32; // scope 0 at $DIR/scalar_literal_propagation.rs:+1:13: +1:14 - StorageLive(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 - StorageLive(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 -- _3 = _1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 -+ _3 = const 1_u32; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 - _2 = consume(move _3) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 - // mir::Constant - // + span: $DIR/scalar_literal_propagation.rs:6:5: 6:12 - // + literal: Const { ty: fn(u32) {consume}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:14: +2:15 - StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:15: +2:16 - _0 = const (); // scope 0 at $DIR/scalar_literal_propagation.rs:+0:11: +3:2 - StorageDead(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+3:1: +3:2 - return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..0677295d0 --- /dev/null +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff @@ -0,0 +1,31 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let _2: (); + let mut _3: u32; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + _1 = const 1_u32; + StorageLive(_2); + StorageLive(_3); +- _3 = _1; ++ _3 = const 1_u32; + _2 = consume(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..a7d7a7224 --- /dev/null +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff @@ -0,0 +1,31 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let _2: (); + let mut _3: u32; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + _1 = const 1_u32; + StorageLive(_2); + StorageLive(_3); +- _3 = _1; ++ _3 = const 1_u32; + _2 = consume(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.rs b/tests/mir-opt/const_prop/scalar_literal_propagation.rs index fc33cc2d0..dfe41e614 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs @@ -1,5 +1,5 @@ // unit-test: ConstProp -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR scalar_literal_propagation.main.ConstProp.diff fn main() { let x = 1; diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff deleted file mode 100644 index 8bd2b48d6..000000000 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff +++ /dev/null @@ -1,50 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/slice_len.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - let mut _2: &[u32]; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:30 - let mut _3: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - let _4: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - let _5: [u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:7: +1:19 - let _6: usize; // in scope 0 at $DIR/slice_len.rs:+1:31: +1:32 - let mut _7: usize; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - let mut _8: bool; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - let mut _9: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - StorageLive(_2); // scope 0 at $DIR/slice_len.rs:+1:5: +1:30 - StorageLive(_3); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - StorageLive(_4); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - _9 = const _; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - // mir::Constant - // + span: $DIR/slice_len.rs:8:6: 8:19 - // + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - _3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - _2 = move _3 as &[u32] (Pointer(Unsize)); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - StorageDead(_3); // scope 0 at $DIR/slice_len.rs:+1:18: +1:19 - StorageLive(_6); // scope 0 at $DIR/slice_len.rs:+1:31: +1:32 - _6 = const 1_usize; // scope 0 at $DIR/slice_len.rs:+1:31: +1:32 -- _7 = Len((*_2)); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -- _8 = Lt(_6, _7); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ _7 = const 3_usize; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ _8 = const true; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - } - - bb1: { -- _1 = (*_2)[_6]; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ _1 = const 2_u32; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - StorageDead(_6); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - StorageDead(_4); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - StorageDead(_2); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - StorageDead(_1); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - _0 = const (); // scope 0 at $DIR/slice_len.rs:+0:11: +2:2 - return; // scope 0 at $DIR/slice_len.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff new file mode 100644 index 000000000..3c2b8e111 --- /dev/null +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff @@ -0,0 +1,47 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: &[u32]; + let mut _3: &[u32; 3]; + let _4: &[u32; 3]; + let _5: [u32; 3]; + let _6: usize; + let mut _7: usize; + let mut _8: bool; + let mut _9: &[u32; 3]; + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _9 = const _; + _4 = _9; + _3 = _4; + _2 = move _3 as &[u32] (PointerCoercion(Unsize)); + StorageDead(_3); + StorageLive(_6); + _6 = const 1_usize; +- _7 = Len((*_2)); +- _8 = Lt(_6, _7); +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; ++ _7 = const 3_usize; ++ _8 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = (*_2)[_6]; ++ _1 = const 2_u32; + StorageDead(_6); + StorageDead(_4); + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff new file mode 100644 index 000000000..303096030 --- /dev/null +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff @@ -0,0 +1,47 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: &[u32]; + let mut _3: &[u32; 3]; + let _4: &[u32; 3]; + let _5: [u32; 3]; + let _6: usize; + let mut _7: usize; + let mut _8: bool; + let mut _9: &[u32; 3]; + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _9 = const _; + _4 = _9; + _3 = _4; + _2 = move _3 as &[u32] (PointerCoercion(Unsize)); + StorageDead(_3); + StorageLive(_6); + _6 = const 1_usize; +- _7 = Len((*_2)); +- _8 = Lt(_6, _7); +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; ++ _7 = const 3_usize; ++ _8 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = (*_2)[_6]; ++ _1 = const 2_u32; + StorageDead(_6); + StorageDead(_4); + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff deleted file mode 100644 index 8bd2b48d6..000000000 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff +++ /dev/null @@ -1,50 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/slice_len.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - let mut _2: &[u32]; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:30 - let mut _3: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - let _4: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - let _5: [u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:7: +1:19 - let _6: usize; // in scope 0 at $DIR/slice_len.rs:+1:31: +1:32 - let mut _7: usize; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - let mut _8: bool; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - let mut _9: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - StorageLive(_2); // scope 0 at $DIR/slice_len.rs:+1:5: +1:30 - StorageLive(_3); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - StorageLive(_4); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - _9 = const _; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - // mir::Constant - // + span: $DIR/slice_len.rs:8:6: 8:19 - // + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - _3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - _2 = move _3 as &[u32] (Pointer(Unsize)); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 - StorageDead(_3); // scope 0 at $DIR/slice_len.rs:+1:18: +1:19 - StorageLive(_6); // scope 0 at $DIR/slice_len.rs:+1:31: +1:32 - _6 = const 1_usize; // scope 0 at $DIR/slice_len.rs:+1:31: +1:32 -- _7 = Len((*_2)); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -- _8 = Lt(_6, _7); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ _7 = const 3_usize; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ _8 = const true; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - } - - bb1: { -- _1 = (*_2)[_6]; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ _1 = const 2_u32; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 - StorageDead(_6); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - StorageDead(_4); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - StorageDead(_2); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - StorageDead(_1); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - _0 = const (); // scope 0 at $DIR/slice_len.rs:+0:11: +2:2 - return; // scope 0 at $DIR/slice_len.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff new file mode 100644 index 000000000..3c2b8e111 --- /dev/null +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff @@ -0,0 +1,47 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: &[u32]; + let mut _3: &[u32; 3]; + let _4: &[u32; 3]; + let _5: [u32; 3]; + let _6: usize; + let mut _7: usize; + let mut _8: bool; + let mut _9: &[u32; 3]; + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _9 = const _; + _4 = _9; + _3 = _4; + _2 = move _3 as &[u32] (PointerCoercion(Unsize)); + StorageDead(_3); + StorageLive(_6); + _6 = const 1_usize; +- _7 = Len((*_2)); +- _8 = Lt(_6, _7); +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; ++ _7 = const 3_usize; ++ _8 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = (*_2)[_6]; ++ _1 = const 2_u32; + StorageDead(_6); + StorageDead(_4); + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff new file mode 100644 index 000000000..303096030 --- /dev/null +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff @@ -0,0 +1,47 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: u32; + let mut _2: &[u32]; + let mut _3: &[u32; 3]; + let _4: &[u32; 3]; + let _5: [u32; 3]; + let _6: usize; + let mut _7: usize; + let mut _8: bool; + let mut _9: &[u32; 3]; + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _9 = const _; + _4 = _9; + _3 = _4; + _2 = move _3 as &[u32] (PointerCoercion(Unsize)); + StorageDead(_3); + StorageLive(_6); + _6 = const 1_usize; +- _7 = Len((*_2)); +- _8 = Lt(_6, _7); +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; ++ _7 = const 3_usize; ++ _8 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = (*_2)[_6]; ++ _1 = const 2_u32; + StorageDead(_6); + StorageDead(_4); + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 9821d1b1e..e91724536 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+InstSimplify // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff b/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff deleted file mode 100644 index 664b7839f..000000000 --- a/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff +++ /dev/null @@ -1,34 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/switch_int.rs:+0:11: +0:11 - let mut _1: i32; // in scope 0 at $DIR/switch_int.rs:+1:11: +1:12 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/switch_int.rs:+1:11: +1:12 - _1 = const 1_i32; // scope 0 at $DIR/switch_int.rs:+1:11: +1:12 -- switchInt(_1) -> [1: bb2, otherwise: bb1]; // scope 0 at $DIR/switch_int.rs:+1:5: +1:12 -+ switchInt(const 1_i32) -> [1: bb2, otherwise: bb1]; // scope 0 at $DIR/switch_int.rs:+1:5: +1:12 - } - - bb1: { - _0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21 - // mir::Constant - // + span: $DIR/switch_int.rs:12:14: 12:17 - // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } - } - - bb2: { - _0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20 - // mir::Constant - // + span: $DIR/switch_int.rs:11:14: 11:17 - // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } - } - - bb3: { - StorageDead(_1); // scope 0 at $DIR/switch_int.rs:+5:1: +5:2 - return; // scope 0 at $DIR/switch_int.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..508cc1573 --- /dev/null +++ b/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-abort.diff @@ -0,0 +1,28 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let mut _1: i32; + + bb0: { + StorageLive(_1); + _1 = const 1_i32; +- switchInt(_1) -> [1: bb2, otherwise: bb1]; ++ switchInt(const 1_i32) -> [1: bb2, otherwise: bb1]; + } + + bb1: { + _0 = foo(const -1_i32) -> [return: bb3, unwind unreachable]; + } + + bb2: { + _0 = foo(const 0_i32) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..1ce28e979 --- /dev/null +++ b/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff @@ -0,0 +1,28 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let mut _1: i32; + + bb0: { + StorageLive(_1); + _1 = const 1_i32; +- switchInt(_1) -> [1: bb2, otherwise: bb1]; ++ switchInt(const 1_i32) -> [1: bb2, otherwise: bb1]; + } + + bb1: { + _0 = foo(const -1_i32) -> [return: bb3, unwind continue]; + } + + bb2: { + _0 = foo(const 0_i32) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff deleted file mode 100644 index ef2c4d5fa..000000000 --- a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff +++ /dev/null @@ -1,34 +0,0 @@ -- // MIR for `main` before SimplifyConstCondition-after-const-prop -+ // MIR for `main` after SimplifyConstCondition-after-const-prop - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/switch_int.rs:+0:11: +0:11 - let mut _1: i32; // in scope 0 at $DIR/switch_int.rs:+1:11: +1:12 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/switch_int.rs:+1:11: +1:12 - _1 = const 1_i32; // scope 0 at $DIR/switch_int.rs:+1:11: +1:12 -- switchInt(const 1_i32) -> [1: bb2, otherwise: bb1]; // scope 0 at $DIR/switch_int.rs:+1:5: +1:12 -+ goto -> bb2; // scope 0 at $DIR/switch_int.rs:+1:5: +1:12 - } - - bb1: { - _0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21 - // mir::Constant - // + span: $DIR/switch_int.rs:12:14: 12:17 - // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } - } - - bb2: { - _0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20 - // mir::Constant - // + span: $DIR/switch_int.rs:11:14: 11:17 - // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } - } - - bb3: { - StorageDead(_1); // scope 0 at $DIR/switch_int.rs:+5:1: +5:2 - return; // scope 0 at $DIR/switch_int.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-abort.diff b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-abort.diff new file mode 100644 index 000000000..ced5e500d --- /dev/null +++ b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-abort.diff @@ -0,0 +1,28 @@ +- // MIR for `main` before SimplifyConstCondition-after-const-prop ++ // MIR for `main` after SimplifyConstCondition-after-const-prop + + fn main() -> () { + let mut _0: (); + let mut _1: i32; + + bb0: { + StorageLive(_1); + _1 = const 1_i32; +- switchInt(const 1_i32) -> [1: bb2, otherwise: bb1]; ++ goto -> bb2; + } + + bb1: { + _0 = foo(const -1_i32) -> [return: bb3, unwind unreachable]; + } + + bb2: { + _0 = foo(const 0_i32) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff new file mode 100644 index 000000000..e598a0d3d --- /dev/null +++ b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff @@ -0,0 +1,28 @@ +- // MIR for `main` before SimplifyConstCondition-after-const-prop ++ // MIR for `main` after SimplifyConstCondition-after-const-prop + + fn main() -> () { + let mut _0: (); + let mut _1: i32; + + bb0: { + StorageLive(_1); + _1 = const 1_i32; +- switchInt(const 1_i32) -> [1: bb2, otherwise: bb1]; ++ goto -> bb2; + } + + bb1: { + _0 = foo(const -1_i32) -> [return: bb3, unwind continue]; + } + + bb2: { + _0 = foo(const 0_i32) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/switch_int.rs b/tests/mir-opt/const_prop/switch_int.rs index 7158ea4d2..bf708c829 100644 --- a/tests/mir-opt/const_prop/switch_int.rs +++ b/tests/mir-opt/const_prop/switch_int.rs @@ -1,6 +1,6 @@ // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+SimplifyConstCondition-after-const-prop -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #[inline(never)] fn foo(_: i32) { } diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff index 933dfbb51..febfebc85 100644 --- a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff @@ -2,14 +2,14 @@ + // MIR for `from_char` after ConstProp fn from_char() -> i32 { - let mut _0: i32; // return place in scope 0 at $DIR/transmute.rs:+0:23: +0:26 + let mut _0: i32; scope 1 { } bb0: { -- _0 = const 'R' as i32 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:28 -+ _0 = const 82_i32; // scope 1 at $DIR/transmute.rs:+1:14: +1:28 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 +- _0 = const 'R' as i32 (Transmute); ++ _0 = const 82_i32; + return; } } diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff index 933dfbb51..febfebc85 100644 --- a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff @@ -2,14 +2,14 @@ + // MIR for `from_char` after ConstProp fn from_char() -> i32 { - let mut _0: i32; // return place in scope 0 at $DIR/transmute.rs:+0:23: +0:26 + let mut _0: i32; scope 1 { } bb0: { -- _0 = const 'R' as i32 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:28 -+ _0 = const 82_i32; // scope 1 at $DIR/transmute.rs:+1:14: +1:28 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 +- _0 = const 'R' as i32 (Transmute); ++ _0 = const 82_i32; + return; } } diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff index 4a31194de..38a1eb5a1 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff @@ -2,14 +2,14 @@ + // MIR for `invalid_bool` after ConstProp fn invalid_bool() -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37 + let mut _0: bool; scope 1 { } bb0: { -- _0 = const -1_i8 as bool (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:30 -+ _0 = const {transmute(0xff): bool}; // scope 1 at $DIR/transmute.rs:+1:14: +1:30 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 +- _0 = const -1_i8 as bool (Transmute); ++ _0 = const {transmute(0xff): bool}; + return; } } diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff index 4a31194de..38a1eb5a1 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff @@ -2,14 +2,14 @@ + // MIR for `invalid_bool` after ConstProp fn invalid_bool() -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37 + let mut _0: bool; scope 1 { } bb0: { -- _0 = const -1_i8 as bool (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:30 -+ _0 = const {transmute(0xff): bool}; // scope 1 at $DIR/transmute.rs:+1:14: +1:30 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 +- _0 = const -1_i8 as bool (Transmute); ++ _0 = const {transmute(0xff): bool}; + return; } } diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff index 2c541f2f6..2c0998f77 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff @@ -2,14 +2,14 @@ + // MIR for `invalid_char` after ConstProp fn invalid_char() -> char { - let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37 + let mut _0: char; scope 1 { } bb0: { -- _0 = const _ as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 -+ _0 = const {transmute(0x7fffffff): char}; // scope 1 at $DIR/transmute.rs:+1:14: +1:33 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 +- _0 = const _ as char (Transmute); ++ _0 = const {transmute(0x7fffffff): char}; + return; } } diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff index 2c541f2f6..2c0998f77 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff @@ -2,14 +2,14 @@ + // MIR for `invalid_char` after ConstProp fn invalid_char() -> char { - let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37 + let mut _0: char; scope 1 { } bb0: { -- _0 = const _ as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 -+ _0 = const {transmute(0x7fffffff): char}; // scope 1 at $DIR/transmute.rs:+1:14: +1:33 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 +- _0 = const _ as char (Transmute); ++ _0 = const {transmute(0x7fffffff): char}; + return; } } diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff index 76d464789..7ac7bed8a 100644 --- a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff @@ -2,22 +2,19 @@ + // MIR for `less_as_i8` after ConstProp fn less_as_i8() -> i8 { - let mut _0: i8; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:26 - let mut _1: std::cmp::Ordering; // in scope 0 at $DIR/transmute.rs:+1:24: +1:48 + let mut _0: i8; + let mut _1: std::cmp::Ordering; scope 1 { } bb0: { - StorageLive(_1); // scope 1 at $DIR/transmute.rs:+1:24: +1:48 -- _1 = Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48 -- _0 = move _1 as i8 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:49 -+ _1 = const Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: std::cmp::Ordering, val: Value(Scalar(0xff)) } -+ _0 = const -1_i8; // scope 1 at $DIR/transmute.rs:+1:14: +1:49 - StorageDead(_1); // scope 1 at $DIR/transmute.rs:+1:48: +1:49 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + StorageLive(_1); +- _1 = Less; +- _0 = move _1 as i8 (Transmute); ++ _1 = const Less; ++ _0 = const -1_i8; + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff index 76d464789..7ac7bed8a 100644 --- a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff @@ -2,22 +2,19 @@ + // MIR for `less_as_i8` after ConstProp fn less_as_i8() -> i8 { - let mut _0: i8; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:26 - let mut _1: std::cmp::Ordering; // in scope 0 at $DIR/transmute.rs:+1:24: +1:48 + let mut _0: i8; + let mut _1: std::cmp::Ordering; scope 1 { } bb0: { - StorageLive(_1); // scope 1 at $DIR/transmute.rs:+1:24: +1:48 -- _1 = Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48 -- _0 = move _1 as i8 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:49 -+ _1 = const Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: std::cmp::Ordering, val: Value(Scalar(0xff)) } -+ _0 = const -1_i8; // scope 1 at $DIR/transmute.rs:+1:14: +1:49 - StorageDead(_1); // scope 1 at $DIR/transmute.rs:+1:48: +1:49 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + StorageLive(_1); +- _1 = Less; +- _0 = move _1 as i8 (Transmute); ++ _1 = const Less; ++ _0 = const -1_i8; + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff index 538b1f26e..afedf2a30 100644 --- a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff @@ -2,21 +2,21 @@ + // MIR for `undef_union_as_integer` after ConstProp fn undef_union_as_integer() -> u32 { - let mut _0: u32; // return place in scope 0 at $DIR/transmute.rs:+0:43: +0:46 - let mut _1: undef_union_as_integer::Union32; // in scope 0 at $DIR/transmute.rs:+2:24: +2:44 - let mut _2: (); // in scope 0 at $DIR/transmute.rs:+2:40: +2:42 + let mut _0: u32; + let mut _1: undef_union_as_integer::Union32; + let mut _2: (); scope 1 { } bb0: { - StorageLive(_1); // scope 1 at $DIR/transmute.rs:+2:24: +2:44 - StorageLive(_2); // scope 1 at $DIR/transmute.rs:+2:40: +2:42 - _2 = (); // scope 1 at $DIR/transmute.rs:+2:40: +2:42 - _1 = Union32 { value: move _2 }; // scope 1 at $DIR/transmute.rs:+2:24: +2:44 - StorageDead(_2); // scope 1 at $DIR/transmute.rs:+2:43: +2:44 - _0 = move _1 as u32 (Transmute); // scope 1 at $DIR/transmute.rs:+2:14: +2:45 - StorageDead(_1); // scope 1 at $DIR/transmute.rs:+2:44: +2:45 - return; // scope 0 at $DIR/transmute.rs:+3:2: +3:2 + StorageLive(_1); + StorageLive(_2); + _2 = (); + _1 = Union32 { value: move _2 }; + StorageDead(_2); + _0 = move _1 as u32 (Transmute); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff index 538b1f26e..afedf2a30 100644 --- a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff @@ -2,21 +2,21 @@ + // MIR for `undef_union_as_integer` after ConstProp fn undef_union_as_integer() -> u32 { - let mut _0: u32; // return place in scope 0 at $DIR/transmute.rs:+0:43: +0:46 - let mut _1: undef_union_as_integer::Union32; // in scope 0 at $DIR/transmute.rs:+2:24: +2:44 - let mut _2: (); // in scope 0 at $DIR/transmute.rs:+2:40: +2:42 + let mut _0: u32; + let mut _1: undef_union_as_integer::Union32; + let mut _2: (); scope 1 { } bb0: { - StorageLive(_1); // scope 1 at $DIR/transmute.rs:+2:24: +2:44 - StorageLive(_2); // scope 1 at $DIR/transmute.rs:+2:40: +2:42 - _2 = (); // scope 1 at $DIR/transmute.rs:+2:40: +2:42 - _1 = Union32 { value: move _2 }; // scope 1 at $DIR/transmute.rs:+2:24: +2:44 - StorageDead(_2); // scope 1 at $DIR/transmute.rs:+2:43: +2:44 - _0 = move _1 as u32 (Transmute); // scope 1 at $DIR/transmute.rs:+2:14: +2:45 - StorageDead(_1); // scope 1 at $DIR/transmute.rs:+2:44: +2:45 - return; // scope 0 at $DIR/transmute.rs:+3:2: +3:2 + StorageLive(_1); + StorageLive(_2); + _2 = (); + _1 = Union32 { value: move _2 }; + StorageDead(_2); + _0 = move _1 as u32 (Transmute); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff index 5258d75bd..100982382 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff @@ -2,22 +2,19 @@ + // MIR for `unreachable_box` after ConstProp fn unreachable_box() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let _1: std::boxed::Box<Never>; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _0: !; + let _1: std::boxed::Box<Never>; scope 1 { - debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 -- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: Box<Never>, val: Value(Scalar(0x00000001)) } - unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + StorageLive(_1); +- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); ++ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); + unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff index 7e57e06a5..100982382 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff @@ -2,22 +2,19 @@ + // MIR for `unreachable_box` after ConstProp fn unreachable_box() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let _1: std::boxed::Box<Never>; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _0: !; + let _1: std::boxed::Box<Never>; scope 1 { - debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 -- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: Box<Never>, val: Value(Scalar(0x0000000000000001)) } - unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + StorageLive(_1); +- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); ++ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); + unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff index 032681f23..896608e7e 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff @@ -2,21 +2,21 @@ + // MIR for `unreachable_direct` after ConstProp fn unreachable_direct() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:39: +0:40 - let _1: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _2: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 + let mut _0: !; + let _1: Never; + let mut _2: (); scope 1 { - debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_2); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _2 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _1 = move _2 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 - unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + StorageLive(_1); + StorageLive(_2); + _2 = (); + _1 = move _2 as Never (Transmute); + unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff index 032681f23..896608e7e 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff @@ -2,21 +2,21 @@ + // MIR for `unreachable_direct` after ConstProp fn unreachable_direct() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:39: +0:40 - let _1: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _2: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 + let mut _0: !; + let _1: Never; + let mut _2: (); scope 1 { - debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_2); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _2 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _1 = move _2 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 - unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + StorageLive(_1); + StorageLive(_2); + _2 = (); + _1 = move _2 as Never (Transmute); + unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff index ec8a62bd6..c9d5ccf0b 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff @@ -2,26 +2,23 @@ + // MIR for `unreachable_mut` after ConstProp fn unreachable_mut() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let _1: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 + let mut _0: !; + let _1: &mut Never; + let mut _2: &mut Never; scope 1 { - debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 -- _2 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ _2 = const {0x1 as &mut Never}; // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: &mut Never, val: Value(Scalar(0x00000001)) } - _1 = &mut (*_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 - StorageDead(_2); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 - unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + StorageLive(_1); + StorageLive(_2); +- _2 = const 1_usize as &mut Never (Transmute); ++ _2 = const {0x1 as &mut Never}; + _1 = &mut (*_2); + StorageDead(_2); + unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff index 288da6e56..c9d5ccf0b 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff @@ -2,26 +2,23 @@ + // MIR for `unreachable_mut` after ConstProp fn unreachable_mut() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let _1: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 + let mut _0: !; + let _1: &mut Never; + let mut _2: &mut Never; scope 1 { - debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 -- _2 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ _2 = const {0x1 as &mut Never}; // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: &mut Never, val: Value(Scalar(0x0000000000000001)) } - _1 = &mut (*_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 - StorageDead(_2); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 - unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + StorageLive(_1); + StorageLive(_2); +- _2 = const 1_usize as &mut Never (Transmute); ++ _2 = const {0x1 as &mut Never}; + _1 = &mut (*_2); + StorageDead(_2); + unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff index dcca0fca6..b684ba34c 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff @@ -2,22 +2,19 @@ + // MIR for `unreachable_ref` after ConstProp fn unreachable_ref() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let _1: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _0: !; + let _1: &Never; scope 1 { - debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 -- _1 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 -+ _1 = const {0x1 as &Never}; // scope 2 at $DIR/transmute.rs:+1:30: +1:48 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: &Never, val: Value(Scalar(0x00000001)) } - unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + StorageLive(_1); +- _1 = const 1_usize as &Never (Transmute); ++ _1 = const {0x1 as &Never}; + unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff index 3a0b967e6..b684ba34c 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff @@ -2,22 +2,19 @@ + // MIR for `unreachable_ref` after ConstProp fn unreachable_ref() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let _1: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _0: !; + let _1: &Never; scope 1 { - debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 -- _1 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 -+ _1 = const {0x1 as &Never}; // scope 2 at $DIR/transmute.rs:+1:30: +1:48 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: &Never, val: Value(Scalar(0x0000000000000001)) } - unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + StorageLive(_1); +- _1 = const 1_usize as &Never (Transmute); ++ _1 = const {0x1 as &Never}; + unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff index eac33b730..f215b3ca3 100644 --- a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff @@ -2,14 +2,14 @@ + // MIR for `valid_char` after ConstProp fn valid_char() -> char { - let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:28 + let mut _0: char; scope 1 { } bb0: { -- _0 = const 82_u32 as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 -+ _0 = const 'R'; // scope 1 at $DIR/transmute.rs:+1:14: +1:33 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 +- _0 = const 82_u32 as char (Transmute); ++ _0 = const 'R'; + return; } } diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff index eac33b730..f215b3ca3 100644 --- a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff @@ -2,14 +2,14 @@ + // MIR for `valid_char` after ConstProp fn valid_char() -> char { - let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:28 + let mut _0: char; scope 1 { } bb0: { -- _0 = const 82_u32 as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 -+ _0 = const 'R'; // scope 1 at $DIR/transmute.rs:+1:14: +1:33 - return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 +- _0 = const 82_u32 as char (Transmute); ++ _0 = const 'R'; + return; } } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff deleted file mode 100644 index e4a7c0d1e..000000000 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff +++ /dev/null @@ -1,35 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/tuple_literal_propagation.rs:+0:11: +0:11 - let _1: (u32, u32); // in scope 0 at $DIR/tuple_literal_propagation.rs:+1:9: +1:10 - let _2: (); // in scope 0 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 - let mut _3: (u32, u32); // in scope 0 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 - scope 1 { - debug x => _1; // in scope 1 at $DIR/tuple_literal_propagation.rs:+1:9: +1:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:9: +1:10 -- _1 = (const 1_u32, const 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 -+ _1 = const (1_u32, 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 - StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 - StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 -- _3 = _1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 -+ _3 = const (1_u32, 2_u32); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 - _2 = consume(move _3) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 - // mir::Constant - // + span: $DIR/tuple_literal_propagation.rs:7:5: 7:12 - // + literal: Const { ty: fn((u32, u32)) {consume}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:14: +3:15 - StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:15: +3:16 - _0 = const (); // scope 0 at $DIR/tuple_literal_propagation.rs:+0:11: +4:2 - StorageDead(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+4:1: +4:2 - return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2 - } - } - diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..a72f24152 --- /dev/null +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff @@ -0,0 +1,32 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: (u32, u32); + let _2: (); + let mut _3: (u32, u32); + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); +- _1 = (const 1_u32, const 2_u32); ++ _1 = const (1_u32, 2_u32); + StorageLive(_2); + StorageLive(_3); +- _3 = _1; ++ _3 = const (1_u32, 2_u32); + _2 = consume(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..6255f9ec5 --- /dev/null +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff @@ -0,0 +1,32 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: (u32, u32); + let _2: (); + let mut _3: (u32, u32); + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); +- _1 = (const 1_u32, const 2_u32); ++ _1 = const (1_u32, 2_u32); + StorageLive(_2); + StorageLive(_3); +- _3 = _1; ++ _3 = const (1_u32, 2_u32); + _2 = consume(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs index f342ae270..5890a343f 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs @@ -1,5 +1,5 @@ // unit-test: ConstProp -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR tuple_literal_propagation.main.ConstProp.diff fn main() { let x = (1, 2); diff --git a/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff b/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff index 377324218..f54908b4a 100644 --- a/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff +++ b/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff @@ -2,53 +2,53 @@ + // MIR for `change_loop_body` after ConstProp fn change_loop_body() -> () { - let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:+0:27: +0:27 - let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 - let mut _2: (); // in scope 0 at $DIR/while_let_loops.rs:+0:1: +6:2 - let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:+2:28: +2:32 - let mut _4: isize; // in scope 0 at $DIR/while_let_loops.rs:+2:15: +2:25 - let mut _5: !; // in scope 0 at $DIR/while_let_loops.rs:+2:33: +5:6 - let mut _6: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6 - let _7: (); // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6 - let mut _8: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6 + let mut _0: (); + let mut _1: i32; + let mut _2: (); + let mut _3: std::option::Option<u32>; + let mut _4: isize; + let mut _5: !; + let mut _6: !; + let _7: (); + let mut _8: !; scope 1 { - debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:+1:9: +1:15 + debug _x => _1; scope 2 { } } bb0: { - StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 - _1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:+1:18: +1:19 - StorageLive(_3); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 - _3 = Option::<u32>::None; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 -- _4 = discriminant(_3); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 -- switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 -+ _4 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 -+ switchInt(const 0_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + StorageLive(_1); + _1 = const 0_i32; + StorageLive(_3); + _3 = Option::<u32>::None; +- _4 = discriminant(_3); +- switchInt(move _4) -> [1: bb1, otherwise: bb3]; ++ _4 = const 0_isize; ++ switchInt(const 0_isize) -> [1: bb1, otherwise: bb3]; } bb1: { - switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; } bb2: { - _1 = const 1_i32; // scope 2 at $DIR/while_let_loops.rs:+3:9: +3:15 - _0 = const (); // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14 - goto -> bb4; // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14 + _1 = const 1_i32; + _0 = const (); + goto -> bb4; } bb3: { - StorageLive(_7); // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6 - _0 = const (); // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6 - StorageDead(_7); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 - goto -> bb4; // scope 1 at no-location + StorageLive(_7); + _0 = const (); + StorageDead(_7); + goto -> bb4; } bb4: { - StorageDead(_3); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 - StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:+6:1: +6:2 - return; // scope 0 at $DIR/while_let_loops.rs:+6:2: +6:2 + StorageDead(_3); + StorageDead(_1); + return; } } |