diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
commit | 631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch) | |
tree | a1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/mir-opt/const_prop | |
parent | Adding debian version 1.69.0+dfsg1-1. (diff) | |
download | rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/const_prop')
58 files changed, 429 insertions, 82 deletions
diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff index f6e58955b..041197266 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff @@ -29,7 +29,7 @@ + _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:8:5: 8:8 + // + span: $DIR/aggregate.rs:9:5: 9:8 // + literal: Const { ty: fn(u8) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir index 4706af92c..05d4bf8b5 100644 --- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir +++ b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir @@ -25,7 +25,7 @@ fn main() -> () { _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:8:5: 8:8 + // + span: $DIR/aggregate.rs:9:5: 9:8 // + literal: Const { ty: fn(u8) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs index aa123b7a8..ed5a4ab59 100644 --- a/tests/mir-opt/const_prop/aggregate.rs +++ b/tests/mir-opt/const_prop/aggregate.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -O diff --git a/tests/mir-opt/const_prop/array_index.rs b/tests/mir-opt/const_prop/array_index.rs index d31c2827b..f36cf2213 100644 --- a/tests/mir-opt/const_prop/array_index.rs +++ b/tests/mir-opt/const_prop/array_index.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // EMIT_MIR_FOR_EACH_BIT_WIDTH 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 a6fd325ec..38f1a993d 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,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index ae9ffd519..bedfa5992 100644 --- 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 @@ -27,17 +27,19 @@ } bb1: { - _5 = Eq(_1, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 +- _5 = Eq(_1, 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, _1) -> 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, _1) -> bb2; // 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, const 0_i32) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 } bb2: { - _2 = Rem(const 1_i32, _1); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 +- _2 = Rem(const 1_i32, _1); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 ++ _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 StorageDead(_2); // scope 1 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.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs index cc16a4a5a..a1078472c 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,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index 38d402b8f..e711babf0 100644 --- 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 @@ -25,7 +25,7 @@ StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _8 = 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:5:25: 5:35 + // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _2 = &raw const (*_8); // 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 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 index 38d402b8f..e711babf0 100644 --- 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 @@ -25,7 +25,7 @@ StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _8 = 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:5:25: 5:35 + // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _2 = &raw const (*_8); // 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 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 cf22b06d5..3d252f2d2 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,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff #[allow(unconditional_panic)] diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.diff b/tests/mir-opt/const_prop/boxes.main.ConstProp.diff index 5ec421eb2..b0e86e753 100644 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/boxes.main.ConstProp.diff @@ -4,14 +4,14 @@ 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: +1:22 - let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _4: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _5: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _6: *mut u8; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _8: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _9: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 + 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 } @@ -20,41 +20,41 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/boxes.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/boxes.rs:+1:13: +1:22 - StorageLive(_3); // scope 0 at $DIR/boxes.rs:+1:14: +1:22 -- _4 = SizeOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22 -- _5 = AlignOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22 -+ _4 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +1:22 -+ _5 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +1:22 - _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +1:22 + 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: 13:22 + // + 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: +1:22 - _7 = ShallowInitBox(move _6, i32); // scope 0 at $DIR/boxes.rs:+1:14: +1:22 - _8 = (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+1:19: +1:21 - (*_8) = const 42_i32; // scope 0 at $DIR/boxes.rs:+1:19: +1:21 - _3 = move _7; // scope 0 at $DIR/boxes.rs:+1:14: +1:22 - StorageDead(_7); // scope 0 at $DIR/boxes.rs:+1:21: +1:22 - _9 = (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+1:13: +1:22 - _2 = (*_9); // scope 0 at $DIR/boxes.rs:+1:13: +1:22 - _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/boxes.rs:+1:13: +1:26 - StorageDead(_2); // scope 0 at $DIR/boxes.rs:+1:25: +1:26 - drop(_3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/boxes.rs:+1:26: +1:27 + 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:+1:26: +1:27 - _0 = const (); // scope 0 at $DIR/boxes.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/boxes.rs:+2:1: +2:2 - return; // scope 0 at $DIR/boxes.rs:+2:2: +2:2 + 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: +2:2 + resume; // scope 0 at $DIR/boxes.rs:+0:1: +4:2 } } diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs index d287830db..66e8c24d4 100644 --- a/tests/mir-opt/const_prop/boxes.rs +++ b/tests/mir-opt/const_prop/boxes.rs @@ -4,11 +4,13 @@ // ignore-wasm32 // ignore-wasm64 -#![feature(box_syntax)] +#![feature(rustc_attrs, stmt_expr_attributes)] -// Note: this test verifies that we, in fact, do not const prop `box` +// Note: this test verifies that we, in fact, do not const prop `#[rustc_box]` // EMIT_MIR boxes.main.ConstProp.diff fn main() { - let x = *(box 42) + 0; + let x = *(#[rustc_box] + Box::new(42)) + + 0; } diff --git a/tests/mir-opt/const_prop/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs index b9860da4c..007defd10 100644 --- a/tests/mir-opt/const_prop/checked_add.rs +++ b/tests/mir-opt/const_prop/checked_add.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index bea7114c7..d75fae30b 100644 --- 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 @@ -18,7 +18,7 @@ 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:8:13: 8:16 + // + 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 @@ -29,7 +29,7 @@ _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:9:5: 9:9 + // + span: $DIR/const_prop_fails_gracefully.rs:10:5: 10:9 // + literal: Const { ty: fn(usize) {read}, val: Value(<ZST>) } } 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 0a3dcbd38..44d487842 100644 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs +++ b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index f270ab8b6..7e77c18d5 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff @@ -14,7 +14,6 @@ } bb1: { - StorageLive(_2); // scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL _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 diff --git a/tests/mir-opt/const_prop/control_flow_simplification.rs b/tests/mir-opt/const_prop/control_flow_simplification.rs index 7dbe8e734..b2ca045e8 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.rs +++ b/tests/mir-opt/const_prop/control_flow_simplification.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 b9a10704b..6d8738aa6 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff @@ -22,7 +22,7 @@ - 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: $DIR/discriminant.rs:12:34: 12:44 ++ // + 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 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 b9a10704b..6d8738aa6 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff @@ -22,7 +22,7 @@ - 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: $DIR/discriminant.rs:12:34: 12:44 ++ // + 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 diff --git a/tests/mir-opt/const_prop/indirect.rs b/tests/mir-opt/const_prop/indirect.rs index 44916cbfe..46fd8082d 100644 --- a/tests/mir-opt/const_prop/indirect.rs +++ b/tests/mir-opt/const_prop/indirect.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index d03c23a3f..0ac7fa43d 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff @@ -8,7 +8,7 @@ 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:8:13: 8:47 + 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 diff --git a/tests/mir-opt/const_prop/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs index 541a8c5c3..4e905d00d 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.rs +++ b/tests/mir-opt/const_prop/inherit_overflow.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 4f056dd85..85dedf68c 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff @@ -12,12 +12,10 @@ let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 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 scope 5 { - debug _enum_without_variants => _6; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 - let _7: main::Str<"���">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 + debug _enum_without_variants => const [ZeroSized: Empty]; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 scope 7 { - debug _non_utf8_str => _7; // 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 } } scope 6 { @@ -44,18 +42,14 @@ - _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 + _4 = const Scalar(0x00000004): E; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 + // mir::Constant -+ // + span: $DIR/invalid_constant.rs:28:34: 28:57 ++ // + span: no-location + // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) } + _3 = [const Scalar(0x00000004): E]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 + // mir::Constant -+ // + span: $DIR/invalid_constant.rs:28:24: 28:60 ++ // + span: no-location + // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) } 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 5 at $DIR/invalid_constant.rs:+24:9: +24:22 - StorageDead(_7); // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 - StorageDead(_6); // 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 diff --git a/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff new file mode 100644 index 000000000..e31c2bc39 --- /dev/null +++ b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff @@ -0,0 +1,76 @@ +- // MIR for `main` before RemoveZsts ++ // 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 + 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 + 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 + 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 + 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 + } + } + scope 6 { + } + } + scope 4 { + } + } + scope 2 { + } + + 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 + } + } + diff --git a/tests/mir-opt/const_prop/invalid_constant.rs b/tests/mir-opt/const_prop/invalid_constant.rs index 0337a7ca8..eb6172cdf 100644 --- a/tests/mir-opt/const_prop/invalid_constant.rs +++ b/tests/mir-opt/const_prop/invalid_constant.rs @@ -11,6 +11,7 @@ enum E { A, B, C } #[derive(Copy, Clone)] enum Empty {} +// EMIT_MIR invalid_constant.main.RemoveZsts.diff // EMIT_MIR invalid_constant.main.ConstProp.diff fn main() { // An invalid char. diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff index 964dd3080..265269409 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff @@ -5,23 +5,18 @@ 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 - let mut _3: (); // in scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 StorageLive(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - StorageLive(_3); // scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 - _2 = (move _3, const 0_u8, const 0_u8); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - StorageDead(_3); // scope 0 at $DIR/issue_66971.rs:+1:21: +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:17:5: 17:11 + // + 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 - StorageDead(_1); // scope 0 at $DIR/issue_66971.rs:+1:23: +1:24 return; // scope 0 at $DIR/issue_66971.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/issue_66971.rs b/tests/mir-opt/const_prop/issue_66971.rs index 6ca03438e..af95c9ca2 100644 --- a/tests/mir-opt/const_prop/issue_66971.rs +++ b/tests/mir-opt/const_prop/issue_66971.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index a631cb310..54c9200d6 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff @@ -8,7 +8,6 @@ let mut _3: (u8, u8); // in scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_67019.rs:+1:5: +1:20 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 @@ -17,13 +16,12 @@ 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:12:5: 12:9 + // + 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 - StorageDead(_1); // scope 0 at $DIR/issue_67019.rs:+1:20: +1:21 return; // scope 0 at $DIR/issue_67019.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/issue_67019.rs b/tests/mir-opt/const_prop/issue_67019.rs index ffc6fa1f2..08c7d4805 100644 --- a/tests/mir-opt/const_prop/issue_67019.rs +++ b/tests/mir-opt/const_prop/issue_67019.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -Z mir-opt-level=3 diff --git a/tests/mir-opt/const_prop/large_array_index.rs b/tests/mir-opt/const_prop/large_array_index.rs index 48d134376..073f98495 100644 --- a/tests/mir-opt/const_prop/large_array_index.rs +++ b/tests/mir-opt/const_prop/large_array_index.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR large_array_index.main.ConstProp.diff 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 index 149aa6290..75f6ebc58 100644 --- 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 @@ -16,7 +16,7 @@ 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 + // + span: $DIR/mutable_variable_aggregate_partial_read.rs:7:29: 7:32 // + literal: Const { ty: fn() -> (i32, i32) {foo}, val: Value(<ZST>) } } 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 cb59509ff..70a287cf3 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,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test // compile-flags: -O 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 index 4010dd6c6..9582504b2 100644 --- 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 @@ -26,7 +26,7 @@ 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 + // + span: $DIR/mutable_variable_unprop_assign.rs:7:13: 7:16 // + literal: Const { ty: fn() -> i32 {foo}, val: Value(<ZST>) } } 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 b077cfd3e..fabd04e9b 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test // compile-flags: -O diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.rs b/tests/mir-opt/const_prop/optimizes_into_variable.rs index abea07e20..5ffa15347 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.rs +++ b/tests/mir-opt/const_prop/optimizes_into_variable.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs index 36d9b9fc6..2f3b7d2c5 100644 --- a/tests/mir-opt/const_prop/repeat.rs +++ b/tests/mir-opt/const_prop/repeat.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // compile-flags: -O // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/return_place.rs b/tests/mir-opt/const_prop/return_place.rs index 06a853696..ae119df85 100644 --- a/tests/mir-opt/const_prop/return_place.rs +++ b/tests/mir-opt/const_prop/return_place.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index 22f710387..a091b4ace 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff @@ -12,16 +12,14 @@ bb0: { _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 - _2 = consume(_1) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 + _2 = consume(const 1_u32) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 // mir::Constant - // + span: $DIR/scalar_literal_propagation.rs:4:5: 4:12 + // + span: $DIR/scalar_literal_propagation.rs:5:5: 5:12 // + literal: Const { ty: fn(u32) {consume}, val: Value(<ZST>) } } bb1: { - StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:15: +2:16 return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2 } } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.rs b/tests/mir-opt/const_prop/scalar_literal_propagation.rs index 8724e4d57..e13e352f8 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index b99b83b0c..8bd2b48d6 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff @@ -20,7 +20,7 @@ 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:7:6: 7:19 + // + 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 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 index b99b83b0c..8bd2b48d6 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff @@ -20,7 +20,7 @@ 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:7:6: 7:19 + // + 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 diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 8183def0c..4499c54f2 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+InstCombine // 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 index ddc1a4493..85704c48a 100644 --- a/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff @@ -15,14 +15,14 @@ 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:9:14: 9:17 + // + span: $DIR/switch_int.rs:10:14: 10: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:8:14: 8:17 + // + span: $DIR/switch_int.rs:9:14: 9:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } 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 index 09c47ee6e..0864db225 100644 --- 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 @@ -15,14 +15,14 @@ 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:9:14: 9:17 + // + span: $DIR/switch_int.rs:10:14: 10: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:8:14: 8:17 + // + span: $DIR/switch_int.rs:9:14: 9:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/switch_int.rs b/tests/mir-opt/const_prop/switch_int.rs index d7319eca1..2a2322e43 100644 --- a/tests/mir-opt/const_prop/switch_int.rs +++ b/tests/mir-opt/const_prop/switch_int.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default #[inline(never)] fn foo(_: i32) { } diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.diff b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.diff new file mode 100644 index 000000000..933dfbb51 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.diff @@ -0,0 +1,15 @@ +- // MIR for `from_char` before ConstProp ++ // 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 + 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 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.diff new file mode 100644 index 000000000..f3474855f --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.diff @@ -0,0 +1,14 @@ +- // MIR for `invalid_bool` before ConstProp ++ // 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 + scope 1 { + } + + bb0: { + _0 = const -1_i8 as bool (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:30 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.diff b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.diff new file mode 100644 index 000000000..ba087e226 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.diff @@ -0,0 +1,14 @@ +- // MIR for `invalid_char` before ConstProp ++ // 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 + scope 1 { + } + + bb0: { + _0 = const _ as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.diff new file mode 100644 index 000000000..76d464789 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.diff @@ -0,0 +1,23 @@ +- // MIR for `less_as_i8` before ConstProp ++ // 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 + 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 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.rs b/tests/mir-opt/const_prop/transmute.rs new file mode 100644 index 000000000..b753cdccd --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.rs @@ -0,0 +1,61 @@ +// unit-test: ConstProp +// compile-flags: -O --crate-type=lib + +use std::mem::transmute; + +// EMIT_MIR transmute.less_as_i8.ConstProp.diff +pub fn less_as_i8() -> i8 { + unsafe { transmute(std::cmp::Ordering::Less) } +} + +// EMIT_MIR transmute.from_char.ConstProp.diff +pub fn from_char() -> i32 { + unsafe { transmute('R') } +} + +// EMIT_MIR transmute.valid_char.ConstProp.diff +pub fn valid_char() -> char { + unsafe { transmute(0x52_u32) } +} + +// EMIT_MIR transmute.invalid_char.ConstProp.diff +pub unsafe fn invalid_char() -> char { + unsafe { transmute(i32::MAX) } +} + +// EMIT_MIR transmute.invalid_bool.ConstProp.diff +pub unsafe fn invalid_bool() -> bool { + unsafe { transmute(-1_i8) } +} + +// EMIT_MIR transmute.undef_union_as_integer.ConstProp.diff +pub unsafe fn undef_union_as_integer() -> u32 { + union Union32 { value: u32, unit: () } + unsafe { transmute(Union32 { unit: () }) } +} + +// EMIT_MIR transmute.unreachable_direct.ConstProp.diff +pub unsafe fn unreachable_direct() -> ! { + let x: Never = unsafe { transmute(()) }; + match x {} +} + +// EMIT_MIR transmute.unreachable_ref.ConstProp.diff +pub unsafe fn unreachable_ref() -> ! { + let x: &Never = unsafe { transmute(1_usize) }; + match *x {} +} + +// EMIT_MIR transmute.unreachable_mut.ConstProp.diff +pub unsafe fn unreachable_mut() -> ! { + let x: &mut Never = unsafe { transmute(1_usize) }; + match *x {} +} + +// EMIT_MIR transmute.unreachable_box.ConstProp.diff +pub unsafe fn unreachable_box() -> ! { + let x: Box<Never> = unsafe { transmute(1_usize) }; + match *x {} +} + +enum Never {} diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.diff new file mode 100644 index 000000000..538b1f26e --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.diff @@ -0,0 +1,22 @@ +- // MIR for `undef_union_as_integer` before ConstProp ++ // 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 + 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 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.diff new file mode 100644 index 000000000..8bf97996a --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.diff @@ -0,0 +1,23 @@ +- // MIR for `unreachable_box` before ConstProp ++ // 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 mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 + let _2: std::boxed::Box<Never>; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + scope 1 { + debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + _2 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.diff new file mode 100644 index 000000000..81b7b3689 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.diff @@ -0,0 +1,25 @@ +- // MIR for `unreachable_direct` before ConstProp ++ // 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 mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:41: +3:2 + let _2: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _3: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 + let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:15 + scope 1 { + debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:41: +3:2 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_3); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _3 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _2 = move _3 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.diff new file mode 100644 index 000000000..34f7aea8e --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.diff @@ -0,0 +1,27 @@ +- // MIR for `unreachable_mut` before ConstProp ++ // 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 mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 + let _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _3: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 + let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + scope 1 { + debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 + _3 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + _2 = &mut (*_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 + StorageDead(_3); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 + StorageLive(_4); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.diff new file mode 100644 index 000000000..ff95f2a0b --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.diff @@ -0,0 +1,23 @@ +- // MIR for `unreachable_ref` before ConstProp ++ // 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 mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 + let _2: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + scope 1 { + debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + _2 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 + StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.diff b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.diff new file mode 100644 index 000000000..eac33b730 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.diff @@ -0,0 +1,15 @@ +- // MIR for `valid_char` before ConstProp ++ // 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 + 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 + } + } + 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 index 270a1ccf5..12313b6c5 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff @@ -13,15 +13,13 @@ bb0: { - _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 _2 = consume(_1) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 // mir::Constant - // + span: $DIR/tuple_literal_propagation.rs:5:5: 5:12 + // + span: $DIR/tuple_literal_propagation.rs:6:5: 6:12 // + literal: Const { ty: fn((u32, u32)) {consume}, val: Value(<ZST>) } } bb1: { - StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:15: +3:16 return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs index e644baec4..edd748d00 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // EMIT_MIR tuple_literal_propagation.main.ConstProp.diff fn main() { let x = (1, 2); |