summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/const_prop
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/const_prop')
-rw-r--r--tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff58
-rw-r--r--tests/mir-opt/const_prop/address_of_pair.rs14
-rw-r--r--tests/mir-opt/const_prop/aggregate.foo.ConstProp.diff55
-rw-r--r--tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-abort.diff55
-rw-r--r--tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-unwind.diff55
-rw-r--r--tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.mir49
-rw-r--r--tests/mir-opt/const_prop/aggregate.main.ConstProp.diff44
-rw-r--r--tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff42
-rw-r--r--tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff42
-rw-r--r--tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir39
-rw-r--r--tests/mir-opt/const_prop/aggregate.rs19
-rw-r--r--tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff39
-rw-r--r--tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff39
-rw-r--r--tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff39
-rw-r--r--tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff39
-rw-r--r--tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff39
-rw-r--r--tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff39
-rw-r--r--tests/mir-opt/const_prop/array_index.rs5
-rw-r--r--tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff53
-rw-r--r--tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff54
-rw-r--r--tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff54
-rw-r--r--tests/mir-opt/const_prop/bad_op_div_by_zero.rs9
-rw-r--r--tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff53
-rw-r--r--tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff54
-rw-r--r--tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff54
-rw-r--r--tests/mir-opt/const_prop/bad_op_mod_by_zero.rs10
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff57
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff54
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff54
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff57
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff54
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff54
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs9
-rw-r--r--tests/mir-opt/const_prop/boolean_identities.rs11
-rw-r--r--tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff58
-rw-r--r--tests/mir-opt/const_prop/boxes.main.ConstProp.diff60
-rw-r--r--tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff54
-rw-r--r--tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff58
-rw-r--r--tests/mir-opt/const_prop/boxes.rs9
-rw-r--r--tests/mir-opt/const_prop/cast.main.ConstProp.diff30
-rw-r--r--tests/mir-opt/const_prop/cast.rs6
-rw-r--r--tests/mir-opt/const_prop/checked_add.main.ConstProp.diff28
-rw-r--r--tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff32
-rw-r--r--tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff32
-rw-r--r--tests/mir-opt/const_prop/checked_add.rs6
-rw-r--r--tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff44
-rw-r--r--tests/mir-opt/const_prop/const_prop_fails_gracefully.rs11
-rw-r--r--tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff31
-rw-r--r--tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff26
-rw-r--r--tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff26
-rw-r--r--tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir9
-rw-r--r--tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.panic-abort.mir9
-rw-r--r--tests/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.panic-unwind.mir9
-rw-r--r--tests/mir-opt/const_prop/control_flow_simplification.rs3
-rw-r--r--tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff57
-rw-r--r--tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff57
-rw-r--r--tests/mir-opt/const_prop/discriminant.rs14
-rw-r--r--tests/mir-opt/const_prop/indirect.main.ConstProp.diff33
-rw-r--r--tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff37
-rw-r--r--tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff37
-rw-r--r--tests/mir-opt/const_prop/indirect.rs5
-rw-r--r--tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff41
-rw-r--r--tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff35
-rw-r--r--tests/mir-opt/const_prop/indirect_mutation.rs41
-rw-r--r--tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff39
-rw-r--r--tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff45
-rw-r--r--tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff45
-rw-r--r--tests/mir-opt/const_prop/inherit_overflow.rs10
-rw-r--r--tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff92
-rw-r--r--tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff106
-rw-r--r--tests/mir-opt/const_prop/invalid_constant.rs1
-rw-r--r--tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff23
-rw-r--r--tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff37
-rw-r--r--tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff37
-rw-r--r--tests/mir-opt/const_prop/issue_66971.rs5
-rw-r--r--tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff28
-rw-r--r--tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff42
-rw-r--r--tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff42
-rw-r--r--tests/mir-opt/const_prop/issue_67019.rs5
-rw-r--r--tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff39
-rw-r--r--tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff39
-rw-r--r--tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff39
-rw-r--r--tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff39
-rw-r--r--tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff39
-rw-r--r--tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff39
-rw-r--r--tests/mir-opt/const_prop/large_array_index.rs4
-rw-r--r--tests/mir-opt/const_prop/mult_by_zero.rs6
-rw-r--r--tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff18
-rw-r--r--tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff30
-rw-r--r--tests/mir-opt/const_prop/mutable_variable.rs6
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff40
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate.rs6
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff38
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs8
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff35
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-abort.diff32
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff32
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs9
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff57
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_no_prop.rs8
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff53
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff54
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff54
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs15
-rw-r--r--tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff44
-rw-r--r--tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff124
-rw-r--r--tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff124
-rw-r--r--tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff40
-rw-r--r--tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff110
-rw-r--r--tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff110
-rw-r--r--tests/mir-opt/const_prop/offset_of.rs21
-rw-r--r--tests/mir-opt/const_prop/overwrite_with_const_with_params.rs26
-rw-r--r--tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff20
-rw-r--r--tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff38
-rw-r--r--tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff38
-rw-r--r--tests/mir-opt/const_prop/pointer_expose_address.rs18
-rw-r--r--tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff62
-rw-r--r--tests/mir-opt/const_prop/read_immutable_static.rs3
-rw-r--r--tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff34
-rw-r--r--tests/mir-opt/const_prop/ref_deref.rs7
-rw-r--r--tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff34
-rw-r--r--tests/mir-opt/const_prop/ref_deref_project.rs8
-rw-r--r--tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff33
-rw-r--r--tests/mir-opt/const_prop/reify_fn_ptr.rs4
-rw-r--r--tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff44
-rw-r--r--tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff44
-rw-r--r--tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff44
-rw-r--r--tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff44
-rw-r--r--tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff44
-rw-r--r--tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff44
-rw-r--r--tests/mir-opt/const_prop/repeat.rs6
-rw-r--r--tests/mir-opt/const_prop/return_place.add.ConstProp.diff21
-rw-r--r--tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff25
-rw-r--r--tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff25
-rw-r--r--tests/mir-opt/const_prop/return_place.add.PreCodegen.before.mir16
-rw-r--r--tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir20
-rw-r--r--tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir20
-rw-r--r--tests/mir-opt/const_prop/return_place.rs4
-rw-r--r--tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff34
-rw-r--r--tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff32
-rw-r--r--tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff32
-rw-r--r--tests/mir-opt/const_prop/scalar_literal_propagation.rs5
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff50
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff50
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff50
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff50
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff50
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff50
-rw-r--r--tests/mir-opt/const_prop/slice_len.rs8
-rw-r--r--tests/mir-opt/const_prop/switch_int.main.ConstProp.diff34
-rw-r--r--tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-abort.diff28
-rw-r--r--tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff28
-rw-r--r--tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff34
-rw-r--r--tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-abort.diff28
-rw-r--r--tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff28
-rw-r--r--tests/mir-opt/const_prop/switch_int.rs10
-rw-r--r--tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff8
-rw-r--r--tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff8
-rw-r--r--tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff8
-rw-r--r--tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff8
-rw-r--r--tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff8
-rw-r--r--tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff8
-rw-r--r--tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff21
-rw-r--r--tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff21
-rw-r--r--tests/mir-opt/const_prop/transmute.rs22
-rw-r--r--tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff22
-rw-r--r--tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff22
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff20
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff20
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff18
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff18
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff25
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff25
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff17
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff17
-rw-r--r--tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff8
-rw-r--r--tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff8
-rw-r--r--tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff35
-rw-r--r--tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff45
-rw-r--r--tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff45
-rw-r--r--tests/mir-opt/const_prop/tuple_literal_propagation.rs6
-rw-r--r--tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff58
-rw-r--r--tests/mir-opt/const_prop/while_let_loops.rs2
183 files changed, 3978 insertions, 2041 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/address_of_pair.rs b/tests/mir-opt/const_prop/address_of_pair.rs
index 43dc9bae6..730ebe2ca 100644
--- a/tests/mir-opt/const_prop/address_of_pair.rs
+++ b/tests/mir-opt/const_prop/address_of_pair.rs
@@ -2,6 +2,20 @@
// EMIT_MIR address_of_pair.fn0.ConstProp.diff
pub fn fn0() -> bool {
+ // CHECK-LABEL: fn fn0(
+ // CHECK: debug pair => [[pair:_.*]];
+ // CHECK: debug ptr => [[ptr:_.*]];
+ // CHECK: debug ret => [[ret:_.*]];
+ // CHECK: (*[[ptr]]) = const true;
+ // CHECK-NOT: = const false;
+ // CHECK-NOT: = const true;
+ // CHECK: [[tmp:_.*]] = ([[pair]].1: bool);
+ // CHECK-NOT: = const false;
+ // CHECK-NOT: = const true;
+ // CHECK: [[ret]] = Not(move [[tmp]]);
+ // CHECK-NOT: = const false;
+ // CHECK-NOT: = const true;
+ // CHECK: _0 = [[ret]];
let mut pair = (1, false);
let ptr = core::ptr::addr_of_mut!(pair.1);
pair = (1, false);
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.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..a4911a6d4
--- /dev/null
+++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff
@@ -0,0 +1,42 @@
+- // 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;
+- _4 = foo(move _5) -> [return: bb1, unwind unreachable];
++ _5 = const 1_u8;
++ _4 = foo(const 1_u8) -> [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..b8b9fa5cc
--- /dev/null
+++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,42 @@
+- // 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;
+- _4 = foo(move _5) -> [return: bb1, unwind continue];
++ _5 = const 1_u8;
++ _4 = foo(const 1_u8) -> [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.rs b/tests/mir-opt/const_prop/aggregate.rs
index ed5a4ab59..fa716b084 100644
--- a/tests/mir-opt/const_prop/aggregate.rs
+++ b/tests/mir-opt/const_prop/aggregate.rs
@@ -1,18 +1,29 @@
-// ignore-wasm32 compiled with panic=abort by default
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// compile-flags: -O
// EMIT_MIR aggregate.main.ConstProp.diff
-// EMIT_MIR aggregate.main.PreCodegen.after.mir
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK-NOT: = Add(
+ // CHECK: [[x]] = const 1_u8;
+ // CHECK-NOT: = Add(
+ // CHECK: foo(const 1_u8)
let x = (0, 1, 2).1 + 0;
foo(x);
}
+// Verify that we still propagate if part of the aggregate is not known.
// EMIT_MIR aggregate.foo.ConstProp.diff
-// EMIT_MIR aggregate.foo.PreCodegen.after.mir
fn foo(x: u8) {
- // Verify that we still propagate if part of the aggregate is not known.
+ // CHECK-LABEL: fn foo(
+ // CHECK: debug first => [[first:_.*]];
+ // CHECK: debug second => [[second:_.*]];
+ // CHECK-NOT: = Add(
+ // CHECK: [[first]] = const 1_i32;
+ // CHECK-NOT: = Add(
+ // CHECK: [[second]] = const 3_i32;
let first = (0, x).0 + 1;
let second = (x, 1).1 + 2;
}
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..b2f58f8f7
--- /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 {}", const 4_usize, const 2_usize) -> [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..f9e3f8f17
--- /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 {}", const 4_usize, const 2_usize) -> [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..b2f58f8f7
--- /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 {}", const 4_usize, const 2_usize) -> [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..f9e3f8f17
--- /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 {}", const 4_usize, const 2_usize) -> [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..c4c46d78f 100644
--- a/tests/mir-opt/const_prop/array_index.rs
+++ b/tests/mir-opt/const_prop/array_index.rs
@@ -1,8 +1,11 @@
-// ignore-wasm32 compiled with panic=abort by default
// unit-test: ConstProp
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR array_index.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: [[x]] = const 2_u32;
let x: u32 = [0, 1, 2, 3][2];
}
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..cead70110
--- /dev/null
+++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff
@@ -0,0 +1,54 @@
+- // 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, const 0_i32) -> [success: bb2, unwind unreachable];
+ }
+
+ bb2: {
+- _2 = Div(const 1_i32, move _3);
++ _2 = Div(const 1_i32, const 0_i32);
+ 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..c9c4ba854
--- /dev/null
+++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,54 @@
+- // 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, const 0_i32) -> [success: bb2, unwind continue];
+ }
+
+ bb2: {
+- _2 = Div(const 1_i32, move _3);
++ _2 = Div(const 1_i32, const 0_i32);
+ 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..0e8765a07 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,8 +1,15 @@
-// ignore-wasm32 compiled with panic=abort by default
// unit-test: ConstProp
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+
// EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff
#[allow(unconditional_panic)]
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: debug _z => [[z:_.*]];
+ // CHECK: assert(!const true, "attempt to divide `{}` by zero", const 1_i32)
+ // CHECK: assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, const 0_i32)
+ // CHECK: [[z]] = Div(const 1_i32, const 0_i32);
let y = 0;
let _z = 1 / y;
}
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..2666fd9eb
--- /dev/null
+++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff
@@ -0,0 +1,54 @@
+- // 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, const 0_i32) -> [success: bb2, unwind unreachable];
+ }
+
+ bb2: {
+- _2 = Rem(const 1_i32, move _3);
++ _2 = Rem(const 1_i32, const 0_i32);
+ 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..679df90f1
--- /dev/null
+++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,54 @@
+- // 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, const 0_i32) -> [success: bb2, unwind continue];
+ }
+
+ bb2: {
+- _2 = Rem(const 1_i32, move _3);
++ _2 = Rem(const 1_i32, const 0_i32);
+ 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..d895d9e21 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,8 +1,16 @@
// 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() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: debug _z => [[z:_.*]];
+ // CHECK: assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of
+ // zero", const 1_i32)
+ // CHECK: assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32)
+ // CHECK: [[z]] = Rem(const 1_i32, const 0_i32);
let y = 0;
let _z = 1 % y;
}
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..e443c8991
--- /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 = Len((*_1));
+- _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 = Lt(const 3_usize, _7);
++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 3_usize) -> [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..592f43f47
--- /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 = Len((*_1));
+- _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 = Lt(const 3_usize, _7);
++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 3_usize) -> [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..e443c8991
--- /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 = Len((*_1));
+- _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 = Lt(const 3_usize, _7);
++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 3_usize) -> [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..592f43f47
--- /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 = Len((*_1));
+- _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 = Lt(const 3_usize, _7);
++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 3_usize) -> [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..266105c11 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,11 +1,14 @@
// unit-test: ConstProp
-// ignore-wasm32 compiled with panic=abort by default
-// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen
-
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
+
// EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff
#[allow(unconditional_panic)]
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: debug _b => [[b:_.*]];
+ // CHECK: [[b]] = (*[[a]])[3 of 4];
let a: *const [_] = &[1, 2, 3];
unsafe {
let _b = (*a)[3];
diff --git a/tests/mir-opt/const_prop/boolean_identities.rs b/tests/mir-opt/const_prop/boolean_identities.rs
index c7b609949..2aa038034 100644
--- a/tests/mir-opt/const_prop/boolean_identities.rs
+++ b/tests/mir-opt/const_prop/boolean_identities.rs
@@ -1,9 +1,16 @@
// unit-test: ConstProp
-// compile-flags: -O -Zmir-opt-level=4
// EMIT_MIR boolean_identities.test.ConstProp.diff
pub fn test(x: bool, y: bool) -> bool {
- (y | true) & (x & false)
+ // CHECK-LABEL: fn test(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: debug b => [[b:_.*]];
+ // CHECK: [[a]] = const true;
+ // CHECK: [[b]] = const false;
+ // CHECK: _0 = const false;
+ let a = (y | true);
+ let b = (x & false);
+ a & b
}
fn main() {
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..41e1acdff 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,48 @@
+ // 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 _3: bool;
+ let mut _4: bool;
+ let mut _6: bool;
+ let mut _7: bool;
+ let mut _8: bool;
+ scope 1 {
+ debug a => _3;
+ let _5: bool;
+ scope 2 {
+ debug b => _5;
+ }
+ }
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);
+ StorageLive(_4);
+ _4 = _2;
+- _3 = BitOr(move _4, const true);
++ _3 = const true;
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ _6 = _1;
+- _5 = BitAnd(move _6, const false);
++ _5 = const false;
+ StorageDead(_6);
+ StorageLive(_7);
+- _7 = _3;
++ _7 = const true;
+ StorageLive(_8);
+- _8 = _5;
+- _0 = BitAnd(move _7, move _8);
++ _8 = const false;
++ _0 = const false;
+ StorageDead(_8);
+ StorageDead(_7);
+ 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..c9670a5ee
--- /dev/null
+++ b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff
@@ -0,0 +1,54 @@
+- // 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);
+- _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind unreachable];
++ _4 = const 4_usize;
++ _5 = const 4_usize;
++ _6 = alloc::alloc::exchange_malloc(const 4_usize, const 4_usize) -> [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..64fe72be5
--- /dev/null
+++ b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,58 @@
+- // 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);
+- _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind continue];
++ _4 = const 4_usize;
++ _5 = const 4_usize;
++ _6 = alloc::alloc::exchange_malloc(const 4_usize, const 4_usize) -> [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..90a8e33e8 100644
--- a/tests/mir-opt/const_prop/boxes.rs
+++ b/tests/mir-opt/const_prop/boxes.rs
@@ -1,8 +1,6 @@
// unit-test: ConstProp
// compile-flags: -O
-// ignore-emscripten compiled with panic=abort by default
-// ignore-wasm32
-// ignore-wasm64
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![feature(rustc_attrs, stmt_expr_attributes)]
@@ -10,6 +8,11 @@
// EMIT_MIR boxes.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: (*{{_.*}}) = const 42_i32;
+ // CHECK: [[tmp:_.*]] = (*{{_.*}});
+ // CHECK: [[x]] = Add(move [[tmp]], const 0_i32);
let x = *(#[rustc_box]
Box::new(42))
+ 0;
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/cast.rs b/tests/mir-opt/const_prop/cast.rs
index 984086eda..b81c2740a 100644
--- a/tests/mir-opt/const_prop/cast.rs
+++ b/tests/mir-opt/const_prop/cast.rs
@@ -2,7 +2,11 @@
// EMIT_MIR cast.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = const 42_u32;
+ // CHECK: [[y]] = const 42_u8;
let x = 42u8 as u32;
-
let y = 42u32 as u8;
}
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..5a958cc7a
--- /dev/null
+++ b/tests/mir-opt/const_prop/checked_add.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;
+ 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;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 02 00 00 00 00 __ __ __ │ .....░░░
+ }
+
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..ab48186ae
--- /dev/null
+++ b/tests/mir-opt/const_prop/checked_add.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;
+ 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;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 02 00 00 00 00 __ __ __ │ .....░░░
+ }
+
diff --git a/tests/mir-opt/const_prop/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs
index 007defd10..571a5cc4e 100644
--- a/tests/mir-opt/const_prop/checked_add.rs
+++ b/tests/mir-opt/const_prop/checked_add.rs
@@ -1,8 +1,12 @@
-// ignore-wasm32 compiled with panic=abort by default
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// compile-flags: -C overflow-checks=on
// EMIT_MIR checked_add.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: assert(!const false,
+ // CHECK: [[x]] = const 2_u32;
let x: u32 = 1 + 1;
}
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.rs b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs
deleted file mode 100644
index 44d487842..000000000
--- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// ignore-wasm32 compiled with panic=abort by default
-// unit-test: ConstProp
-#[inline(never)]
-fn read(_: usize) { }
-
-// EMIT_MIR const_prop_fails_gracefully.main.ConstProp.diff
-fn main() {
- const FOO: &i32 = &1;
- let x = FOO as *const i32 as usize;
- read(x);
-}
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..ba2e89f0a
--- /dev/null
+++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff
@@ -0,0 +1,26 @@
+- // 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];
++ _1 = const false;
++ 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..e0a610f60
--- /dev/null
+++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff
@@ -0,0 +1,26 @@
+- // 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];
++ _1 = const false;
++ 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..5fc13e202 100644
--- a/tests/mir-opt/const_prop/control_flow_simplification.rs
+++ b/tests/mir-opt/const_prop/control_flow_simplification.rs
@@ -1,4 +1,5 @@
-// ignore-wasm32 compiled with panic=abort by default
+// skip-filecheck
+// 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/discriminant.rs b/tests/mir-opt/const_prop/discriminant.rs
index fdd67ca8a..0ed683d62 100644
--- a/tests/mir-opt/const_prop/discriminant.rs
+++ b/tests/mir-opt/const_prop/discriminant.rs
@@ -1,5 +1,4 @@
// unit-test: ConstProp
-// compile-flags: -O
// FIXME(wesleywiser): Ideally, we could const-prop away all of this and just be left with
// `let x = 42` but that doesn't work because const-prop doesn't support `Operand::Indirect`
@@ -9,5 +8,18 @@
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR discriminant.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: bb0: {
+ // CHECK: switchInt(const 1_isize) -> [1: bb1, otherwise: bb3];
+ // CHECK: bb1: {
+ // CHECK: switchInt(const true) -> [0: bb3, otherwise: bb2];
+ // CHECK: bb2: {
+ // CHECK: [[tmp:_.*]] = const 42_i32;
+ // CHECK: goto -> bb4;
+ // CHECK: bb3: {
+ // CHECK: [[tmp]] = const 10_i32;
+ // CHECK: goto -> bb4;
+ // CHECK: bb4: {
+ // CHECK: {{_.*}} = Add(move [[tmp]], const 0_i32);
let x = (if let Some(true) = Some(true) { 42 } else { 10 }) + 0;
}
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..530cfc653
--- /dev/null
+++ b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff
@@ -0,0 +1,37 @@
+- // 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", const 2_u8, const 1_u8) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = move (_3.0: u8);
++ _1 = const 3_u8;
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 03 00 │ ..
+ }
+
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..08cf72e47
--- /dev/null
+++ b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,37 @@
+- // 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", const 2_u8, const 1_u8) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = move (_3.0: u8);
++ _1 = const 3_u8;
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 03 00 │ ..
+ }
+
diff --git a/tests/mir-opt/const_prop/indirect.rs b/tests/mir-opt/const_prop/indirect.rs
index 46fd8082d..d3c42e3eb 100644
--- a/tests/mir-opt/const_prop/indirect.rs
+++ b/tests/mir-opt/const_prop/indirect.rs
@@ -1,8 +1,11 @@
-// ignore-wasm32 compiled with panic=abort by default
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// compile-flags: -C overflow-checks=on
// EMIT_MIR indirect.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: [[x]] = const 3_u8;
let x = (2u32 as u8) + 1;
}
diff --git a/tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff b/tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff
new file mode 100644
index 000000000..4eafb8d09
--- /dev/null
+++ b/tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff
@@ -0,0 +1,41 @@
+- // MIR for `bar` before ConstProp
++ // MIR for `bar` after ConstProp
+
+ fn bar() -> () {
+ let mut _0: ();
+ let mut _1: (i32,);
+ let _2: ();
+ let mut _3: *mut i32;
+ let mut _5: i32;
+ scope 1 {
+ debug v => _1;
+ let _4: bool;
+ scope 2 {
+ }
+ scope 3 {
+ debug y => _4;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = (const 1_i32,);
+ StorageLive(_2);
+ StorageLive(_3);
+ _3 = &raw mut (_1.0: i32);
+ (*_3) = const 5_i32;
+ StorageDead(_3);
+ _2 = const ();
+ StorageDead(_2);
+ StorageLive(_4);
+ StorageLive(_5);
+ _5 = (_1.0: i32);
+ _4 = Eq(move _5, const 5_i32);
+ StorageDead(_5);
+ _0 = const ();
+ StorageDead(_4);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff b/tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff
new file mode 100644
index 000000000..445d9895d
--- /dev/null
+++ b/tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff
@@ -0,0 +1,35 @@
+- // MIR for `foo` before ConstProp
++ // MIR for `foo` after ConstProp
+
+ fn foo() -> () {
+ let mut _0: ();
+ let mut _1: (i32,);
+ let mut _2: &mut i32;
+ let mut _4: i32;
+ scope 1 {
+ debug u => _1;
+ let _3: bool;
+ scope 2 {
+ debug y => _3;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = (const 1_i32,);
+ StorageLive(_2);
+ _2 = &mut (_1.0: i32);
+ (*_2) = const 5_i32;
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = (_1.0: i32);
+ _3 = Eq(move _4, const 5_i32);
+ StorageDead(_4);
+ _0 = const ();
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/const_prop/indirect_mutation.rs b/tests/mir-opt/const_prop/indirect_mutation.rs
new file mode 100644
index 000000000..ec9da6e8e
--- /dev/null
+++ b/tests/mir-opt/const_prop/indirect_mutation.rs
@@ -0,0 +1,41 @@
+// unit-test: ConstProp
+// Check that we do not propagate past an indirect mutation.
+#![feature(raw_ref_op)]
+
+// EMIT_MIR indirect_mutation.foo.ConstProp.diff
+fn foo() {
+ // CHECK-LABEL: fn foo(
+ // CHECK: debug u => _1;
+ // CHECK: debug y => _3;
+ // CHECK: _1 = (const 1_i32,);
+ // CHECK: _2 = &mut (_1.0: i32);
+ // CHECK: (*_2) = const 5_i32;
+ // CHECK: _4 = (_1.0: i32);
+ // CHECK: _3 = Eq(move _4, const 5_i32);
+
+ let mut u = (1,);
+ *&mut u.0 = 5;
+ let y = { u.0 } == 5;
+}
+
+// EMIT_MIR indirect_mutation.bar.ConstProp.diff
+fn bar() {
+ // CHECK-LABEL: fn bar(
+ // CHECK: debug v => _1;
+ // CHECK: debug y => _4;
+ // CHECK: _3 = &raw mut (_1.0: i32);
+ // CHECK: (*_3) = const 5_i32;
+ // CHECK: _5 = (_1.0: i32);
+ // CHECK: _4 = Eq(move _5, const 5_i32);
+
+ let mut v = (1,);
+ unsafe {
+ *&raw mut v.0 = 5;
+ }
+ let y = { v.0 } == 5;
+}
+
+fn main() {
+ foo();
+ bar();
+}
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..11cdf9e09
--- /dev/null
+++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff
@@ -0,0 +1,45 @@
+- // 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 #[track_caller] <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;
+ StorageLive(_4);
+- _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", const u8::MAX, const 1_u8) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = move (_4.0: u8);
++ _1 = const 0_u8;
+ StorageDead(_4);
+ StorageDead(_3);
+ StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 00 01 │ ..
+ }
+
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..181a2f287
--- /dev/null
+++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,45 @@
+- // 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 #[track_caller] <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;
+ StorageLive(_4);
+- _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", const u8::MAX, const 1_u8) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = move (_4.0: u8);
++ _1 = const 0_u8;
+ StorageDead(_4);
+ StorageDead(_3);
+ StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 00 01 │ ..
+ }
+
diff --git a/tests/mir-opt/const_prop/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs
index 4e905d00d..5b561ae14 100644
--- a/tests/mir-opt/const_prop/inherit_overflow.rs
+++ b/tests/mir-opt/const_prop/inherit_overflow.rs
@@ -1,10 +1,14 @@
-// ignore-wasm32 compiled with panic=abort by default
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// compile-flags: -Zmir-enable-passes=+Inline
+// After inlining, this will contain a `CheckedBinaryOp`.
+// Propagating the overflow is ok as codegen will just skip emitting the panic.
// EMIT_MIR inherit_overflow.main.ConstProp.diff
fn main() {
- // After inlining, this will contain a `CheckedBinaryOp`.
- // Propagating the overflow is ok as codegen will just skip emitting the panic.
+ // CHECK-LABEL: fn main(
+ // CHECK: {{_.*}} = const (0_u8, true);
+ // CHECK: assert(!const true,
+ // CHECK: {{_.*}} = const 0_u8;
let _ = <u8 as std::ops::Add>::add(255, 1);
}
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..10e978a68 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,37 @@
}
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);
+- _3 = [move _4];
++ _4 = const Scalar(0x00000004): E;
++ _3 = [const Scalar(0x00000004): E];
+ 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/invalid_constant.rs b/tests/mir-opt/const_prop/invalid_constant.rs
index bdbc5a199..ff6b31a1e 100644
--- a/tests/mir-opt/const_prop/invalid_constant.rs
+++ b/tests/mir-opt/const_prop/invalid_constant.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: ConstProp
// compile-flags: -Zmir-enable-passes=+RemoveZsts
// Verify that we can pretty print invalid constants.
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..ff93c85e5
--- /dev/null
+++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff
@@ -0,0 +1,37 @@
+- // 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: ();
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ _3 = ();
+- _2 = (move _3, const 0_u8, const 0_u8);
++ _2 = const ((), 0_u8, 0_u8);
+ StorageDead(_3);
+- _1 = encode(move _2) -> [return: bb1, unwind unreachable];
++ _1 = encode(const ((), 0_u8, 0_u8)) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 00 00 │ ..
++ }
++
++ ALLOC1 (size: 2, align: 1) {
++ 00 00 │ ..
+ }
+
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..8790aad45
--- /dev/null
+++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,37 @@
+- // 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: ();
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ _3 = ();
+- _2 = (move _3, const 0_u8, const 0_u8);
++ _2 = const ((), 0_u8, 0_u8);
+ StorageDead(_3);
+- _1 = encode(move _2) -> [return: bb1, unwind continue];
++ _1 = encode(const ((), 0_u8, 0_u8)) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 00 00 │ ..
++ }
++
++ ALLOC1 (size: 2, align: 1) {
++ 00 00 │ ..
+ }
+
diff --git a/tests/mir-opt/const_prop/issue_66971.rs b/tests/mir-opt/const_prop/issue_66971.rs
index af95c9ca2..49d598ff2 100644
--- a/tests/mir-opt/const_prop/issue_66971.rs
+++ b/tests/mir-opt/const_prop/issue_66971.rs
@@ -1,6 +1,5 @@
-// ignore-wasm32 compiled with panic=abort by default
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
-// compile-flags: -Z mir-opt-level=3
// Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected
// outputs below, after ConstProp this is how _2 would look like with the bug:
@@ -15,5 +14,7 @@ fn encode(this: ((), u8, u8)) {
// EMIT_MIR issue_66971.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: = encode(const ((), 0_u8, 0_u8))
encode(((), 0, 0));
}
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..3de9cdd79
--- /dev/null
+++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff
@@ -0,0 +1,42 @@
+- // 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(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+- _3 = (const 1_u8, const 2_u8);
+- _2 = (move _3,);
++ _3 = const (1_u8, 2_u8);
++ _2 = const ((1_u8, 2_u8),);
+ StorageDead(_3);
+- _1 = test(move _2) -> [return: bb1, unwind unreachable];
++ _1 = test(const ((1_u8, 2_u8),)) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 01 02 │ ..
++ }
++
++ ALLOC1 (size: 2, align: 1) {
++ 01 02 │ ..
++ }
++
++ ALLOC2 (size: 2, align: 1) {
++ 01 02 │ ..
+ }
+
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..72cf48b5c
--- /dev/null
+++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,42 @@
+- // 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(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+- _3 = (const 1_u8, const 2_u8);
+- _2 = (move _3,);
++ _3 = const (1_u8, 2_u8);
++ _2 = const ((1_u8, 2_u8),);
+ StorageDead(_3);
+- _1 = test(move _2) -> [return: bb1, unwind continue];
++ _1 = test(const ((1_u8, 2_u8),)) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 01 02 │ ..
++ }
++
++ ALLOC1 (size: 2, align: 1) {
++ 01 02 │ ..
++ }
++
++ ALLOC2 (size: 2, align: 1) {
++ 01 02 │ ..
+ }
+
diff --git a/tests/mir-opt/const_prop/issue_67019.rs b/tests/mir-opt/const_prop/issue_67019.rs
index 08c7d4805..f0a09e6e8 100644
--- a/tests/mir-opt/const_prop/issue_67019.rs
+++ b/tests/mir-opt/const_prop/issue_67019.rs
@@ -1,6 +1,5 @@
-// ignore-wasm32 compiled with panic=abort by default
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
-// compile-flags: -Z mir-opt-level=3
// This used to ICE in const-prop
@@ -10,5 +9,7 @@ fn test(this: ((u8, u8),)) {
// EMIT_MIR issue_67019.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: = test(const ((1_u8, 2_u8),))
test(((1, 2),));
}
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..20e2ee326
--- /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 {}", const 5000_usize, const 2_usize) -> [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..1bdbbbf78
--- /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 {}", const 5000_usize, const 2_usize) -> [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..20e2ee326
--- /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 {}", const 5000_usize, const 2_usize) -> [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..1bdbbbf78
--- /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 {}", const 5000_usize, const 2_usize) -> [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..d98d166ff 100644
--- a/tests/mir-opt/const_prop/large_array_index.rs
+++ b/tests/mir-opt/const_prop/large_array_index.rs
@@ -1,6 +1,6 @@
+// skip-filecheck
// unit-test: ConstProp
-// ignore-wasm32 compiled with panic=abort by default
-// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR large_array_index.main.ConstProp.diff
diff --git a/tests/mir-opt/const_prop/mult_by_zero.rs b/tests/mir-opt/const_prop/mult_by_zero.rs
index 7bd30975a..2e9c63a1c 100644
--- a/tests/mir-opt/const_prop/mult_by_zero.rs
+++ b/tests/mir-opt/const_prop/mult_by_zero.rs
@@ -1,8 +1,10 @@
// unit-test: ConstProp
// EMIT_MIR mult_by_zero.test.ConstProp.diff
-fn test(x : i32) -> i32 {
- x * 0
+fn test(x: i32) -> i32 {
+ // CHECK: fn test(
+ // CHECK: _0 = const 0_i32;
+ x * 0
}
fn main() {
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.rs b/tests/mir-opt/const_prop/mutable_variable.rs
index 95987ef7f..6c74ea5b9 100644
--- a/tests/mir-opt/const_prop/mutable_variable.rs
+++ b/tests/mir-opt/const_prop/mutable_variable.rs
@@ -2,6 +2,12 @@
// EMIT_MIR mutable_variable.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = const 42_i32;
+ // CHECK: [[x]] = const 99_i32;
+ // CHECK: [[y]] = const 99_i32;
let mut x = 42;
x = 99;
let y = x;
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..c3ace9687 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,36 @@
+ // 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;
}
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 2a 00 00 00 63 00 00 00 │ *...c...
++ }
++
++ ALLOC1 (size: 8, align: 4) {
++ 2a 00 00 00 2b 00 00 00 │ *...+...
}
diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs
index a145c0354..a38296502 100644
--- a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs
+++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs
@@ -2,6 +2,12 @@
// EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = const (42_i32, 43_i32);
+ // CHECK: ([[x]].1: i32) = const 99_i32;
+ // CHECK: [[y]] = const (42_i32, 99_i32);
let mut x = (42, 43);
x.1 = 99;
let y = x;
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_mut_ref.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs
index 3099e659f..60f414ae2 100644
--- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs
+++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs
@@ -2,6 +2,14 @@
// EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug z => [[z:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = (const 42_i32, const 43_i32);
+ // CHECK: [[z]] = &mut [[x]];
+ // CHECK: ((*[[z]]).1: i32) = const 99_i32;
+ // CHECK: [[y]] = [[x]];
let mut x = (42, 43);
let z = &mut x;
z.1 = 99;
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..888fcde2d 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,8 +1,15 @@
-// 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
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = foo()
+ // CHECK: ([[x]].1: i32) = const 99_i32;
+ // CHECK: ([[x]].0: i32) = const 42_i32;
+ // CHECK: [[y]] = const 99_i32;
let mut x: (i32, i32) = foo();
x.1 = 99;
x.0 = 42;
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..1f74bdcfd 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,47 +2,44 @@
+ // 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 {ALLOC0: *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;
}
}
- alloc1 (static: STATIC, size: 4, align: 4) {
+ ALLOC0 (static: STATIC, size: 4, align: 4) {
42 42 42 42 │ BBBB
}
diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs
index e51c62235..49e9a7015 100644
--- a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs
+++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs
@@ -1,9 +1,17 @@
// unit-test: ConstProp
+// Verify that we do not propagate the contents of this mutable static.
static mut STATIC: u32 = 0x42424242;
// EMIT_MIR mutable_variable_no_prop.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = const 42_u32;
+ // CHECK: [[tmp:_.*]] = (*{{_.*}});
+ // CHECK: [[x]] = move [[tmp]];
+ // CHECK: [[y]] = [[x]];
let mut x = 42;
unsafe {
x = STATIC;
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..85bd2b6e7
--- /dev/null
+++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff
@@ -0,0 +1,54 @@
+- // 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;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
+ }
+
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..06e96e57a
--- /dev/null
+++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,54 @@
+- // 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;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
+ }
+
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..04e347fc0 100644
--- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs
+++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs
@@ -1,13 +1,24 @@
-// 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
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: debug z => [[z:_.*]];
+ // CHECK: [[a]] = foo()
+ // CHECK: [[x]] = const (1_i32, 2_i32);
+ // CHECK: [[tmp:_.*]] = [[a]];
+ // CHECK: ([[x]].1: i32) = move [[tmp]];
+ // CHECK: [[y]] = ([[x]].1: i32);
+ // CHECK: [[z]] = const 1_i32;
let a = foo();
let mut x: (i32, i32) = (1, 2);
x.1 = a;
let y = x.1;
- let z = x.0; // this could theoretically be allowed, but we can't handle it right now
+ let z = x.0;
}
#[inline(never)]
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..711db3d21
--- /dev/null
+++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff
@@ -0,0 +1,124 @@
+- // 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;
+ let mut _10: usize;
+ let mut _12: usize;
+ let mut _14: 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;
+ let _9: usize;
+ scope 5 {
+ debug eA0 => _9;
+ let _11: usize;
+ scope 6 {
+ debug eA1 => _11;
+ let _13: usize;
+ scope 7 {
+ debug eC => _13;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = OffsetOf(Alpha, [(0, 0)]);
+- _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable];
++ _2 = const 4_usize;
++ _1 = must_use::<usize>(const 4_usize) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = OffsetOf(Alpha, [(0, 1)]);
+- _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable];
++ _4 = const 0_usize;
++ _3 = must_use::<usize>(const 0_usize) -> [return: bb2, unwind unreachable];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+- _6 = OffsetOf(Alpha, [(0, 2), (0, 0)]);
+- _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable];
++ _6 = const 2_usize;
++ _5 = must_use::<usize>(const 2_usize) -> [return: bb3, unwind unreachable];
+ }
+
+ bb3: {
+ StorageDead(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+- _8 = OffsetOf(Alpha, [(0, 2), (0, 1)]);
+- _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable];
++ _8 = const 3_usize;
++ _7 = must_use::<usize>(const 3_usize) -> [return: bb4, unwind unreachable];
+ }
+
+ bb4: {
+ StorageDead(_8);
+ StorageLive(_9);
+ StorageLive(_10);
+- _10 = OffsetOf(Epsilon, [(0, 0)]);
+- _9 = must_use::<usize>(move _10) -> [return: bb5, unwind unreachable];
++ _10 = const 1_usize;
++ _9 = must_use::<usize>(const 1_usize) -> [return: bb5, unwind unreachable];
+ }
+
+ bb5: {
+ StorageDead(_10);
+ StorageLive(_11);
+ StorageLive(_12);
+- _12 = OffsetOf(Epsilon, [(0, 1)]);
+- _11 = must_use::<usize>(move _12) -> [return: bb6, unwind unreachable];
++ _12 = const 2_usize;
++ _11 = must_use::<usize>(const 2_usize) -> [return: bb6, unwind unreachable];
+ }
+
+ bb6: {
+ StorageDead(_12);
+ StorageLive(_13);
+ StorageLive(_14);
+- _14 = OffsetOf(Epsilon, [(2, 0)]);
+- _13 = must_use::<usize>(move _14) -> [return: bb7, unwind unreachable];
++ _14 = const 4_usize;
++ _13 = must_use::<usize>(const 4_usize) -> [return: bb7, unwind unreachable];
+ }
+
+ bb7: {
+ StorageDead(_14);
+ _0 = const ();
+ StorageDead(_13);
+ StorageDead(_11);
+ StorageDead(_9);
+ 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..494581454
--- /dev/null
+++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff
@@ -0,0 +1,124 @@
+- // 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;
+ let mut _10: usize;
+ let mut _12: usize;
+ let mut _14: 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;
+ let _9: usize;
+ scope 5 {
+ debug eA0 => _9;
+ let _11: usize;
+ scope 6 {
+ debug eA1 => _11;
+ let _13: usize;
+ scope 7 {
+ debug eC => _13;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = OffsetOf(Alpha, [(0, 0)]);
+- _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue];
++ _2 = const 4_usize;
++ _1 = must_use::<usize>(const 4_usize) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = OffsetOf(Alpha, [(0, 1)]);
+- _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue];
++ _4 = const 0_usize;
++ _3 = must_use::<usize>(const 0_usize) -> [return: bb2, unwind continue];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+- _6 = OffsetOf(Alpha, [(0, 2), (0, 0)]);
+- _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue];
++ _6 = const 2_usize;
++ _5 = must_use::<usize>(const 2_usize) -> [return: bb3, unwind continue];
+ }
+
+ bb3: {
+ StorageDead(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+- _8 = OffsetOf(Alpha, [(0, 2), (0, 1)]);
+- _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue];
++ _8 = const 3_usize;
++ _7 = must_use::<usize>(const 3_usize) -> [return: bb4, unwind continue];
+ }
+
+ bb4: {
+ StorageDead(_8);
+ StorageLive(_9);
+ StorageLive(_10);
+- _10 = OffsetOf(Epsilon, [(0, 0)]);
+- _9 = must_use::<usize>(move _10) -> [return: bb5, unwind continue];
++ _10 = const 1_usize;
++ _9 = must_use::<usize>(const 1_usize) -> [return: bb5, unwind continue];
+ }
+
+ bb5: {
+ StorageDead(_10);
+ StorageLive(_11);
+ StorageLive(_12);
+- _12 = OffsetOf(Epsilon, [(0, 1)]);
+- _11 = must_use::<usize>(move _12) -> [return: bb6, unwind continue];
++ _12 = const 2_usize;
++ _11 = must_use::<usize>(const 2_usize) -> [return: bb6, unwind continue];
+ }
+
+ bb6: {
+ StorageDead(_12);
+ StorageLive(_13);
+ StorageLive(_14);
+- _14 = OffsetOf(Epsilon, [(2, 0)]);
+- _13 = must_use::<usize>(move _14) -> [return: bb7, unwind continue];
++ _14 = const 4_usize;
++ _13 = must_use::<usize>(const 4_usize) -> [return: bb7, unwind continue];
+ }
+
+ bb7: {
+ StorageDead(_14);
+ _0 = const ();
+ StorageDead(_13);
+ StorageDead(_11);
+ StorageDead(_9);
+ 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..768970a72
--- /dev/null
+++ b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff
@@ -0,0 +1,110 @@
+- // 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;
+ let mut _10: usize;
+ let mut _12: usize;
+ let mut _14: 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;
+ let _9: usize;
+ scope 5 {
+ debug zA0 => _9;
+ let _11: usize;
+ scope 6 {
+ debug zA1 => _11;
+ let _13: usize;
+ scope 7 {
+ debug zB => _13;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = OffsetOf(Gamma<T>, [(0, 0)]);
+ _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = OffsetOf(Gamma<T>, [(0, 1)]);
+ _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ _6 = OffsetOf(Delta<T>, [(0, 1)]);
+ _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable];
+ }
+
+ bb3: {
+ StorageDead(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+ _8 = OffsetOf(Delta<T>, [(0, 2)]);
+ _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable];
+ }
+
+ bb4: {
+ StorageDead(_8);
+ StorageLive(_9);
+ StorageLive(_10);
+ _10 = OffsetOf(Zeta<T>, [(0, 0)]);
+ _9 = must_use::<usize>(move _10) -> [return: bb5, unwind unreachable];
+ }
+
+ bb5: {
+ StorageDead(_10);
+ StorageLive(_11);
+ StorageLive(_12);
+ _12 = OffsetOf(Zeta<T>, [(0, 1)]);
+ _11 = must_use::<usize>(move _12) -> [return: bb6, unwind unreachable];
+ }
+
+ bb6: {
+ StorageDead(_12);
+ StorageLive(_13);
+ StorageLive(_14);
+ _14 = OffsetOf(Zeta<T>, [(1, 0)]);
+ _13 = must_use::<usize>(move _14) -> [return: bb7, unwind unreachable];
+ }
+
+ bb7: {
+ StorageDead(_14);
+ _0 = const ();
+ StorageDead(_13);
+ StorageDead(_11);
+ StorageDead(_9);
+ 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..04ccd2b36
--- /dev/null
+++ b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff
@@ -0,0 +1,110 @@
+- // 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;
+ let mut _10: usize;
+ let mut _12: usize;
+ let mut _14: 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;
+ let _9: usize;
+ scope 5 {
+ debug zA0 => _9;
+ let _11: usize;
+ scope 6 {
+ debug zA1 => _11;
+ let _13: usize;
+ scope 7 {
+ debug zB => _13;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = OffsetOf(Gamma<T>, [(0, 0)]);
+ _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = OffsetOf(Gamma<T>, [(0, 1)]);
+ _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ _6 = OffsetOf(Delta<T>, [(0, 1)]);
+ _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue];
+ }
+
+ bb3: {
+ StorageDead(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+ _8 = OffsetOf(Delta<T>, [(0, 2)]);
+ _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue];
+ }
+
+ bb4: {
+ StorageDead(_8);
+ StorageLive(_9);
+ StorageLive(_10);
+ _10 = OffsetOf(Zeta<T>, [(0, 0)]);
+ _9 = must_use::<usize>(move _10) -> [return: bb5, unwind continue];
+ }
+
+ bb5: {
+ StorageDead(_10);
+ StorageLive(_11);
+ StorageLive(_12);
+ _12 = OffsetOf(Zeta<T>, [(0, 1)]);
+ _11 = must_use::<usize>(move _12) -> [return: bb6, unwind continue];
+ }
+
+ bb6: {
+ StorageDead(_12);
+ StorageLive(_13);
+ StorageLive(_14);
+ _14 = OffsetOf(Zeta<T>, [(1, 0)]);
+ _13 = must_use::<usize>(move _14) -> [return: bb7, unwind continue];
+ }
+
+ bb7: {
+ StorageDead(_14);
+ _0 = const ();
+ StorageDead(_13);
+ StorageDead(_11);
+ StorageDead(_9);
+ 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..2571c3856 100644
--- a/tests/mir-opt/const_prop/offset_of.rs
+++ b/tests/mir-opt/const_prop/offset_of.rs
@@ -1,6 +1,8 @@
+// skip-filecheck
// unit-test: ConstProp
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
-#![feature(offset_of)]
+#![feature(offset_of, offset_of_enum)]
use std::marker::PhantomData;
use std::mem::offset_of;
@@ -26,12 +28,26 @@ struct Delta<T> {
y: u16,
}
+enum Epsilon {
+ A(u8, u16),
+ B,
+ C { c: u32 }
+}
+
+enum Zeta<T> {
+ A(T, bool),
+ B(char),
+}
+
// EMIT_MIR offset_of.concrete.ConstProp.diff
fn concrete() {
let x = offset_of!(Alpha, x);
let y = offset_of!(Alpha, y);
let z0 = offset_of!(Alpha, z.0);
let z1 = offset_of!(Alpha, z.1);
+ let eA0 = offset_of!(Epsilon, A.0);
+ let eA1 = offset_of!(Epsilon, A.1);
+ let eC = offset_of!(Epsilon, C.c);
}
// EMIT_MIR offset_of.generic.ConstProp.diff
@@ -40,6 +56,9 @@ fn generic<T>() {
let gy = offset_of!(Gamma<T>, y);
let dx = offset_of!(Delta<T>, x);
let dy = offset_of!(Delta<T>, y);
+ let zA0 = offset_of!(Zeta<T>, A.0);
+ let zA1 = offset_of!(Zeta<T>, A.1);
+ let zB = offset_of!(Zeta<T>, B.0);
}
fn main() {
diff --git a/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs b/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs
new file mode 100644
index 000000000..4cf6d7c13
--- /dev/null
+++ b/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs
@@ -0,0 +1,26 @@
+// unit-test: ConstProp
+// compile-flags: -O
+
+// Regression test for https://github.com/rust-lang/rust/issues/118328
+
+#![allow(unused_assignments)]
+
+struct SizeOfConst<T>(std::marker::PhantomData<T>);
+impl<T> SizeOfConst<T> {
+ const SIZE: usize = std::mem::size_of::<T>();
+}
+
+// EMIT_MIR overwrite_with_const_with_params.size_of.ConstProp.diff
+fn size_of<T>() -> usize {
+ // CHECK-LABEL: fn size_of(
+ // CHECK: _1 = const 0_usize;
+ // CHECK-NEXT: _1 = const _;
+ // CHECK-NEXT: _0 = _1;
+ let mut a = 0;
+ a = SizeOfConst::<T>::SIZE;
+ a
+}
+
+fn main() {
+ assert_eq!(size_of::<u32>(), std::mem::size_of::<u32>());
+}
diff --git a/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff
new file mode 100644
index 000000000..ad8318832
--- /dev/null
+++ b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff
@@ -0,0 +1,20 @@
+- // MIR for `size_of` before ConstProp
++ // MIR for `size_of` after ConstProp
+
+ fn size_of() -> usize {
+ let mut _0: usize;
+ let mut _1: usize;
+ scope 1 {
+ debug a => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const 0_usize;
+ _1 = const _;
+ _0 = _1;
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff
new file mode 100644
index 000000000..bd1de7476
--- /dev/null
+++ b/tests/mir-opt/const_prop/pointer_expose_address.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/pointer_expose_address.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff
new file mode 100644
index 000000000..850b743fe
--- /dev/null
+++ b/tests/mir-opt/const_prop/pointer_expose_address.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/pointer_expose_address.rs b/tests/mir-opt/const_prop/pointer_expose_address.rs
new file mode 100644
index 000000000..631aac901
--- /dev/null
+++ b/tests/mir-opt/const_prop/pointer_expose_address.rs
@@ -0,0 +1,18 @@
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// unit-test: ConstProp
+
+#[inline(never)]
+fn read(_: usize) { }
+
+// EMIT_MIR pointer_expose_address.main.ConstProp.diff
+fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: [[ptr:_.*]] = const _;
+ // CHECK: [[ref:_.*]] = &raw const (*[[ptr]]);
+ // CHECK: [[x:_.*]] = move [[ref]] as usize (PointerExposeAddress);
+ // CHECK: [[arg:_.*]] = [[x]];
+ // CHECK: = read(move [[arg]])
+ const FOO: &i32 = &1;
+ let x = FOO as *const i32 as usize;
+ read(x);
+}
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..e193c82d2 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,47 +2,41 @@
+ // 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 {ALLOC0: &u8};
+- _2 = (*_3);
++ _2 = const 2_u8;
+ StorageLive(_4);
+ StorageLive(_5);
+ _5 = const {ALLOC0: &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;
}
}
- alloc1 (static: FOO, size: 1, align: 1) {
+ ALLOC0 (static: FOO, size: 1, align: 1) {
02 │ .
}
diff --git a/tests/mir-opt/const_prop/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs
index fb8f9fe99..0fa18dd10 100644
--- a/tests/mir-opt/const_prop/read_immutable_static.rs
+++ b/tests/mir-opt/const_prop/read_immutable_static.rs
@@ -4,5 +4,8 @@ static FOO: u8 = 2;
// EMIT_MIR read_immutable_static.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: [[x]] = const 4_u8;
let x = FOO + FOO;
}
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..a54ae8d2f 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,25 @@
+ // 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;
+ scope 1 {
+ debug a => _1;
+ }
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);
+ _0 = const ();
+ StorageDead(_1);
+ return;
}
}
diff --git a/tests/mir-opt/const_prop/ref_deref.rs b/tests/mir-opt/const_prop/ref_deref.rs
index 76e56916a..5bceae749 100644
--- a/tests/mir-opt/const_prop/ref_deref.rs
+++ b/tests/mir-opt/const_prop/ref_deref.rs
@@ -1,6 +1,9 @@
// unit-test: ConstProp
-// EMIT_MIR ref_deref.main.ConstProp.diff
+// EMIT_MIR ref_deref.main.ConstProp.diff
fn main() {
- *(&4);
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: [[a]] = (*{{_.*}});
+ let a = *(&4);
}
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..05a4e1774 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,25 @@
+ // 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);
+ scope 1 {
+ debug a => _1;
+ }
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);
+ _0 = const ();
+ StorageDead(_1);
+ return;
}
}
diff --git a/tests/mir-opt/const_prop/ref_deref_project.rs b/tests/mir-opt/const_prop/ref_deref_project.rs
index 04fc7f8da..4b5c67303 100644
--- a/tests/mir-opt/const_prop/ref_deref_project.rs
+++ b/tests/mir-opt/const_prop/ref_deref_project.rs
@@ -1,6 +1,10 @@
+// This does not currently propagate (#67862)
// unit-test: ConstProp
-// EMIT_MIR ref_deref_project.main.ConstProp.diff
+// EMIT_MIR ref_deref_project.main.ConstProp.diff
fn main() {
- *(&(4, 5).1); // This does not currently propagate (#67862)
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: [[a]] = (*{{_.*}});
+ let a = *(&(4, 5).1);
}
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/reify_fn_ptr.rs b/tests/mir-opt/const_prop/reify_fn_ptr.rs
index 5f6382066..33fdd4142 100644
--- a/tests/mir-opt/const_prop/reify_fn_ptr.rs
+++ b/tests/mir-opt/const_prop/reify_fn_ptr.rs
@@ -2,5 +2,9 @@
// EMIT_MIR reify_fn_ptr.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: [[ptr:_.*]] = main as fn() (PointerCoercion(ReifyFnPointer));
+ // CHECK: [[addr:_.*]] = move [[ptr]] as usize (PointerExposeAddress);
+ // CHECK: [[back:_.*]] = move [[addr]] as *const fn() (PointerFromExposedAddress);
let _ = main as usize as *const fn();
}
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..a55bd029e
--- /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 {}", const 8_usize, const 2_usize) -> [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..d49ef2e01
--- /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 {}", const 8_usize, const 2_usize) -> [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..a55bd029e
--- /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 {}", const 8_usize, const 2_usize) -> [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..d49ef2e01
--- /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 {}", const 8_usize, const 2_usize) -> [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..9f688bbb5 100644
--- a/tests/mir-opt/const_prop/repeat.rs
+++ b/tests/mir-opt/const_prop/repeat.rs
@@ -1,9 +1,11 @@
// unit-test: ConstProp
-// ignore-wasm32 compiled with panic=abort by default
-// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR repeat.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: [[x]] = const 42_u32;
let x: u32 = [42; 8][2] + 0;
}
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..974a42e50
--- /dev/null
+++ b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff
@@ -0,0 +1,25 @@
+- // 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;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 04 00 00 00 00 __ __ __ │ .....░░░
+ }
+
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..55dbc7002
--- /dev/null
+++ b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff
@@ -0,0 +1,25 @@
+- // 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;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 04 00 00 00 00 __ __ __ │ .....░░░
+ }
+
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..f87c26bb0
--- /dev/null
+++ b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir
@@ -0,0 +1,20 @@
+// 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;
+ }
+}
+
+ALLOC0 (size: 8, align: 4) {
+ 04 00 00 00 00 __ __ __ │ .....░░░
+}
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..33f975913
--- /dev/null
+++ b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir
@@ -0,0 +1,20 @@
+// 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;
+ }
+}
+
+ALLOC0 (size: 8, align: 4) {
+ 04 00 00 00 00 __ __ __ │ .....░░░
+}
diff --git a/tests/mir-opt/const_prop/return_place.rs b/tests/mir-opt/const_prop/return_place.rs
index 0e68309f0..286543abb 100644
--- a/tests/mir-opt/const_prop/return_place.rs
+++ b/tests/mir-opt/const_prop/return_place.rs
@@ -1,10 +1,12 @@
// 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
// EMIT_MIR return_place.add.PreCodegen.before.mir
fn add() -> u32 {
+ // CHECK-LABEL: fn add(
+ // CHECK: _0 = const 4_u32;
2 + 2
}
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..c5c09c8ed
--- /dev/null
+++ b/tests/mir-opt/const_prop/scalar_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;
+ let _2: ();
+ let mut _3: u32;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const 1_u32;
+ StorageLive(_2);
+ StorageLive(_3);
+- _3 = _1;
+- _2 = consume(move _3) -> [return: bb1, unwind unreachable];
++ _3 = const 1_u32;
++ _2 = consume(const 1_u32) -> [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..b256c5676
--- /dev/null
+++ b/tests/mir-opt/const_prop/scalar_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;
+ let _2: ();
+ let mut _3: u32;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const 1_u32;
+ StorageLive(_2);
+ StorageLive(_3);
+- _3 = _1;
+- _2 = consume(move _3) -> [return: bb1, unwind continue];
++ _3 = const 1_u32;
++ _2 = consume(const 1_u32) -> [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..782cd35d4 100644
--- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs
+++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs
@@ -1,7 +1,10 @@
// 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() {
+ // CHECK-LABEL: fn main(
+ // CHECK: = consume(const 1_u32)
let x = 1;
consume(x);
}
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..7d5d036f4
--- /dev/null
+++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff
@@ -0,0 +1,50 @@
+- // 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];
+ scope 1 {
+ debug a => _1;
+ }
+
+ 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 {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = (*_2)[_6];
++ _1 = const 2_u32;
+ StorageDead(_6);
+ StorageDead(_4);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ 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..fa4c5a71b
--- /dev/null
+++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff
@@ -0,0 +1,50 @@
+- // 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];
+ scope 1 {
+ debug a => _1;
+ }
+
+ 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 {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = (*_2)[_6];
++ _1 = const 2_u32;
+ StorageDead(_6);
+ StorageDead(_4);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ 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..7d5d036f4
--- /dev/null
+++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff
@@ -0,0 +1,50 @@
+- // 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];
+ scope 1 {
+ debug a => _1;
+ }
+
+ 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 {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = (*_2)[_6];
++ _1 = const 2_u32;
+ StorageDead(_6);
+ StorageDead(_4);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ 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..fa4c5a71b
--- /dev/null
+++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff
@@ -0,0 +1,50 @@
+- // 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];
+ scope 1 {
+ debug a => _1;
+ }
+
+ 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 {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = (*_2)[_6];
++ _1 = const 2_u32;
+ StorageDead(_6);
+ StorageDead(_4);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs
index 9821d1b1e..0bf442726 100644
--- a/tests/mir-opt/const_prop/slice_len.rs
+++ b/tests/mir-opt/const_prop/slice_len.rs
@@ -1,9 +1,13 @@
-// ignore-wasm32 compiled with panic=abort by default
// unit-test: ConstProp
// compile-flags: -Zmir-enable-passes=+InstSimplify
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR slice_len.main.ConstProp.diff
fn main() {
- (&[1u32, 2, 3] as &[u32])[1];
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: assert(const true,
+ // CHECK: [[a]] = const 2_u32;
+ let a = (&[1u32, 2, 3] as &[u32])[1];
}
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..d1cbaae49 100644
--- a/tests/mir-opt/const_prop/switch_int.rs
+++ b/tests/mir-opt/const_prop/switch_int.rs
@@ -1,12 +1,20 @@
// 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) { }
// EMIT_MIR switch_int.main.ConstProp.diff
// EMIT_MIR switch_int.main.SimplifyConstCondition-after-const-prop.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: bb0: {
+ // CHECK-NOT: switchInt(
+ // CHECK: goto -> [[bb:bb.*]];
+ // CHECK: [[bb]]: {
+ // CHECK-NOT: _0 = foo(const -1_i32)
+ // CHECK: _0 = foo(const 0_i32)
match 1 {
1 => foo(0),
_ => foo(-1),
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.rs b/tests/mir-opt/const_prop/transmute.rs
index 762c42171..99988d059 100644
--- a/tests/mir-opt/const_prop/transmute.rs
+++ b/tests/mir-opt/const_prop/transmute.rs
@@ -7,55 +7,77 @@ use std::mem::transmute;
// EMIT_MIR transmute.less_as_i8.ConstProp.diff
pub fn less_as_i8() -> i8 {
+ // CHECK-LABEL: fn less_as_i8(
+ // CHECK: _0 = const -1_i8;
unsafe { transmute(std::cmp::Ordering::Less) }
}
// EMIT_MIR transmute.from_char.ConstProp.diff
pub fn from_char() -> i32 {
+ // CHECK-LABEL: fn from_char(
+ // CHECK: _0 = const 82_i32;
unsafe { transmute('R') }
}
// EMIT_MIR transmute.valid_char.ConstProp.diff
pub fn valid_char() -> char {
+ // CHECK-LABEL: fn valid_char(
+ // CHECK: _0 = const 'R';
unsafe { transmute(0x52_u32) }
}
// EMIT_MIR transmute.invalid_char.ConstProp.diff
pub unsafe fn invalid_char() -> char {
+ // CHECK-LABEL: fn invalid_char(
+ // CHECK: _0 = const {transmute(0x7fffffff): char};
unsafe { transmute(i32::MAX) }
}
// EMIT_MIR transmute.invalid_bool.ConstProp.diff
pub unsafe fn invalid_bool() -> bool {
+ // CHECK-LABEL: fn invalid_bool(
+ // CHECK: _0 = const {transmute(0xff): bool};
unsafe { transmute(-1_i8) }
}
// EMIT_MIR transmute.undef_union_as_integer.ConstProp.diff
pub unsafe fn undef_union_as_integer() -> u32 {
+ // CHECK-LABEL: fn undef_union_as_integer(
+ // CHECK: _1 = Union32 {
+ // CHECK: _0 = move _1 as u32 (Transmute);
union Union32 { value: u32, unit: () }
unsafe { transmute(Union32 { unit: () }) }
}
// EMIT_MIR transmute.unreachable_direct.ConstProp.diff
pub unsafe fn unreachable_direct() -> ! {
+ // CHECK-LABEL: fn unreachable_direct(
+ // CHECK: [[unit:_.*]] = ();
+ // CHECK: move [[unit]] as Never (Transmute);
let x: Never = unsafe { transmute(()) };
match x {}
}
// EMIT_MIR transmute.unreachable_ref.ConstProp.diff
pub unsafe fn unreachable_ref() -> ! {
+ // CHECK-LABEL: fn unreachable_ref(
+ // CHECK: = const {0x1 as &Never};
let x: &Never = unsafe { transmute(1_usize) };
match *x {}
}
// EMIT_MIR transmute.unreachable_mut.ConstProp.diff
pub unsafe fn unreachable_mut() -> ! {
+ // CHECK-LABEL: fn unreachable_mut(
+ // CHECK: = const {0x1 as &mut Never};
let x: &mut Never = unsafe { transmute(1_usize) };
match *x {}
}
// EMIT_MIR transmute.unreachable_box.ConstProp.diff
pub unsafe fn unreachable_box() -> ! {
+ // CHECK-LABEL: fn unreachable_box(
+ // CHECK: = const Box::<Never>(
let x: Box<Never> = unsafe { transmute(1_usize) };
match *x {}
}
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..16519749b 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,22 @@
+ // 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>;
+ let mut _2: *const 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);
+- _2 = (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never);
++ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
++ _2 = const {0x1 as *const Never};
+ 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..16519749b 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,22 @@
+ // 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>;
+ let mut _2: *const 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);
+- _2 = (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never);
++ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
++ _2 = const {0x1 as *const Never};
+ 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..f19650d5a
--- /dev/null
+++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff
@@ -0,0 +1,45 @@
+- // 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;
+- _2 = consume(move _3) -> [return: bb1, unwind unreachable];
++ _3 = const (1_u32, 2_u32);
++ _2 = consume(const (1_u32, 2_u32)) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
++ }
++
++ ALLOC1 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
++ }
++
++ ALLOC2 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
+ }
+
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..67307c423
--- /dev/null
+++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff
@@ -0,0 +1,45 @@
+- // 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;
+- _2 = consume(move _3) -> [return: bb1, unwind continue];
++ _3 = const (1_u32, 2_u32);
++ _2 = consume(const (1_u32, 2_u32)) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
++ }
++
++ ALLOC1 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
++ }
++
++ ALLOC2 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs
index f342ae270..dfc4a6f3f 100644
--- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs
+++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs
@@ -1,9 +1,11 @@
// 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() {
+ // CHECK-LABEL: fn main(
+ // CHECK: = consume(const (1_u32, 2_u32))
let x = (1, 2);
-
consume(x);
}
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;
}
}
diff --git a/tests/mir-opt/const_prop/while_let_loops.rs b/tests/mir-opt/const_prop/while_let_loops.rs
index 595a94b88..8b2a73438 100644
--- a/tests/mir-opt/const_prop/while_let_loops.rs
+++ b/tests/mir-opt/const_prop/while_let_loops.rs
@@ -2,6 +2,8 @@
// EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff
pub fn change_loop_body() {
+ // CHECK-LABEL: fn change_loop_body(
+ // CHECK: switchInt(const 0_isize)
let mut _x = 0;
while let Some(0u32) = None {
_x = 1;