diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 1b38eeccfad04..6791bc92283fd 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -11,42 +11,59 @@ use rustc_span::symbol::Symbol; use rustc_target::abi::FieldIdx; use rustc_target::spec::abi::Abi; -pub struct InstSimplify; +pub enum InstSimplify { + BeforeUnreachablePropagation, + Final, +} impl<'tcx> MirPass<'tcx> for InstSimplify { + fn name(&self) -> &'static str { + match &self { + InstSimplify::BeforeUnreachablePropagation => { + "InstSimplify-before-unreachable-propagation" + } + InstSimplify::Final => "InstSimplify-final", + } + } + fn is_enabled(&self, sess: &rustc_session::Session) -> bool { sess.mir_opt_level() > 0 } fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - let ctx = InstSimplifyContext { - tcx, - local_decls: &body.local_decls, - param_env: tcx.param_env_reveal_all_normalized(body.source.def_id()), - }; - let preserve_ub_checks = - attr::contains_name(tcx.hir().krate_attrs(), sym::rustc_preserve_ub_checks); - for block in body.basic_blocks.as_mut() { - for statement in block.statements.iter_mut() { - match statement.kind { - StatementKind::Assign(box (_place, ref mut rvalue)) => { - if !preserve_ub_checks { - ctx.simplify_ub_check(&statement.source_info, rvalue); - } - ctx.simplify_bool_cmp(&statement.source_info, rvalue); - ctx.simplify_ref_deref(&statement.source_info, rvalue); - ctx.simplify_len(&statement.source_info, rvalue); - ctx.simplify_cast(rvalue); + inst_simplify(tcx, body); + } +} + +fn inst_simplify<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + let ctx = InstSimplifyContext { + tcx, + local_decls: &body.local_decls, + param_env: tcx.param_env_reveal_all_normalized(body.source.def_id()), + }; + let preserve_ub_checks = + attr::contains_name(tcx.hir().krate_attrs(), sym::rustc_preserve_ub_checks); + for block in body.basic_blocks.as_mut() { + for statement in block.statements.iter_mut() { + match statement.kind { + StatementKind::Assign(box (_place, ref mut rvalue)) => { + if !preserve_ub_checks { + ctx.simplify_ub_check(&statement.source_info, rvalue); } - _ => {} + ctx.simplify_bool_cmp(&statement.source_info, rvalue); + ctx.simplify_ref_deref(&statement.source_info, rvalue); + ctx.simplify_len(&statement.source_info, rvalue); + ctx.simplify_cast(rvalue); } + _ => {} } - - ctx.simplify_primitive_clone(block.terminator.as_mut().unwrap(), &mut block.statements); - ctx.simplify_intrinsic_assert(block.terminator.as_mut().unwrap()); - ctx.simplify_nounwind_call(block.terminator.as_mut().unwrap()); - simplify_duplicate_switch_targets(block.terminator.as_mut().unwrap()); } + + let terminator = block.terminator.as_mut().unwrap(); + ctx.simplify_primitive_clone(terminator, &mut block.statements); + ctx.simplify_intrinsic_assert(terminator); + ctx.simplify_nounwind_call(terminator); + simplify_duplicate_switch_targets(terminator); } } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 15988c0ea6b37..42b38f1f0902f 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -581,6 +581,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &remove_unneeded_drops::RemoveUnneededDrops, // Type instantiation may create uninhabited enums. &uninhabited_enum_branching::UninhabitedEnumBranching, + &instsimplify::InstSimplify::BeforeUnreachablePropagation, &unreachable_prop::UnreachablePropagation, &o1(simplify::SimplifyCfg::AfterUninhabitedEnumBranching), // Inlining may have introduced a lot of redundant code and a large move pattern. @@ -591,9 +592,9 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &ref_prop::ReferencePropagation, &sroa::ScalarReplacementOfAggregates, &match_branches::MatchBranchSimplification, - // inst combine is after MatchBranchSimplification to clean up Ne(_1, false) + // InstSimplify is after MatchBranchSimplification to clean up Ne(_1, false) &multiple_return_terminators::MultipleReturnTerminators, - &instsimplify::InstSimplify, + &instsimplify::InstSimplify::Final, &simplify::SimplifyLocals::BeforeConstProp, &dead_store_elimination::DeadStoreElimination::Initial, &gvn::GVN, diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 4a48f92ec2b43..54ea616693016 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,5 +1,5 @@ //@ unit-test: GVN -//@ compile-flags: -Zmir-enable-passes=+InstSimplify +//@ compile-flags: -Zmir-enable-passes=+InstSimplify-before-unreachable-propagation // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/dataflow-const-prop/slice_len.rs b/tests/mir-opt/dataflow-const-prop/slice_len.rs index 08707779e2c80..0ce18e89589ea 100644 --- a/tests/mir-opt/dataflow-const-prop/slice_len.rs +++ b/tests/mir-opt/dataflow-const-prop/slice_len.rs @@ -1,6 +1,6 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //@ unit-test: DataflowConstProp -//@ compile-flags: -Zmir-enable-passes=+InstSimplify +//@ compile-flags: -Zmir-enable-passes=+InstSimplify-before-unreachable-propagation // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR slice_len.main.DataflowConstProp.diff diff --git a/tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify-before-unreachable-propagation.diff similarity index 80% rename from tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify-before-unreachable-propagation.diff index 5c09963d43344..60055349d90b6 100644 --- a/tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `eq_false` before InstSimplify -+ // MIR for `eq_false` after InstSimplify +- // MIR for `eq_false` before InstSimplify-before-unreachable-propagation ++ // MIR for `eq_false` after InstSimplify-before-unreachable-propagation fn eq_false(_1: bool) -> u32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify-before-unreachable-propagation.diff similarity index 80% rename from tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify-before-unreachable-propagation.diff index a80133b0eb097..ed27b41123aef 100644 --- a/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `eq_true` before InstSimplify -+ // MIR for `eq_true` after InstSimplify +- // MIR for `eq_true` before InstSimplify-before-unreachable-propagation ++ // MIR for `eq_true` after InstSimplify-before-unreachable-propagation fn eq_true(_1: bool) -> u32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify-before-unreachable-propagation.diff similarity index 80% rename from tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify-before-unreachable-propagation.diff index 8235d5263bb1b..209a980d625e3 100644 --- a/tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `false_eq` before InstSimplify -+ // MIR for `false_eq` after InstSimplify +- // MIR for `false_eq` before InstSimplify-before-unreachable-propagation ++ // MIR for `false_eq` after InstSimplify-before-unreachable-propagation fn false_eq(_1: bool) -> u32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify-before-unreachable-propagation.diff similarity index 80% rename from tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify-before-unreachable-propagation.diff index 77d076c6c14e3..057b295bdbad1 100644 --- a/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `false_ne` before InstSimplify -+ // MIR for `false_ne` after InstSimplify +- // MIR for `false_ne` before InstSimplify-before-unreachable-propagation ++ // MIR for `false_ne` after InstSimplify-before-unreachable-propagation fn false_ne(_1: bool) -> u32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify-before-unreachable-propagation.diff similarity index 80% rename from tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify-before-unreachable-propagation.diff index 2362b11297ea6..389f810b6c597 100644 --- a/tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `ne_false` before InstSimplify -+ // MIR for `ne_false` after InstSimplify +- // MIR for `ne_false` before InstSimplify-before-unreachable-propagation ++ // MIR for `ne_false` after InstSimplify-before-unreachable-propagation fn ne_false(_1: bool) -> u32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify-before-unreachable-propagation.diff similarity index 81% rename from tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify-before-unreachable-propagation.diff index 6ccbd2fb7a1f0..b741c17001e0c 100644 --- a/tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `ne_true` before InstSimplify -+ // MIR for `ne_true` after InstSimplify +- // MIR for `ne_true` before InstSimplify-before-unreachable-propagation ++ // MIR for `ne_true` after InstSimplify-before-unreachable-propagation fn ne_true(_1: bool) -> u32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/bool_compare.rs b/tests/mir-opt/instsimplify/bool_compare.rs index 47984edd669f0..8ddad6bca5720 100644 --- a/tests/mir-opt/instsimplify/bool_compare.rs +++ b/tests/mir-opt/instsimplify/bool_compare.rs @@ -1,55 +1,55 @@ -//@ unit-test: InstSimplify +//@ unit-test: InstSimplify-before-unreachable-propagation -// EMIT_MIR bool_compare.eq_true.InstSimplify.diff +// EMIT_MIR bool_compare.eq_true.InstSimplify-before-unreachable-propagation.diff fn eq_true(x: bool) -> u32 { // CHECK-LABEL: fn eq_true( // CHECK-NOT: Eq( if x == true { 0 } else { 1 } } -// EMIT_MIR bool_compare.true_eq.InstSimplify.diff +// EMIT_MIR bool_compare.true_eq.InstSimplify-before-unreachable-propagation.diff fn true_eq(x: bool) -> u32 { // CHECK-LABEL: fn true_eq( // CHECK-NOT: Eq( if true == x { 0 } else { 1 } } -// EMIT_MIR bool_compare.ne_true.InstSimplify.diff +// EMIT_MIR bool_compare.ne_true.InstSimplify-before-unreachable-propagation.diff fn ne_true(x: bool) -> u32 { // CHECK-LABEL: fn ne_true( // CHECK: Not( if x != true { 0 } else { 1 } } -// EMIT_MIR bool_compare.true_ne.InstSimplify.diff +// EMIT_MIR bool_compare.true_ne.InstSimplify-before-unreachable-propagation.diff fn true_ne(x: bool) -> u32 { // CHECK-LABEL: fn true_ne( // CHECK: Not( if true != x { 0 } else { 1 } } -// EMIT_MIR bool_compare.eq_false.InstSimplify.diff +// EMIT_MIR bool_compare.eq_false.InstSimplify-before-unreachable-propagation.diff fn eq_false(x: bool) -> u32 { // CHECK-LABEL: fn eq_false( // CHECK: Not( if x == false { 0 } else { 1 } } -// EMIT_MIR bool_compare.false_eq.InstSimplify.diff +// EMIT_MIR bool_compare.false_eq.InstSimplify-before-unreachable-propagation.diff fn false_eq(x: bool) -> u32 { // CHECK-LABEL: fn false_eq( // CHECK: Not( if false == x { 0 } else { 1 } } -// EMIT_MIR bool_compare.ne_false.InstSimplify.diff +// EMIT_MIR bool_compare.ne_false.InstSimplify-before-unreachable-propagation.diff fn ne_false(x: bool) -> u32 { // CHECK-LABEL: fn ne_false( // CHECK-NOT: Ne( if x != false { 0 } else { 1 } } -// EMIT_MIR bool_compare.false_ne.InstSimplify.diff +// EMIT_MIR bool_compare.false_ne.InstSimplify-before-unreachable-propagation.diff fn false_ne(x: bool) -> u32 { // CHECK-LABEL: fn false_ne( // CHECK-NOT: Ne( diff --git a/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify-before-unreachable-propagation.diff similarity index 80% rename from tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify-before-unreachable-propagation.diff index 18675329a2eed..43887ed1f6dfb 100644 --- a/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `true_eq` before InstSimplify -+ // MIR for `true_eq` after InstSimplify +- // MIR for `true_eq` before InstSimplify-before-unreachable-propagation ++ // MIR for `true_eq` after InstSimplify-before-unreachable-propagation fn true_eq(_1: bool) -> u32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify-before-unreachable-propagation.diff similarity index 81% rename from tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify-before-unreachable-propagation.diff index dc91cf8a5c41e..27620e0dc9d3f 100644 --- a/tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `true_ne` before InstSimplify -+ // MIR for `true_ne` after InstSimplify +- // MIR for `true_ne` before InstSimplify-before-unreachable-propagation ++ // MIR for `true_ne` after InstSimplify-before-unreachable-propagation fn true_ne(_1: bool) -> u32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify-before-unreachable-propagation.diff similarity index 83% rename from tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff rename to tests/mir-opt/instsimplify/casts.redundant.InstSimplify-before-unreachable-propagation.diff index 9e1bce1ee202a..3c582c466c025 100644 --- a/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `redundant` before InstSimplify -+ // MIR for `redundant` after InstSimplify +- // MIR for `redundant` before InstSimplify-before-unreachable-propagation ++ // MIR for `redundant` after InstSimplify-before-unreachable-propagation fn redundant(_1: *const &u8) -> *const &u8 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/casts.roundtrip.InstSimplify.diff b/tests/mir-opt/instsimplify/casts.roundtrip.InstSimplify-before-unreachable-propagation.diff similarity index 80% rename from tests/mir-opt/instsimplify/casts.roundtrip.InstSimplify.diff rename to tests/mir-opt/instsimplify/casts.roundtrip.InstSimplify-before-unreachable-propagation.diff index a6d68cd4e4b8e..11fd47e8bf750 100644 --- a/tests/mir-opt/instsimplify/casts.roundtrip.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/casts.roundtrip.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `roundtrip` before InstSimplify -+ // MIR for `roundtrip` after InstSimplify +- // MIR for `roundtrip` before InstSimplify-before-unreachable-propagation ++ // MIR for `roundtrip` after InstSimplify-before-unreachable-propagation fn roundtrip(_1: *const u8) -> *const u8 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/casts.rs b/tests/mir-opt/instsimplify/casts.rs index adcf325e3f5c2..23da412522204 100644 --- a/tests/mir-opt/instsimplify/casts.rs +++ b/tests/mir-opt/instsimplify/casts.rs @@ -1,4 +1,4 @@ -//@ unit-test: InstSimplify +//@ unit-test: InstSimplify-before-unreachable-propagation //@ compile-flags: -Zinline-mir #![crate_type = "lib"] @@ -7,7 +7,7 @@ fn generic_cast(x: *const T) -> *const U { x as *const U } -// EMIT_MIR casts.redundant.InstSimplify.diff +// EMIT_MIR casts.redundant.InstSimplify-before-unreachable-propagation.diff pub fn redundant<'a, 'b: 'a>(x: *const &'a u8) -> *const &'a u8 { // CHECK-LABEL: fn redundant( // CHECK: inlined generic_cast @@ -15,7 +15,7 @@ pub fn redundant<'a, 'b: 'a>(x: *const &'a u8) -> *const &'a u8 { generic_cast::<&'a u8, &'b u8>(x) as *const &'a u8 } -// EMIT_MIR casts.roundtrip.InstSimplify.diff +// EMIT_MIR casts.roundtrip.InstSimplify-before-unreachable-propagation.diff pub fn roundtrip(x: *const u8) -> *const u8 { // CHECK-LABEL: fn roundtrip( // CHECK: _4 = _1; diff --git a/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-abort.diff b/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify-before-unreachable-propagation.panic-abort.diff similarity index 93% rename from tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-abort.diff rename to tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify-before-unreachable-propagation.panic-abort.diff index 3e7d0ce51e2eb..41dbafb1d22c3 100644 --- a/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-abort.diff +++ b/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify-before-unreachable-propagation.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `norm2` before InstSimplify -+ // MIR for `norm2` after InstSimplify +- // MIR for `norm2` before InstSimplify-before-unreachable-propagation ++ // MIR for `norm2` after InstSimplify-before-unreachable-propagation fn norm2(_1: [f32; 2]) -> f32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-unwind.diff b/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify-before-unreachable-propagation.panic-unwind.diff similarity index 93% rename from tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-unwind.diff rename to tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify-before-unreachable-propagation.panic-unwind.diff index 4833c1089e3c5..80bb394d30f7f 100644 --- a/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify.panic-unwind.diff +++ b/tests/mir-opt/instsimplify/combine_array_len.norm2.InstSimplify-before-unreachable-propagation.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `norm2` before InstSimplify -+ // MIR for `norm2` after InstSimplify +- // MIR for `norm2` before InstSimplify-before-unreachable-propagation ++ // MIR for `norm2` after InstSimplify-before-unreachable-propagation fn norm2(_1: [f32; 2]) -> f32 { debug x => _1; diff --git a/tests/mir-opt/instsimplify/combine_array_len.rs b/tests/mir-opt/instsimplify/combine_array_len.rs index 4b4054a7a2d6b..b09653029a05a 100644 --- a/tests/mir-opt/instsimplify/combine_array_len.rs +++ b/tests/mir-opt/instsimplify/combine_array_len.rs @@ -1,7 +1,7 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -//@ unit-test: InstSimplify +//@ unit-test: InstSimplify-before-unreachable-propagation -// EMIT_MIR combine_array_len.norm2.InstSimplify.diff +// EMIT_MIR combine_array_len.norm2.InstSimplify-before-unreachable-propagation.diff fn norm2(x: [f32; 2]) -> f32 { // CHECK-LABEL: fn norm2( // CHECK-NOT: Len( diff --git a/tests/mir-opt/instsimplify/combine_clone_of_primitives.rs b/tests/mir-opt/instsimplify/combine_clone_of_primitives.rs index d0c85595dbcf8..b7f4715191583 100644 --- a/tests/mir-opt/instsimplify/combine_clone_of_primitives.rs +++ b/tests/mir-opt/instsimplify/combine_clone_of_primitives.rs @@ -1,7 +1,7 @@ -//@ unit-test: InstSimplify +//@ unit-test: InstSimplify-before-unreachable-propagation // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// EMIT_MIR combine_clone_of_primitives.{impl#0}-clone.InstSimplify.diff +// EMIT_MIR combine_clone_of_primitives.{impl#0}-clone.InstSimplify-before-unreachable-propagation.diff #[derive(Clone)] struct MyThing { v: T, diff --git a/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-abort.diff b/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-before-unreachable-propagation.panic-abort.diff similarity index 93% rename from tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-abort.diff rename to tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-before-unreachable-propagation.panic-abort.diff index 48586f8b3349a..102b92f5b44af 100644 --- a/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-abort.diff +++ b/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-before-unreachable-propagation.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `::clone` before InstSimplify -+ // MIR for `::clone` after InstSimplify +- // MIR for `::clone` before InstSimplify-before-unreachable-propagation ++ // MIR for `::clone` after InstSimplify-before-unreachable-propagation fn ::clone(_1: &MyThing) -> MyThing { debug self => _1; diff --git a/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff b/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-before-unreachable-propagation.panic-unwind.diff similarity index 93% rename from tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff rename to tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-before-unreachable-propagation.panic-unwind.diff index a57266e9c1226..4bae76bbbb5c8 100644 --- a/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff +++ b/tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-before-unreachable-propagation.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `::clone` before InstSimplify -+ // MIR for `::clone` after InstSimplify +- // MIR for `::clone` before InstSimplify-before-unreachable-propagation ++ // MIR for `::clone` after InstSimplify-before-unreachable-propagation fn ::clone(_1: &MyThing) -> MyThing { debug self => _1; diff --git a/tests/mir-opt/instsimplify/combine_transmutes.adt_transmutes.InstSimplify.diff b/tests/mir-opt/instsimplify/combine_transmutes.adt_transmutes.InstSimplify-before-unreachable-propagation.diff similarity index 94% rename from tests/mir-opt/instsimplify/combine_transmutes.adt_transmutes.InstSimplify.diff rename to tests/mir-opt/instsimplify/combine_transmutes.adt_transmutes.InstSimplify-before-unreachable-propagation.diff index 17730e66291c1..3a0822e0c7a31 100644 --- a/tests/mir-opt/instsimplify/combine_transmutes.adt_transmutes.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/combine_transmutes.adt_transmutes.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `adt_transmutes` before InstSimplify -+ // MIR for `adt_transmutes` after InstSimplify +- // MIR for `adt_transmutes` before InstSimplify-before-unreachable-propagation ++ // MIR for `adt_transmutes` after InstSimplify-before-unreachable-propagation fn adt_transmutes() -> () { let mut _0: (); diff --git a/tests/mir-opt/instsimplify/combine_transmutes.identity_transmutes.InstSimplify.diff b/tests/mir-opt/instsimplify/combine_transmutes.identity_transmutes.InstSimplify-before-unreachable-propagation.diff similarity index 83% rename from tests/mir-opt/instsimplify/combine_transmutes.identity_transmutes.InstSimplify.diff rename to tests/mir-opt/instsimplify/combine_transmutes.identity_transmutes.InstSimplify-before-unreachable-propagation.diff index 58ae5919071af..957867a290e27 100644 --- a/tests/mir-opt/instsimplify/combine_transmutes.identity_transmutes.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/combine_transmutes.identity_transmutes.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `identity_transmutes` before InstSimplify -+ // MIR for `identity_transmutes` after InstSimplify +- // MIR for `identity_transmutes` before InstSimplify-before-unreachable-propagation ++ // MIR for `identity_transmutes` after InstSimplify-before-unreachable-propagation fn identity_transmutes() -> () { let mut _0: (); diff --git a/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify.diff b/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify-before-unreachable-propagation.diff similarity index 78% rename from tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify.diff rename to tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify-before-unreachable-propagation.diff index 8eff802dd3c4b..c8c5d7236a76c 100644 --- a/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `integer_transmutes` before InstSimplify -+ // MIR for `integer_transmutes` after InstSimplify +- // MIR for `integer_transmutes` before InstSimplify-before-unreachable-propagation ++ // MIR for `integer_transmutes` after InstSimplify-before-unreachable-propagation fn integer_transmutes() -> () { let mut _0: (); diff --git a/tests/mir-opt/instsimplify/combine_transmutes.rs b/tests/mir-opt/instsimplify/combine_transmutes.rs index 3707ee17690da..123a144435a46 100644 --- a/tests/mir-opt/instsimplify/combine_transmutes.rs +++ b/tests/mir-opt/instsimplify/combine_transmutes.rs @@ -1,4 +1,4 @@ -//@ unit-test: InstSimplify +//@ unit-test: InstSimplify-before-unreachable-propagation //@ compile-flags: -C panic=abort #![crate_type = "lib"] #![feature(core_intrinsics)] @@ -8,7 +8,7 @@ use std::intrinsics::mir::*; use std::mem::{MaybeUninit, ManuallyDrop, transmute}; -// EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff +// EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify-before-unreachable-propagation.diff pub unsafe fn identity_transmutes() { // CHECK-LABEL: fn identity_transmutes( // CHECK-NOT: as i32 (Transmute); @@ -20,7 +20,7 @@ pub unsafe fn identity_transmutes() { } #[custom_mir(dialect = "runtime", phase = "initial")] -// EMIT_MIR combine_transmutes.integer_transmutes.InstSimplify.diff +// EMIT_MIR combine_transmutes.integer_transmutes.InstSimplify-before-unreachable-propagation.diff pub unsafe fn integer_transmutes() { // CHECK-LABEL: fn integer_transmutes( // CHECK-NOT: _i32 as u32 (Transmute); @@ -44,7 +44,7 @@ pub unsafe fn integer_transmutes() { } } -// EMIT_MIR combine_transmutes.adt_transmutes.InstSimplify.diff +// EMIT_MIR combine_transmutes.adt_transmutes.InstSimplify-before-unreachable-propagation.diff pub unsafe fn adt_transmutes() { // CHECK-LABEL: fn adt_transmutes( // CHECK: as u8 (Transmute); diff --git a/tests/mir-opt/instsimplify/duplicate_switch_targets.assert_zero.InstSimplify.diff b/tests/mir-opt/instsimplify/duplicate_switch_targets.assert_zero.InstSimplify-before-unreachable-propagation.diff similarity index 66% rename from tests/mir-opt/instsimplify/duplicate_switch_targets.assert_zero.InstSimplify.diff rename to tests/mir-opt/instsimplify/duplicate_switch_targets.assert_zero.InstSimplify-before-unreachable-propagation.diff index e2b45c882d6f3..04a9a81c249fe 100644 --- a/tests/mir-opt/instsimplify/duplicate_switch_targets.assert_zero.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/duplicate_switch_targets.assert_zero.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `assert_zero` before InstSimplify -+ // MIR for `assert_zero` after InstSimplify +- // MIR for `assert_zero` before InstSimplify-before-unreachable-propagation ++ // MIR for `assert_zero` after InstSimplify-before-unreachable-propagation fn assert_zero(_1: u8) -> u8 { let mut _0: u8; diff --git a/tests/mir-opt/instsimplify/duplicate_switch_targets.rs b/tests/mir-opt/instsimplify/duplicate_switch_targets.rs index fd09d632a4f04..9f2c6685884a3 100644 --- a/tests/mir-opt/instsimplify/duplicate_switch_targets.rs +++ b/tests/mir-opt/instsimplify/duplicate_switch_targets.rs @@ -1,11 +1,11 @@ -//@ unit-test: InstSimplify +//@ unit-test: InstSimplify-before-unreachable-propagation #![feature(custom_mir, core_intrinsics)] #![crate_type = "lib"] use std::intrinsics::mir::*; -// EMIT_MIR duplicate_switch_targets.assert_zero.InstSimplify.diff +// EMIT_MIR duplicate_switch_targets.assert_zero.InstSimplify-before-unreachable-propagation.diff #[custom_mir(dialect = "runtime", phase = "post-cleanup")] pub unsafe fn assert_zero(x: u8) -> u8 { // CHECK-LABEL: fn assert_zero( diff --git a/tests/mir-opt/instsimplify/intrinsic_asserts.generic.InstSimplify.diff b/tests/mir-opt/instsimplify/intrinsic_asserts.generic.InstSimplify-before-unreachable-propagation.diff similarity index 81% rename from tests/mir-opt/instsimplify/intrinsic_asserts.generic.InstSimplify.diff rename to tests/mir-opt/instsimplify/intrinsic_asserts.generic.InstSimplify-before-unreachable-propagation.diff index 2ecacb5e39f47..3b48bb00163bb 100644 --- a/tests/mir-opt/instsimplify/intrinsic_asserts.generic.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.generic.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `generic` before InstSimplify -+ // MIR for `generic` after InstSimplify +- // MIR for `generic` before InstSimplify-before-unreachable-propagation ++ // MIR for `generic` after InstSimplify-before-unreachable-propagation fn generic() -> () { let mut _0: (); diff --git a/tests/mir-opt/instsimplify/intrinsic_asserts.generic_ref.InstSimplify.diff b/tests/mir-opt/instsimplify/intrinsic_asserts.generic_ref.InstSimplify-before-unreachable-propagation.diff similarity index 66% rename from tests/mir-opt/instsimplify/intrinsic_asserts.generic_ref.InstSimplify.diff rename to tests/mir-opt/instsimplify/intrinsic_asserts.generic_ref.InstSimplify-before-unreachable-propagation.diff index d29af0945f7dc..32c6bd7cf279e 100644 --- a/tests/mir-opt/instsimplify/intrinsic_asserts.generic_ref.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.generic_ref.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `generic_ref` before InstSimplify -+ // MIR for `generic_ref` after InstSimplify +- // MIR for `generic_ref` before InstSimplify-before-unreachable-propagation ++ // MIR for `generic_ref` after InstSimplify-before-unreachable-propagation fn generic_ref() -> () { let mut _0: (); diff --git a/tests/mir-opt/instsimplify/intrinsic_asserts.panics.InstSimplify.diff b/tests/mir-opt/instsimplify/intrinsic_asserts.panics.InstSimplify-before-unreachable-propagation.diff similarity index 85% rename from tests/mir-opt/instsimplify/intrinsic_asserts.panics.InstSimplify.diff rename to tests/mir-opt/instsimplify/intrinsic_asserts.panics.InstSimplify-before-unreachable-propagation.diff index 1be386acfccab..5b4862d30009d 100644 --- a/tests/mir-opt/instsimplify/intrinsic_asserts.panics.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.panics.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `panics` before InstSimplify -+ // MIR for `panics` after InstSimplify +- // MIR for `panics` before InstSimplify-before-unreachable-propagation ++ // MIR for `panics` after InstSimplify-before-unreachable-propagation fn panics() -> () { let mut _0: (); diff --git a/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify.diff b/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify-before-unreachable-propagation.diff similarity index 82% rename from tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify.diff rename to tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify-before-unreachable-propagation.diff index f2e6978384205..51aa8b72e71a7 100644 --- a/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `removable` before InstSimplify -+ // MIR for `removable` after InstSimplify +- // MIR for `removable` before InstSimplify-before-unreachable-propagation ++ // MIR for `removable` after InstSimplify-before-unreachable-propagation fn removable() -> () { let mut _0: (); diff --git a/tests/mir-opt/instsimplify/intrinsic_asserts.rs b/tests/mir-opt/instsimplify/intrinsic_asserts.rs index c14b1ac5a218e..9a8e3f04b995c 100644 --- a/tests/mir-opt/instsimplify/intrinsic_asserts.rs +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.rs @@ -1,10 +1,10 @@ -//@ unit-test: InstSimplify +//@ unit-test: InstSimplify-before-unreachable-propagation #![crate_type = "lib"] #![feature(core_intrinsics)] // All these assertions pass, so all the intrinsic calls should be deleted. -// EMIT_MIR intrinsic_asserts.removable.InstSimplify.diff +// EMIT_MIR intrinsic_asserts.removable.InstSimplify-before-unreachable-propagation.diff pub fn removable() { // CHECK-LABEL: fn removable( // CHECK-NOT: assert_inhabited @@ -18,7 +18,7 @@ pub fn removable() { enum Never {} // These assertions all diverge, so their target blocks should become None. -// EMIT_MIR intrinsic_asserts.panics.InstSimplify.diff +// EMIT_MIR intrinsic_asserts.panics.InstSimplify-before-unreachable-propagation.diff pub fn panics() { // CHECK-LABEL: fn panics( // CHECK: assert_inhabited::() -> unwind @@ -30,7 +30,7 @@ pub fn panics() { } // Whether or not these asserts pass isn't known, so they shouldn't be modified. -// EMIT_MIR intrinsic_asserts.generic.InstSimplify.diff +// EMIT_MIR intrinsic_asserts.generic.InstSimplify-before-unreachable-propagation.diff pub fn generic() { // CHECK-LABEL: fn generic( // CHECK: assert_inhabited::() -> [return: @@ -42,7 +42,7 @@ pub fn generic() { } // Whether or not these asserts pass isn't known, so they shouldn't be modified. -// EMIT_MIR intrinsic_asserts.generic_ref.InstSimplify.diff +// EMIT_MIR intrinsic_asserts.generic_ref.InstSimplify-before-unreachable-propagation.diff pub fn generic_ref() { // CHECK-LABEL: fn generic_ref( // CHECK: assert_mem_uninitialized_valid::<&T>() -> [return: diff --git a/tests/mir-opt/instsimplify/ub_check.rs b/tests/mir-opt/instsimplify/ub_check.rs index fc568abcd601c..76401c9acdd6a 100644 --- a/tests/mir-opt/instsimplify/ub_check.rs +++ b/tests/mir-opt/instsimplify/ub_check.rs @@ -1,7 +1,7 @@ -//@ unit-test: InstSimplify +//@ unit-test: InstSimplify-before-unreachable-propagation //@ compile-flags: -Cdebug-assertions=no -Zinline-mir -// EMIT_MIR ub_check.unwrap_unchecked.InstSimplify.diff +// EMIT_MIR ub_check.unwrap_unchecked.InstSimplify-before-unreachable-propagation.diff pub fn unwrap_unchecked(x: Option) -> i32 { // CHECK-LABEL: fn unwrap_unchecked( // CHECK-NOT: UbChecks() diff --git a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-before-unreachable-propagation.diff similarity index 90% rename from tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff rename to tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-before-unreachable-propagation.diff index f3402fde05b90..7ee9821f6feed 100644 --- a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `unwrap_unchecked` before InstSimplify -+ // MIR for `unwrap_unchecked` after InstSimplify +- // MIR for `unwrap_unchecked` before InstSimplify-before-unreachable-propagation ++ // MIR for `unwrap_unchecked` after InstSimplify-before-unreachable-propagation fn unwrap_unchecked(_1: Option) -> i32 { debug x => _1; diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff index b2539f391d1a5..43a4acca20f54 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff @@ -5,7 +5,7 @@ debug x => _1; let mut _0: (); let _2: &[T]; - let mut _3: &[T; 3]; + let _3: &[T; 3]; let _4: [T; 3]; let mut _5: usize; let mut _6: bool; @@ -23,12 +23,10 @@ } bb0: { - StorageLive(_3); StorageLive(_4); _4 = [_1, _1, _1]; _3 = &_4; - _2 = move _3 as &[T] (PointerCoercion(Unsize)); - StorageDead(_3); + _2 = _3 as &[T] (PointerCoercion(Unsize)); _5 = const 3_usize; _6 = const true; goto -> bb2; diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff index ff7f12c093ce4..7c0148c1a274b 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff @@ -5,7 +5,7 @@ debug x => _1; let mut _0: (); let _2: &[T]; - let mut _3: &[T; 3]; + let _3: &[T; 3]; let _4: [T; 3]; let mut _5: usize; let mut _6: bool; @@ -23,12 +23,10 @@ } bb0: { - StorageLive(_3); StorageLive(_4); _4 = [_1, _1, _1]; _3 = &_4; - _2 = move _3 as &[T] (PointerCoercion(Unsize)); - StorageDead(_3); + _2 = _3 as &[T] (PointerCoercion(Unsize)); _5 = const 3_usize; _6 = const true; goto -> bb2; diff --git a/tests/mir-opt/issue_78192.f.InstSimplify.diff b/tests/mir-opt/issue_78192.f.InstSimplify-before-unreachable-propagation.diff similarity index 79% rename from tests/mir-opt/issue_78192.f.InstSimplify.diff rename to tests/mir-opt/issue_78192.f.InstSimplify-before-unreachable-propagation.diff index 10e3dd2036202..82d259d36703b 100644 --- a/tests/mir-opt/issue_78192.f.InstSimplify.diff +++ b/tests/mir-opt/issue_78192.f.InstSimplify-before-unreachable-propagation.diff @@ -1,5 +1,5 @@ -- // MIR for `f` before InstSimplify -+ // MIR for `f` after InstSimplify +- // MIR for `f` before InstSimplify-before-unreachable-propagation ++ // MIR for `f` after InstSimplify-before-unreachable-propagation fn f(_1: &T) -> *const T { debug a => _1; diff --git a/tests/mir-opt/issue_78192.rs b/tests/mir-opt/issue_78192.rs index 857b1dec951e5..cfdce2bf6af45 100644 --- a/tests/mir-opt/issue_78192.rs +++ b/tests/mir-opt/issue_78192.rs @@ -9,4 +9,4 @@ fn main() { f(&2); } -// EMIT_MIR issue_78192.f.InstSimplify.diff +// EMIT_MIR issue_78192.f.InstSimplify-before-unreachable-propagation.diff diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index 2865b829e3e54..9f908f23d315c 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -28,7 +28,7 @@ let mut _14: !; let _15: &str; let mut _16: &dyn std::fmt::Debug; - let mut _17: &std::alloc::AllocError; + let _17: &std::alloc::AllocError; scope 7 { debug t => _5; } @@ -96,6 +96,7 @@ StorageDead(_7); StorageLive(_12); StorageLive(_15); + StorageLive(_17); _12 = discriminant(_6); switchInt(move _12) -> [0: bb6, 1: bb5, otherwise: bb1]; } @@ -103,15 +104,14 @@ bb5: { _15 = const "called `Result::unwrap()` on an `Err` value"; StorageLive(_16); - StorageLive(_17); _17 = &_13; - _16 = move _17 as &dyn std::fmt::Debug (PointerCoercion(Unsize)); - StorageDead(_17); + _16 = _17 as &dyn std::fmt::Debug (PointerCoercion(Unsize)); _14 = result::unwrap_failed(move _15, move _16) -> unwind unreachable; } bb6: { _5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>); + StorageDead(_17); StorageDead(_15); StorageDead(_12); StorageDead(_6); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index 44964392dd658..ca31a6dc08e09 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -28,7 +28,7 @@ let mut _14: !; let _15: &str; let mut _16: &dyn std::fmt::Debug; - let mut _17: &std::alloc::AllocError; + let _17: &std::alloc::AllocError; scope 7 { debug t => _5; } @@ -96,6 +96,7 @@ StorageDead(_7); StorageLive(_12); StorageLive(_15); + StorageLive(_17); _12 = discriminant(_6); switchInt(move _12) -> [0: bb6, 1: bb5, otherwise: bb1]; } @@ -103,15 +104,14 @@ bb5: { _15 = const "called `Result::unwrap()` on an `Err` value"; StorageLive(_16); - StorageLive(_17); _17 = &_13; - _16 = move _17 as &dyn std::fmt::Debug (PointerCoercion(Unsize)); - StorageDead(_17); + _16 = _17 as &dyn std::fmt::Debug (PointerCoercion(Unsize)); _14 = result::unwrap_failed(move _15, move _16) -> unwind unreachable; } bb6: { _5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>); + StorageDead(_17); StorageDead(_15); StorageDead(_12); StorageDead(_6); diff --git a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir index b800a1be22bae..63bda0580140e 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -33,13 +33,11 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { bb2: { StorageLive(_6); - StorageLive(_5); _5 = &mut _4; _6 = , impl Fn(T) -> U> as Iterator>::next(move _5) -> [return: bb3, unwind: bb9]; } bb3: { - StorageDead(_5); _7 = discriminant(_6); switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb8]; } diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir index cb29473d7627f..e537dd6a28ef8 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -30,13 +30,11 @@ fn vec_move(_1: Vec) -> () { bb2: { StorageLive(_5); - StorageLive(_4); _4 = &mut _3; _5 = as Iterator>::next(move _4) -> [return: bb3, unwind: bb9]; } bb3: { - StorageDead(_4); _6 = discriminant(_5); switchInt(move _6) -> [0: bb4, 1: bb6, otherwise: bb8]; } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff index 5f2a096bb1f76..4a18ac7cf7c3f 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff @@ -37,7 +37,7 @@ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; StorageLive(_5); _5 = const 3_usize; - _6 = Len(_4); + _6 = const 6_usize; _7 = Lt(_5, _6); assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind unreachable]; } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff index a49546f158c8b..42c36332cc26c 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff @@ -37,7 +37,7 @@ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; StorageLive(_5); _5 = const 3_usize; - _6 = Len(_4); + _6 = const 6_usize; _7 = Lt(_5, _6); assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff index 5f2a096bb1f76..4a18ac7cf7c3f 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff @@ -37,7 +37,7 @@ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; StorageLive(_5); _5 = const 3_usize; - _6 = Len(_4); + _6 = const 6_usize; _7 = Lt(_5, _6); assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind unreachable]; } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff index a49546f158c8b..42c36332cc26c 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff @@ -37,7 +37,7 @@ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; StorageLive(_5); _5 = const 3_usize; - _6 = Len(_4); + _6 = const 6_usize; _7 = Lt(_5, _6); assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir index 0836600cb6e6d..1f82fb36ccee8 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir @@ -40,13 +40,11 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); - StorageLive(_6); _6 = &mut _5; _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind unreachable]; } bb2: { - StorageDead(_6); _8 = discriminant(_7); switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb7]; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir index 8c1794de5244c..d44380e82a6a8 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir @@ -40,13 +40,11 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); - StorageLive(_6); _6 = &mut _5; _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind: bb8]; } bb2: { - StorageDead(_6); _8 = discriminant(_7); switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb7]; } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index bcc540ae6fc04..9486b077938d3 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -14,6 +14,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> } bb0: { + StorageLive(_4); StorageLive(_3); _3 = &raw mut (*_1); _4 = as SliceIndex<[u32]>>::get_unchecked_mut(move _2, move _3) -> [return: bb1, unwind unreachable]; @@ -22,6 +23,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> bb1: { StorageDead(_3); _0 = &mut (*_4); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index 1fe7da7d2fdcc..b9f84cc5fde64 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -14,6 +14,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> } bb0: { + StorageLive(_4); StorageLive(_3); _3 = &raw mut (*_1); _4 = as SliceIndex<[u32]>>::get_unchecked_mut(move _2, move _3) -> [return: bb1, unwind continue]; @@ -22,6 +23,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> bb1: { StorageDead(_3); _0 = &mut (*_4); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index f698e15d302b4..c0dc7868481bf 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -141,13 +141,11 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb4: { StorageLive(_17); - StorageLive(_16); _16 = &mut _15; _17 = > as Iterator>::next(move _16) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_16); _18 = discriminant(_17); switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index eae9f5909e62d..6568bd070f003 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -141,13 +141,11 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb4: { StorageLive(_17); - StorageLive(_16); _16 = &mut _15; _17 = > as Iterator>::next(move _16) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_16); _18 = discriminant(_17); switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index 158ae0de89047..01767271905d8 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -129,13 +129,11 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb4: { StorageLive(_16); - StorageLive(_15); _15 = &mut _14; _16 = as Iterator>::next(move _15) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_15); _17 = discriminant(_16); switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index ac9e31a0da879..78954dabfaf9d 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -129,13 +129,11 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb4: { StorageLive(_16); - StorageLive(_15); _15 = &mut _14; _16 = as Iterator>::next(move _15) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_15); _17 = discriminant(_16); switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir index 485dc9179cef0..c76e5315db9f6 100644 --- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir @@ -3,16 +3,14 @@ fn outer(_1: u8) -> u8 { debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15 let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26 - let mut _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 + let _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 scope 1 (inlined inner) { // at $DIR/spans.rs:11:5: 11:14 debug x => _2; // in scope 1 at $DIR/spans.rs:14:14: 14:15 } bb0: { - StorageLive(_2); // scope 0 at $DIR/spans.rs:11:11: 11:13 _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13 _0 = _1; // scope 1 at $DIR/spans.rs:15:5: 15:7 - StorageDead(_2); // scope 0 at $DIR/spans.rs:11:13: 11:14 return; // scope 0 at $DIR/spans.rs:12:2: 12:2 } } diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir index 485dc9179cef0..c76e5315db9f6 100644 --- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir @@ -3,16 +3,14 @@ fn outer(_1: u8) -> u8 { debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15 let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26 - let mut _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 + let _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 scope 1 (inlined inner) { // at $DIR/spans.rs:11:5: 11:14 debug x => _2; // in scope 1 at $DIR/spans.rs:14:14: 14:15 } bb0: { - StorageLive(_2); // scope 0 at $DIR/spans.rs:11:11: 11:13 _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13 _0 = _1; // scope 1 at $DIR/spans.rs:15:5: 15:7 - StorageDead(_2); // scope 0 at $DIR/spans.rs:11:13: 11:14 return; // scope 0 at $DIR/spans.rs:12:2: 12:2 } }