From 17c8a4ebfab93934d269153685c7350313c032d6 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Fri, 9 Aug 2024 23:52:28 -0700 Subject: [PATCH 1/2] Add a mir-opt test for dropping parameters --- ...nline_drop.drop_both_arguments.Inline.diff | 30 +++++++++++++++++++ tests/mir-opt/inline/inline_drop.rs | 24 +++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/mir-opt/inline/inline_drop.drop_both_arguments.Inline.diff create mode 100644 tests/mir-opt/inline/inline_drop.rs diff --git a/tests/mir-opt/inline/inline_drop.drop_both_arguments.Inline.diff b/tests/mir-opt/inline/inline_drop.drop_both_arguments.Inline.diff new file mode 100644 index 0000000000000..53db1a4b562e0 --- /dev/null +++ b/tests/mir-opt/inline/inline_drop.drop_both_arguments.Inline.diff @@ -0,0 +1,30 @@ +- // MIR for `drop_both_arguments` before Inline ++ // MIR for `drop_both_arguments` after Inline + + fn drop_both_arguments(_1: CallThingOnDrop, _2: CallThingOnDrop) -> () { + debug _a => _1; + debug _b => _2; + let mut _0: (); + + bb0: { + _0 = const (); + drop(_2) -> [return: bb1, unwind: bb3]; + } + + bb1: { + drop(_1) -> [return: bb2, unwind: bb4]; + } + + bb2: { + return; + } + + bb3 (cleanup): { + drop(_1) -> [return: bb4, unwind terminate(cleanup)]; + } + + bb4 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/inline/inline_drop.rs b/tests/mir-opt/inline/inline_drop.rs new file mode 100644 index 0000000000000..3b64fb325bb92 --- /dev/null +++ b/tests/mir-opt/inline/inline_drop.rs @@ -0,0 +1,24 @@ +// Test for inlining with an indirect destination place. +// +//@ test-mir-pass: Inline +//@ edition: 2021 +//@ needs-unwind +#![crate_type = "lib"] + +#[inline(never)] +fn thing() {} + +struct CallThingOnDrop; + +impl Drop for CallThingOnDrop { + #[inline] + fn drop(&mut self) { + thing(); + } +} + +// EMIT_MIR inline_drop.drop_both_arguments.Inline.diff +pub fn drop_both_arguments(_a: CallThingOnDrop, _b: CallThingOnDrop) { + // CHECK: drop(_2) + // CHECK: drop(_1) +} From e08aae30867a69d0876056a496447b69902a996d Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 10 Aug 2024 01:32:22 -0700 Subject: [PATCH 2/2] Allow inlining all the drops --- compiler/rustc_mir_transform/src/inline.rs | 90 ++++++- .../src/remove_unneeded_drops.rs | 29 ++- tests/codegen/drop-in-place-noalias.rs | 4 +- tests/codegen/drop.rs | 5 +- .../issue-112509-slice-get-andthen-get.rs | 2 +- ...n.DataflowConstProp.32bit.panic-abort.diff | 79 +++--- ....DataflowConstProp.32bit.panic-unwind.diff | 85 +++--- ...n.DataflowConstProp.64bit.panic-abort.diff | 79 +++--- ....DataflowConstProp.64bit.panic-unwind.diff | 85 +++--- ...oxed_slice.main.GVN.32bit.panic-abort.diff | 97 +++---- ...xed_slice.main.GVN.32bit.panic-unwind.diff | 103 ++++---- ...oxed_slice.main.GVN.64bit.panic-abort.diff | 97 +++---- ...xed_slice.main.GVN.64bit.panic-unwind.diff | 103 ++++---- ...in.DestinationPropagation.panic-abort.diff | 2 + ...n.DestinationPropagation.panic-unwind.diff | 2 + .../asm_unwind.main.Inline.panic-unwind.diff | 21 +- ...trivial_bound.foo.Inline.panic-unwind.diff | 6 +- .../inline/cycle.f.Inline.panic-abort.diff | 6 +- .../inline/cycle.f.Inline.panic-unwind.diff | 6 +- .../inline/cycle.main.Inline.panic-abort.diff | 17 +- .../cycle.main.Inline.panic-unwind.diff | 21 +- tests/mir-opt/inline/cycle.rs | 2 + ...ric_rust_call.call.Inline.panic-abort.diff | 6 +- ...ic_rust_call.call.Inline.panic-unwind.diff | 6 +- ...inline_box_fn.call.Inline.panic-abort.diff | 6 +- ...nline_box_fn.call.Inline.panic-unwind.diff | 6 +- ...ine_coroutine.main.Inline.panic-abort.diff | 107 +++++--- ...ne_coroutine.main.Inline.panic-unwind.diff | 136 ++++++---- ...inline_diverging.h.Inline.panic-abort.diff | 11 +- ...nline_diverging.h.Inline.panic-unwind.diff | 23 +- tests/mir-opt/inline/inline_diverging.rs | 3 + ...nline_drop.drop_both_arguments.Inline.diff | 62 ++++- tests/mir-opt/inline/inline_drop.rs | 4 +- .../mir-opt/inline/inline_instruction_set.rs | 4 + .../inline_shims.drop.Inline.panic-abort.diff | 38 +-- .../issue_78442.bar.Inline.panic-abort.diff | 5 +- .../issue_78442.bar.Inline.panic-unwind.diff | 5 +- .../unsized_argument.caller.Inline.diff | 6 +- ...y.run2-{closure#0}.Inline.panic-abort.diff | 215 ++++++++-------- ....run2-{closure#0}.Inline.panic-unwind.diff | 243 +++++++++--------- .../loops.filter_mapped.PreCodegen.after.mir | 15 +- .../loops.mapped.PreCodegen.after.mir | 53 ++-- .../loops.vec_move.PreCodegen.after.mir | 19 +- ...ward_loop.PreCodegen.after.panic-abort.mir | 55 ++-- ...ard_loop.PreCodegen.after.panic-unwind.mir | 55 ++-- ...sive_loop.PreCodegen.after.panic-abort.mir | 31 ++- ...ive_loop.PreCodegen.after.panic-unwind.mir | 31 ++- ...map.ezmap.PreCodegen.after.panic-abort.mir | 57 ++++ ...p.ezmap.PreCodegen.after.panic-unwind.mir} | 31 ++- .../mir-opt/pre-codegen/simple_option_map.rs | 1 + ...ated_loop.PreCodegen.after.panic-abort.mir | 77 +++--- ...ted_loop.PreCodegen.after.panic-unwind.mir | 37 +-- ...ward_loop.PreCodegen.after.panic-abort.mir | 31 ++- ...ard_loop.PreCodegen.after.panic-unwind.mir | 31 ++- ...ange_loop.PreCodegen.after.panic-abort.mir | 73 +++--- ...nge_loop.PreCodegen.after.panic-unwind.mir | 73 +++--- ...erse_loop.PreCodegen.after.panic-abort.mir | 31 ++- ...rse_loop.PreCodegen.after.panic-unwind.mir | 31 ++- ...neric.RemoveUnneededDrops.panic-abort.diff | 9 +- ...eric.RemoveUnneededDrops.panic-unwind.diff | 9 +- ...t_opt.RemoveUnneededDrops.panic-abort.diff | 9 +- ..._opt.RemoveUnneededDrops.panic-unwind.diff | 9 +- ...s.opt.RemoveUnneededDrops.panic-abort.diff | 19 +- ....opt.RemoveUnneededDrops.panic-unwind.diff | 19 +- ..._copy.RemoveUnneededDrops.panic-abort.diff | 19 +- ...copy.RemoveUnneededDrops.panic-unwind.diff | 19 +- ...place.RemoveUnneededDrops.panic-abort.diff | 22 ++ ...lace.RemoveUnneededDrops.panic-unwind.diff | 22 ++ tests/mir-opt/remove_unneeded_drops.rs | 6 + 69 files changed, 1618 insertions(+), 1103 deletions(-) create mode 100644 tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.panic-abort.mir rename tests/mir-opt/pre-codegen/{simple_option_map.ezmap.PreCodegen.after.mir => simple_option_map.ezmap.PreCodegen.after.panic-unwind.mir} (51%) create mode 100644 tests/mir-opt/remove_unneeded_drops.opt_in_place.RemoveUnneededDrops.panic-abort.diff create mode 100644 tests/mir-opt/remove_unneeded_drops.opt_in_place.RemoveUnneededDrops.panic-unwind.diff diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 324ddc5e799d5..5cfc5165ae791 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -13,10 +13,10 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs} use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::{ - self, Instance, InstanceKind, ParamEnv, Ty, TyCtxt, TypeFlags, TypeVisitableExt, + self, GenericArg, Instance, InstanceKind, ParamEnv, Ty, TyCtxt, TypeFlags, TypeVisitableExt, }; use rustc_session::config::{DebugInfo, OptLevel}; -use rustc_span::source_map::Spanned; +use rustc_span::source_map::{dummy_spanned, Spanned}; use rustc_span::sym; use rustc_target::abi::FieldIdx; use rustc_target::spec::abi::Abi; @@ -75,6 +75,87 @@ impl<'tcx> MirPass<'tcx> for Inline { } } +/// Change all the `Drop(place)` terminators to `drop_in_place(&place)` calls. +/// +/// This needs to be done before starting the inlining analysis or else the cycle +/// detection logic will miss things. But it's a waste of time to do the work of +/// adding locals unless we're going to try to inline things, so might as well +/// leave the drop terminators alone in lower optimization levels. +fn lower_drops_to_calls<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, param_env: ParamEnv<'tcx>) { + // I wish this could just be `require_lang_item`, but there are so many + // obnoxious `no_core` tests that I'd have to update to do that. + let Some(drop_in_place_fn) = tcx.lang_items().drop_in_place_fn() else { + error!("No `drop_in_place` function; not even trying to simplify drops!"); + return; + }; + + // We need a unit local to store the "result" of the `drop_in_place` call + let mut unit_local = None; + + // Changing `Drop` to `Call` actually preserves the CFG because + // it keeps the same `target` and the same `unwind` action. + for block in body.basic_blocks.as_mut_preserves_cfg().iter_mut() { + let terminator = block.terminator.as_mut().unwrap(); + let TerminatorKind::Drop { place: dropped_place, target, unwind, replace: _ } = + terminator.kind + else { + continue; + }; + + if block.is_cleanup { + // We don't inline into cleanup blocks, so don't rewrite drops in them either. + continue; + } + + let dropped_ty = dropped_place.ty(&body.local_decls, tcx).ty; + if !dropped_ty.needs_drop(tcx, param_env) { + // Leave it for RemoveUnneededDrops to remove, since that's + // cheaper than doing the work to inline an empty shim. + continue; + } + + if !tcx.consider_optimizing(|| format!("Drop -> drop_in_place on type {dropped_ty:?}")) { + return; + } + + let dropped_operand = if let [PlaceElem::Deref] = **dropped_place.projection + && body.local_decls[dropped_place.local].ty.is_mutable_ptr() + { + Operand::Copy(Place::from(dropped_place.local)) + } else { + let dropped_ty_ptr = Ty::new_mut_ptr(tcx, dropped_ty); + let ptr_local = + body.local_decls.push(LocalDecl::new(dropped_ty_ptr, terminator.source_info.span)); + block.statements.push(Statement { + source_info: terminator.source_info, + kind: StatementKind::Assign(Box::new(( + Place::from(ptr_local), + Rvalue::AddressOf(Mutability::Mut, dropped_place), + ))), + }); + Operand::Move(Place::from(ptr_local)) + }; + let unit_local = *unit_local.get_or_insert_with(|| { + let unit_ty = tcx.types.unit; + body.local_decls.push(LocalDecl::new(unit_ty, terminator.source_info.span)) + }); + terminator.kind = TerminatorKind::Call { + func: Operand::function_handle( + tcx, + drop_in_place_fn, + [GenericArg::from(dropped_ty)], + terminator.source_info.span, + ), + args: Box::new([dummy_spanned(dropped_operand)]), + destination: Place::from(unit_local), + target: Some(target), + unwind, + call_source: CallSource::Misc, + fn_span: terminator.source_info.span, + }; + } +} + fn inline<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> bool { let def_id = body.source.def_id().expect_local(); @@ -94,6 +175,7 @@ fn inline<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> bool { let param_env = tcx.param_env_reveal_all_normalized(def_id); let codegen_fn_attrs = tcx.codegen_fn_attrs(def_id); + lower_drops_to_calls(tcx, body, param_env); let mut this = Inliner { tcx, @@ -509,7 +591,9 @@ impl<'tcx> Inliner<'tcx> { return Err("Body is tainted"); } - let mut threshold = if self.caller_is_inline_forwarder { + let mut threshold = if self.caller_is_inline_forwarder + || matches!(callee_body.source.instance, InstanceKind::DropGlue(..)) + { self.tcx.sess.opts.unstable_opts.inline_mir_forwarder_threshold.unwrap_or(30) } else if cross_crate_inlinable { self.tcx.sess.opts.unstable_opts.inline_mir_hint_threshold.unwrap_or(100) diff --git a/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs b/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs index 2778d91e17b99..c8f63fd7a3a6d 100644 --- a/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs +++ b/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs @@ -4,6 +4,7 @@ //! useful because (unlike MIR building) it runs after type checking, so it can make use of //! `Reveal::All` to provide more precise type information. +use rustc_hir::LangItem; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; @@ -21,18 +22,28 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops { for block in body.basic_blocks.as_mut() { let terminator = block.terminator_mut(); - if let TerminatorKind::Drop { place, target, .. } = terminator.kind { - let ty = place.ty(&body.local_decls, tcx); - if ty.ty.needs_drop(tcx, param_env) { - continue; + let (dropped_ty, target) = match terminator.kind { + TerminatorKind::Drop { place, target, .. } => { + (place.ty(&body.local_decls, tcx).ty, target) } - if !tcx.consider_optimizing(|| format!("RemoveUnneededDrops {did:?} ")) { - continue; + TerminatorKind::Call { ref func, target, .. } + if let Some((def_id, generics)) = func.const_fn_def() + && tcx.is_lang_item(def_id, LangItem::DropInPlace) => + { + (generics.type_at(0), target.unwrap()) } - debug!("SUCCESS: replacing `drop` with goto({:?})", target); - terminator.kind = TerminatorKind::Goto { target }; - should_simplify = true; + _ => continue, + }; + + if dropped_ty.needs_drop(tcx, param_env) { + continue; + } + if !tcx.consider_optimizing(|| format!("RemoveUnneededDrops {did:?} ")) { + continue; } + debug!("SUCCESS: replacing `drop` with goto({:?})", target); + terminator.kind = TerminatorKind::Goto { target }; + should_simplify = true; } // if we applied optimizations, we potentially have some cfg to cleanup to diff --git a/tests/codegen/drop-in-place-noalias.rs b/tests/codegen/drop-in-place-noalias.rs index 2dc769df1c92b..a47abf60ac931 100644 --- a/tests/codegen/drop-in-place-noalias.rs +++ b/tests/codegen/drop-in-place-noalias.rs @@ -1,8 +1,10 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -O -C no-prepopulate-passes -Z inline-mir=no // Tests that the compiler can apply `noalias` and other &mut attributes to `drop_in_place`. // Note that non-Unpin types should not get `noalias`, matching &mut behavior. +// Needs to not run MIR inlining or else everything inlines away. + #![crate_type = "lib"] use std::marker::PhantomPinned; diff --git a/tests/codegen/drop.rs b/tests/codegen/drop.rs index b22a8ef27d239..c89ee2c1d9918 100644 --- a/tests/codegen/drop.rs +++ b/tests/codegen/drop.rs @@ -1,5 +1,8 @@ //@ needs-unwind - this test verifies the amount of drop calls when unwinding is used -//@ compile-flags: -C no-prepopulate-passes +//@ compile-flags: -C no-prepopulate-passes -Z inline-mir=no + +// Needs to disable MIR inlining or else some of the calls are directly to +// `::drop` (rather than via `drop_in_place`). #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs b/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs index aee2edd8dfad2..6f981189474b5 100644 --- a/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs +++ b/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs @@ -3,8 +3,8 @@ // CHECK-LABEL: @write_u8_variant_a // CHECK-NEXT: {{.*}}: -// CHECK-NEXT: icmp ugt // CHECK-NEXT: getelementptr +// CHECK-NEXT: icmp ugt // CHECK-NEXT: select i1 {{.+}} null // CHECK-NEXT: insertvalue // CHECK-NEXT: insertvalue diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index 4097e060f4d47..09281c4e3023e 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -5,24 +5,26 @@ let mut _0: (); let _1: A; let mut _2: std::boxed::Box<[bool]>; + let mut _3: *mut A; + let mut _4: (); scope 1 { debug a => _1; } scope 2 (inlined as Default>::default) { - let _3: std::ptr::Unique<[bool]>; - let mut _4: std::ptr::Unique<[bool; 0]>; + let _5: std::ptr::Unique<[bool]>; + let mut _6: std::ptr::Unique<[bool; 0]>; scope 3 { } scope 4 (inlined Unique::<[bool; 0]>::dangling) { - let mut _5: std::ptr::NonNull<[bool; 0]>; + let mut _7: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let _6: *mut [bool; 0]; + let _8: *mut [bool; 0]; scope 6 { scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - let mut _8: bool; - let _9: (); - let mut _10: *mut (); - let mut _11: *const [bool; 0]; + let mut _10: bool; + let _11: (); + let mut _12: *mut (); + let mut _13: *const [bool; 0]; scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -30,7 +32,7 @@ } } scope 7 (inlined dangling_mut::<[bool; 0]>) { - let mut _7: usize; + let mut _9: usize; scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { @@ -39,58 +41,61 @@ } } } + scope 13 (inlined std::ptr::drop_in_place:: - shim(Some(A))) { + } bb0: { StorageLive(_1); StorageLive(_2); - StorageLive(_3); - StorageLive(_9); - StorageLive(_4); StorageLive(_5); + StorageLive(_11); StorageLive(_6); StorageLive(_7); - _7 = const 1_usize; - _6 = const {0x1 as *mut [bool; 0]}; - StorageDead(_7); - StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb4, otherwise: bb2]; + StorageLive(_9); + _9 = const 1_usize; + _8 = const {0x1 as *mut [bool; 0]}; + StorageDead(_9); + StorageLive(_13); + StorageLive(_10); + _10 = UbChecks(); + switchInt(move _10) -> [0: bb3, otherwise: bb1]; } bb1: { - StorageDead(_1); - return; + StorageLive(_12); + _12 = const {0x1 as *mut ()}; + _11 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb2, unwind unreachable]; } bb2: { - StorageLive(_10); - _10 = const {0x1 as *mut ()}; - _9 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; + StorageDead(_12); + goto -> bb3; } bb3: { StorageDead(_10); - goto -> bb4; - } - - bb4: { + _13 = const {0x1 as *const [bool; 0]}; + _7 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_13); StorageDead(_8); - _11 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_11); + _6 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + StorageDead(_7); + _5 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; - StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; - StorageDead(_4); _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); - StorageDead(_9); - StorageDead(_3); + StorageDead(_11); + StorageDead(_5); _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb1, unwind unreachable]; + _3 = &raw mut _1; + drop(((*_3).0: std::boxed::Box<[bool]>)) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index ff44d0df5e3e9..d3c04892613fe 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -5,24 +5,26 @@ let mut _0: (); let _1: A; let mut _2: std::boxed::Box<[bool]>; + let mut _3: *mut A; + let mut _4: (); scope 1 { debug a => _1; } scope 2 (inlined as Default>::default) { - let _3: std::ptr::Unique<[bool]>; - let mut _4: std::ptr::Unique<[bool; 0]>; + let _5: std::ptr::Unique<[bool]>; + let mut _6: std::ptr::Unique<[bool; 0]>; scope 3 { } scope 4 (inlined Unique::<[bool; 0]>::dangling) { - let mut _5: std::ptr::NonNull<[bool; 0]>; + let mut _7: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let _6: *mut [bool; 0]; + let _8: *mut [bool; 0]; scope 6 { scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - let mut _8: bool; - let _9: (); - let mut _10: *mut (); - let mut _11: *const [bool; 0]; + let mut _10: bool; + let _11: (); + let mut _12: *mut (); + let mut _13: *const [bool; 0]; scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -30,7 +32,7 @@ } } scope 7 (inlined dangling_mut::<[bool; 0]>) { - let mut _7: usize; + let mut _9: usize; scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { @@ -39,62 +41,65 @@ } } } + scope 13 (inlined std::ptr::drop_in_place:: - shim(Some(A))) { + } bb0: { StorageLive(_1); StorageLive(_2); - StorageLive(_3); - StorageLive(_9); - StorageLive(_4); StorageLive(_5); + StorageLive(_11); StorageLive(_6); StorageLive(_7); - _7 = const 1_usize; - _6 = const {0x1 as *mut [bool; 0]}; - StorageDead(_7); - StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb5, otherwise: bb3]; + StorageLive(_9); + _9 = const 1_usize; + _8 = const {0x1 as *mut [bool; 0]}; + StorageDead(_9); + StorageLive(_13); + StorageLive(_10); + _10 = UbChecks(); + switchInt(move _10) -> [0: bb4, otherwise: bb2]; } - bb1: { - StorageDead(_1); - return; + bb1 (cleanup): { + resume; } - bb2 (cleanup): { - resume; + bb2: { + StorageLive(_12); + _12 = const {0x1 as *mut ()}; + _11 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { - StorageLive(_10); - _10 = const {0x1 as *mut ()}; - _9 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; + StorageDead(_12); + goto -> bb4; } bb4: { StorageDead(_10); - goto -> bb5; - } - - bb5: { + _13 = const {0x1 as *const [bool; 0]}; + _7 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_13); StorageDead(_8); - _11 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_11); + _6 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + StorageDead(_7); + _5 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; - StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; - StorageDead(_4); _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); - StorageDead(_9); - StorageDead(_3); + StorageDead(_11); + StorageDead(_5); _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb1, unwind: bb2]; + _3 = &raw mut _1; + drop(((*_3).0: std::boxed::Box<[bool]>)) -> [return: bb5, unwind: bb1]; + } + + bb5: { + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 3662c3b59d271..2041a4bba33df 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -5,24 +5,26 @@ let mut _0: (); let _1: A; let mut _2: std::boxed::Box<[bool]>; + let mut _3: *mut A; + let mut _4: (); scope 1 { debug a => _1; } scope 2 (inlined as Default>::default) { - let _3: std::ptr::Unique<[bool]>; - let mut _4: std::ptr::Unique<[bool; 0]>; + let _5: std::ptr::Unique<[bool]>; + let mut _6: std::ptr::Unique<[bool; 0]>; scope 3 { } scope 4 (inlined Unique::<[bool; 0]>::dangling) { - let mut _5: std::ptr::NonNull<[bool; 0]>; + let mut _7: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let _6: *mut [bool; 0]; + let _8: *mut [bool; 0]; scope 6 { scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - let mut _8: bool; - let _9: (); - let mut _10: *mut (); - let mut _11: *const [bool; 0]; + let mut _10: bool; + let _11: (); + let mut _12: *mut (); + let mut _13: *const [bool; 0]; scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -30,7 +32,7 @@ } } scope 7 (inlined dangling_mut::<[bool; 0]>) { - let mut _7: usize; + let mut _9: usize; scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { @@ -39,58 +41,61 @@ } } } + scope 13 (inlined std::ptr::drop_in_place:: - shim(Some(A))) { + } bb0: { StorageLive(_1); StorageLive(_2); - StorageLive(_3); - StorageLive(_9); - StorageLive(_4); StorageLive(_5); + StorageLive(_11); StorageLive(_6); StorageLive(_7); - _7 = const 1_usize; - _6 = const {0x1 as *mut [bool; 0]}; - StorageDead(_7); - StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb4, otherwise: bb2]; + StorageLive(_9); + _9 = const 1_usize; + _8 = const {0x1 as *mut [bool; 0]}; + StorageDead(_9); + StorageLive(_13); + StorageLive(_10); + _10 = UbChecks(); + switchInt(move _10) -> [0: bb3, otherwise: bb1]; } bb1: { - StorageDead(_1); - return; + StorageLive(_12); + _12 = const {0x1 as *mut ()}; + _11 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb2, unwind unreachable]; } bb2: { - StorageLive(_10); - _10 = const {0x1 as *mut ()}; - _9 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; + StorageDead(_12); + goto -> bb3; } bb3: { StorageDead(_10); - goto -> bb4; - } - - bb4: { + _13 = const {0x1 as *const [bool; 0]}; + _7 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_13); StorageDead(_8); - _11 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_11); + _6 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + StorageDead(_7); + _5 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; - StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; - StorageDead(_4); _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); - StorageDead(_9); - StorageDead(_3); + StorageDead(_11); + StorageDead(_5); _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb1, unwind unreachable]; + _3 = &raw mut _1; + drop(((*_3).0: std::boxed::Box<[bool]>)) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 68dee57dee9e0..5e1ea8b8127ed 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -5,24 +5,26 @@ let mut _0: (); let _1: A; let mut _2: std::boxed::Box<[bool]>; + let mut _3: *mut A; + let mut _4: (); scope 1 { debug a => _1; } scope 2 (inlined as Default>::default) { - let _3: std::ptr::Unique<[bool]>; - let mut _4: std::ptr::Unique<[bool; 0]>; + let _5: std::ptr::Unique<[bool]>; + let mut _6: std::ptr::Unique<[bool; 0]>; scope 3 { } scope 4 (inlined Unique::<[bool; 0]>::dangling) { - let mut _5: std::ptr::NonNull<[bool; 0]>; + let mut _7: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let _6: *mut [bool; 0]; + let _8: *mut [bool; 0]; scope 6 { scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - let mut _8: bool; - let _9: (); - let mut _10: *mut (); - let mut _11: *const [bool; 0]; + let mut _10: bool; + let _11: (); + let mut _12: *mut (); + let mut _13: *const [bool; 0]; scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -30,7 +32,7 @@ } } scope 7 (inlined dangling_mut::<[bool; 0]>) { - let mut _7: usize; + let mut _9: usize; scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { @@ -39,62 +41,65 @@ } } } + scope 13 (inlined std::ptr::drop_in_place:: - shim(Some(A))) { + } bb0: { StorageLive(_1); StorageLive(_2); - StorageLive(_3); - StorageLive(_9); - StorageLive(_4); StorageLive(_5); + StorageLive(_11); StorageLive(_6); StorageLive(_7); - _7 = const 1_usize; - _6 = const {0x1 as *mut [bool; 0]}; - StorageDead(_7); - StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb5, otherwise: bb3]; + StorageLive(_9); + _9 = const 1_usize; + _8 = const {0x1 as *mut [bool; 0]}; + StorageDead(_9); + StorageLive(_13); + StorageLive(_10); + _10 = UbChecks(); + switchInt(move _10) -> [0: bb4, otherwise: bb2]; } - bb1: { - StorageDead(_1); - return; + bb1 (cleanup): { + resume; } - bb2 (cleanup): { - resume; + bb2: { + StorageLive(_12); + _12 = const {0x1 as *mut ()}; + _11 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { - StorageLive(_10); - _10 = const {0x1 as *mut ()}; - _9 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; + StorageDead(_12); + goto -> bb4; } bb4: { StorageDead(_10); - goto -> bb5; - } - - bb5: { + _13 = const {0x1 as *const [bool; 0]}; + _7 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_13); StorageDead(_8); - _11 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_11); + _6 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + StorageDead(_7); + _5 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; - StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; - StorageDead(_4); _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); - StorageDead(_9); - StorageDead(_3); + StorageDead(_11); + StorageDead(_5); _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb1, unwind: bb2]; + _3 = &raw mut _1; + drop(((*_3).0: std::boxed::Box<[bool]>)) -> [return: bb5, unwind: bb1]; + } + + bb5: { + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index 9d96e895c8aa5..8408bcce60bd9 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -5,24 +5,26 @@ let mut _0: (); let _1: A; let mut _2: std::boxed::Box<[bool]>; + let mut _3: *mut A; + let mut _4: (); scope 1 { debug a => _1; } scope 2 (inlined as Default>::default) { - let _3: std::ptr::Unique<[bool]>; - let mut _4: std::ptr::Unique<[bool; 0]>; + let _5: std::ptr::Unique<[bool]>; + let mut _6: std::ptr::Unique<[bool; 0]>; scope 3 { } scope 4 (inlined Unique::<[bool; 0]>::dangling) { - let mut _5: std::ptr::NonNull<[bool; 0]>; + let mut _7: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let _6: *mut [bool; 0]; + let _8: *mut [bool; 0]; scope 6 { scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - let mut _8: bool; - let _9: (); - let mut _10: *mut (); - let mut _11: *const [bool; 0]; + let mut _10: bool; + let _11: (); + let mut _12: *mut (); + let mut _13: *const [bool; 0]; scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -30,7 +32,7 @@ } } scope 7 (inlined dangling_mut::<[bool; 0]>) { - let mut _7: usize; + let mut _9: usize; scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { @@ -39,68 +41,71 @@ } } } + scope 13 (inlined std::ptr::drop_in_place:: - shim(Some(A))) { + } bb0: { StorageLive(_1); StorageLive(_2); - StorageLive(_3); - StorageLive(_9); - StorageLive(_4); StorageLive(_5); + StorageLive(_11); StorageLive(_6); StorageLive(_7); -- _7 = AlignOf([bool; 0]); -- _6 = _7 as *mut [bool; 0] (Transmute); -+ _7 = const 1_usize; -+ _6 = const {0x1 as *mut [bool; 0]}; - StorageDead(_7); - StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb4, otherwise: bb2]; + StorageLive(_9); +- _9 = AlignOf([bool; 0]); +- _8 = _9 as *mut [bool; 0] (Transmute); ++ _9 = const 1_usize; ++ _8 = const {0x1 as *mut [bool; 0]}; + StorageDead(_9); + StorageLive(_13); + StorageLive(_10); + _10 = UbChecks(); + switchInt(move _10) -> [0: bb3, otherwise: bb1]; } bb1: { - StorageDead(_1); - return; + StorageLive(_12); +- _12 = _8 as *mut () (PtrToPtr); +- _11 = NonNull::::new_unchecked::precondition_check(move _12) -> [return: bb2, unwind unreachable]; ++ _12 = const {0x1 as *mut ()}; ++ _11 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb2, unwind unreachable]; } bb2: { - StorageLive(_10); -- _10 = _6 as *mut () (PtrToPtr); -- _9 = NonNull::::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; -+ _10 = const {0x1 as *mut ()}; -+ _9 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; + StorageDead(_12); + goto -> bb3; } bb3: { StorageDead(_10); - goto -> bb4; - } - - bb4: { +- _13 = _8 as *const [bool; 0] (PtrToPtr); +- _7 = NonNull::<[bool; 0]> { pointer: _13 }; ++ _13 = const {0x1 as *const [bool; 0]}; ++ _7 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_13); StorageDead(_8); -- _11 = _6 as *const [bool; 0] (PtrToPtr); -- _5 = NonNull::<[bool; 0]> { pointer: _11 }; -+ _11 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_11); +- _6 = Unique::<[bool; 0]> { pointer: move _7, _marker: const PhantomData::<[bool; 0]> }; ++ _6 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + StorageDead(_7); +- _5 = move _6 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _5 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; - StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; - StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_5, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); - StorageDead(_9); - StorageDead(_3); + StorageDead(_11); + StorageDead(_5); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb1, unwind unreachable]; + _3 = &raw mut _1; + drop(((*_3).0: std::boxed::Box<[bool]>)) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_1); + return; } } + diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index 0bdff584b01ec..b4896a35fe328 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -5,24 +5,26 @@ let mut _0: (); let _1: A; let mut _2: std::boxed::Box<[bool]>; + let mut _3: *mut A; + let mut _4: (); scope 1 { debug a => _1; } scope 2 (inlined as Default>::default) { - let _3: std::ptr::Unique<[bool]>; - let mut _4: std::ptr::Unique<[bool; 0]>; + let _5: std::ptr::Unique<[bool]>; + let mut _6: std::ptr::Unique<[bool; 0]>; scope 3 { } scope 4 (inlined Unique::<[bool; 0]>::dangling) { - let mut _5: std::ptr::NonNull<[bool; 0]>; + let mut _7: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let _6: *mut [bool; 0]; + let _8: *mut [bool; 0]; scope 6 { scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - let mut _8: bool; - let _9: (); - let mut _10: *mut (); - let mut _11: *const [bool; 0]; + let mut _10: bool; + let _11: (); + let mut _12: *mut (); + let mut _13: *const [bool; 0]; scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -30,7 +32,7 @@ } } scope 7 (inlined dangling_mut::<[bool; 0]>) { - let mut _7: usize; + let mut _9: usize; scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { @@ -39,72 +41,75 @@ } } } + scope 13 (inlined std::ptr::drop_in_place:: - shim(Some(A))) { + } bb0: { StorageLive(_1); StorageLive(_2); - StorageLive(_3); - StorageLive(_9); - StorageLive(_4); StorageLive(_5); + StorageLive(_11); StorageLive(_6); StorageLive(_7); -- _7 = AlignOf([bool; 0]); -- _6 = _7 as *mut [bool; 0] (Transmute); -+ _7 = const 1_usize; -+ _6 = const {0x1 as *mut [bool; 0]}; - StorageDead(_7); - StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb5, otherwise: bb3]; + StorageLive(_9); +- _9 = AlignOf([bool; 0]); +- _8 = _9 as *mut [bool; 0] (Transmute); ++ _9 = const 1_usize; ++ _8 = const {0x1 as *mut [bool; 0]}; + StorageDead(_9); + StorageLive(_13); + StorageLive(_10); + _10 = UbChecks(); + switchInt(move _10) -> [0: bb4, otherwise: bb2]; } - bb1: { - StorageDead(_1); - return; + bb1 (cleanup): { + resume; } - bb2 (cleanup): { - resume; + bb2: { + StorageLive(_12); +- _12 = _8 as *mut () (PtrToPtr); +- _11 = NonNull::::new_unchecked::precondition_check(move _12) -> [return: bb3, unwind unreachable]; ++ _12 = const {0x1 as *mut ()}; ++ _11 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { - StorageLive(_10); -- _10 = _6 as *mut () (PtrToPtr); -- _9 = NonNull::::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; -+ _10 = const {0x1 as *mut ()}; -+ _9 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; + StorageDead(_12); + goto -> bb4; } bb4: { StorageDead(_10); - goto -> bb5; - } - - bb5: { +- _13 = _8 as *const [bool; 0] (PtrToPtr); +- _7 = NonNull::<[bool; 0]> { pointer: _13 }; ++ _13 = const {0x1 as *const [bool; 0]}; ++ _7 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_13); StorageDead(_8); -- _11 = _6 as *const [bool; 0] (PtrToPtr); -- _5 = NonNull::<[bool; 0]> { pointer: _11 }; -+ _11 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_11); +- _6 = Unique::<[bool; 0]> { pointer: move _7, _marker: const PhantomData::<[bool; 0]> }; ++ _6 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + StorageDead(_7); +- _5 = move _6 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _5 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; - StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; - StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_5, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); - StorageDead(_9); - StorageDead(_3); + StorageDead(_11); + StorageDead(_5); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb1, unwind: bb2]; + _3 = &raw mut _1; + drop(((*_3).0: std::boxed::Box<[bool]>)) -> [return: bb5, unwind: bb1]; + } + + bb5: { + StorageDead(_1); + return; } } + diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index 99e96fe5d70fd..36b85239601b6 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -5,24 +5,26 @@ let mut _0: (); let _1: A; let mut _2: std::boxed::Box<[bool]>; + let mut _3: *mut A; + let mut _4: (); scope 1 { debug a => _1; } scope 2 (inlined as Default>::default) { - let _3: std::ptr::Unique<[bool]>; - let mut _4: std::ptr::Unique<[bool; 0]>; + let _5: std::ptr::Unique<[bool]>; + let mut _6: std::ptr::Unique<[bool; 0]>; scope 3 { } scope 4 (inlined Unique::<[bool; 0]>::dangling) { - let mut _5: std::ptr::NonNull<[bool; 0]>; + let mut _7: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let _6: *mut [bool; 0]; + let _8: *mut [bool; 0]; scope 6 { scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - let mut _8: bool; - let _9: (); - let mut _10: *mut (); - let mut _11: *const [bool; 0]; + let mut _10: bool; + let _11: (); + let mut _12: *mut (); + let mut _13: *const [bool; 0]; scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -30,7 +32,7 @@ } } scope 7 (inlined dangling_mut::<[bool; 0]>) { - let mut _7: usize; + let mut _9: usize; scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { @@ -39,68 +41,71 @@ } } } + scope 13 (inlined std::ptr::drop_in_place:: - shim(Some(A))) { + } bb0: { StorageLive(_1); StorageLive(_2); - StorageLive(_3); - StorageLive(_9); - StorageLive(_4); StorageLive(_5); + StorageLive(_11); StorageLive(_6); StorageLive(_7); -- _7 = AlignOf([bool; 0]); -- _6 = _7 as *mut [bool; 0] (Transmute); -+ _7 = const 1_usize; -+ _6 = const {0x1 as *mut [bool; 0]}; - StorageDead(_7); - StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb4, otherwise: bb2]; + StorageLive(_9); +- _9 = AlignOf([bool; 0]); +- _8 = _9 as *mut [bool; 0] (Transmute); ++ _9 = const 1_usize; ++ _8 = const {0x1 as *mut [bool; 0]}; + StorageDead(_9); + StorageLive(_13); + StorageLive(_10); + _10 = UbChecks(); + switchInt(move _10) -> [0: bb3, otherwise: bb1]; } bb1: { - StorageDead(_1); - return; + StorageLive(_12); +- _12 = _8 as *mut () (PtrToPtr); +- _11 = NonNull::::new_unchecked::precondition_check(move _12) -> [return: bb2, unwind unreachable]; ++ _12 = const {0x1 as *mut ()}; ++ _11 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb2, unwind unreachable]; } bb2: { - StorageLive(_10); -- _10 = _6 as *mut () (PtrToPtr); -- _9 = NonNull::::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; -+ _10 = const {0x1 as *mut ()}; -+ _9 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; + StorageDead(_12); + goto -> bb3; } bb3: { StorageDead(_10); - goto -> bb4; - } - - bb4: { +- _13 = _8 as *const [bool; 0] (PtrToPtr); +- _7 = NonNull::<[bool; 0]> { pointer: _13 }; ++ _13 = const {0x1 as *const [bool; 0]}; ++ _7 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_13); StorageDead(_8); -- _11 = _6 as *const [bool; 0] (PtrToPtr); -- _5 = NonNull::<[bool; 0]> { pointer: _11 }; -+ _11 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_11); +- _6 = Unique::<[bool; 0]> { pointer: move _7, _marker: const PhantomData::<[bool; 0]> }; ++ _6 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + StorageDead(_7); +- _5 = move _6 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _5 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; - StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; - StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_5, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); - StorageDead(_9); - StorageDead(_3); + StorageDead(_11); + StorageDead(_5); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb1, unwind unreachable]; + _3 = &raw mut _1; + drop(((*_3).0: std::boxed::Box<[bool]>)) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_1); + return; } } + diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 5eefabeac3868..c32d597ddbc79 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -5,24 +5,26 @@ let mut _0: (); let _1: A; let mut _2: std::boxed::Box<[bool]>; + let mut _3: *mut A; + let mut _4: (); scope 1 { debug a => _1; } scope 2 (inlined as Default>::default) { - let _3: std::ptr::Unique<[bool]>; - let mut _4: std::ptr::Unique<[bool; 0]>; + let _5: std::ptr::Unique<[bool]>; + let mut _6: std::ptr::Unique<[bool; 0]>; scope 3 { } scope 4 (inlined Unique::<[bool; 0]>::dangling) { - let mut _5: std::ptr::NonNull<[bool; 0]>; + let mut _7: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let _6: *mut [bool; 0]; + let _8: *mut [bool; 0]; scope 6 { scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - let mut _8: bool; - let _9: (); - let mut _10: *mut (); - let mut _11: *const [bool; 0]; + let mut _10: bool; + let _11: (); + let mut _12: *mut (); + let mut _13: *const [bool; 0]; scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -30,7 +32,7 @@ } } scope 7 (inlined dangling_mut::<[bool; 0]>) { - let mut _7: usize; + let mut _9: usize; scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { @@ -39,72 +41,75 @@ } } } + scope 13 (inlined std::ptr::drop_in_place:: - shim(Some(A))) { + } bb0: { StorageLive(_1); StorageLive(_2); - StorageLive(_3); - StorageLive(_9); - StorageLive(_4); StorageLive(_5); + StorageLive(_11); StorageLive(_6); StorageLive(_7); -- _7 = AlignOf([bool; 0]); -- _6 = _7 as *mut [bool; 0] (Transmute); -+ _7 = const 1_usize; -+ _6 = const {0x1 as *mut [bool; 0]}; - StorageDead(_7); - StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb5, otherwise: bb3]; + StorageLive(_9); +- _9 = AlignOf([bool; 0]); +- _8 = _9 as *mut [bool; 0] (Transmute); ++ _9 = const 1_usize; ++ _8 = const {0x1 as *mut [bool; 0]}; + StorageDead(_9); + StorageLive(_13); + StorageLive(_10); + _10 = UbChecks(); + switchInt(move _10) -> [0: bb4, otherwise: bb2]; } - bb1: { - StorageDead(_1); - return; + bb1 (cleanup): { + resume; } - bb2 (cleanup): { - resume; + bb2: { + StorageLive(_12); +- _12 = _8 as *mut () (PtrToPtr); +- _11 = NonNull::::new_unchecked::precondition_check(move _12) -> [return: bb3, unwind unreachable]; ++ _12 = const {0x1 as *mut ()}; ++ _11 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { - StorageLive(_10); -- _10 = _6 as *mut () (PtrToPtr); -- _9 = NonNull::::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; -+ _10 = const {0x1 as *mut ()}; -+ _9 = NonNull::::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; + StorageDead(_12); + goto -> bb4; } bb4: { StorageDead(_10); - goto -> bb5; - } - - bb5: { +- _13 = _8 as *const [bool; 0] (PtrToPtr); +- _7 = NonNull::<[bool; 0]> { pointer: _13 }; ++ _13 = const {0x1 as *const [bool; 0]}; ++ _7 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_13); StorageDead(_8); -- _11 = _6 as *const [bool; 0] (PtrToPtr); -- _5 = NonNull::<[bool; 0]> { pointer: _11 }; -+ _11 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_11); +- _6 = Unique::<[bool; 0]> { pointer: move _7, _marker: const PhantomData::<[bool; 0]> }; ++ _6 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + StorageDead(_7); +- _5 = move _6 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _5 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; - StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; - StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_5, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); - StorageDead(_9); - StorageDead(_3); + StorageDead(_11); + StorageDead(_5); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb1, unwind: bb2]; + _3 = &raw mut _1; + drop(((*_3).0: std::boxed::Box<[bool]>)) -> [return: bb5, unwind: bb1]; + } + + bb5: { + StorageDead(_1); + return; } } + diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff index b596e25ddfdff..6342f791ce723 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff @@ -10,6 +10,8 @@ debug un => _1; scope 3 (inlined std::mem::drop::) { debug _x => _3; + scope 4 (inlined std::ptr::drop_in_place:: - shim(None)) { + } } } scope 2 (inlined val) { diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff index b596e25ddfdff..6342f791ce723 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff @@ -10,6 +10,8 @@ debug un => _1; scope 3 (inlined std::mem::drop::) { debug _x => _3; + scope 4 (inlined std::ptr::drop_in_place:: - shim(None)) { + } } } scope 2 (inlined val) { diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff index dc0004105a7b7..b481eea42af48 100644 --- a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff @@ -5,35 +5,40 @@ let mut _0: (); let _1: (); + scope 1 (inlined foo) { -+ let _2: D; ++ let mut _2: *mut D; ++ let _3: D; + scope 2 { + debug _d => const D; + } ++ scope 3 (inlined std::ptr::drop_in_place:: - shim(Some(D))) { ++ scope 4 (inlined ::drop) { ++ debug self => _2; ++ } ++ } + } bb0: { StorageLive(_1); - _1 = foo() -> [return: bb1, unwind continue]; + StorageLive(_2); -+ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind: bb3]; ++ StorageLive(_3); ++ asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb2]; } bb1: { ++ _2 = &raw mut _3; ++ StorageDead(_3); + StorageDead(_2); StorageDead(_1); _0 = const (); return; + } + -+ bb2: { -+ drop(_2) -> [return: bb1, unwind continue]; ++ bb2 (cleanup): { ++ drop(_3) -> [return: bb3, unwind terminate(cleanup)]; + } + + bb3 (cleanup): { -+ drop(_2) -> [return: bb4, unwind terminate(cleanup)]; -+ } -+ -+ bb4 (cleanup): { + resume; } } diff --git a/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff b/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff index d4427b2a8076e..46b01cec9a255 100644 --- a/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff @@ -4,6 +4,8 @@ fn foo() -> () { let mut _0: (); let mut _1: >::Item; ++ let mut _2: *mut >::Item; ++ let mut _3: (); scope 1 { debug x => _1; } @@ -15,7 +17,9 @@ bb1: { _0 = const (); - drop(_1) -> [return: bb2, unwind: bb3]; +- drop(_1) -> [return: bb2, unwind: bb3]; ++ _2 = &raw mut _1; ++ _3 = std::ptr::drop_in_place::<>::Item>(move _2) -> [return: bb2, unwind: bb3]; } bb2: { diff --git a/tests/mir-opt/inline/cycle.f.Inline.panic-abort.diff b/tests/mir-opt/inline/cycle.f.Inline.panic-abort.diff index 861b2fc9fb5b1..dd700a3ecacf8 100644 --- a/tests/mir-opt/inline/cycle.f.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/cycle.f.Inline.panic-abort.diff @@ -7,6 +7,8 @@ let _2: (); let mut _3: &impl Fn(); let mut _4: (); ++ let mut _5: *mut impl Fn(); ++ let mut _6: (); bb0: { StorageLive(_2); @@ -22,7 +24,9 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb2, unwind unreachable]; +- drop(_1) -> [return: bb2, unwind unreachable]; ++ _5 = &raw mut _1; ++ _6 = std::ptr::drop_in_place::(move _5) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff index b7fea4f2e147e..b496017bb5ada 100644 --- a/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff @@ -7,6 +7,8 @@ let _2: (); let mut _3: &impl Fn(); let mut _4: (); ++ let mut _5: *mut impl Fn(); ++ let mut _6: (); bb0: { StorageLive(_2); @@ -22,7 +24,9 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb2, unwind: bb4]; +- drop(_1) -> [return: bb2, unwind: bb4]; ++ _5 = &raw mut _1; ++ _6 = std::ptr::drop_in_place::(move _5) -> [return: bb2, unwind: bb4]; } bb2: { diff --git a/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff b/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff index fd1f698c60df8..fab30997ebb75 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff @@ -9,6 +9,10 @@ + debug g => _2; + let mut _3: &fn() {g}; + let _4: (); ++ let mut _5: *mut fn() {g}; ++ let mut _6: (); ++ scope 2 (inlined std::ptr::drop_in_place:: - shim(None)) { ++ } + } bb0: { @@ -17,22 +21,23 @@ + StorageLive(_2); + _2 = g; + StorageLive(_4); ++ StorageLive(_5); ++ StorageLive(_6); + StorageLive(_3); + _3 = &_2; -+ _4 = >::call(move _3, const ()) -> [return: bb2, unwind unreachable]; ++ _4 = >::call(move _3, const ()) -> [return: bb1, unwind unreachable]; } bb1: { ++ StorageDead(_3); ++ _5 = &raw mut _2; ++ StorageDead(_6); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_2); StorageDead(_1); _0 = const (); return; -+ } -+ -+ bb2: { -+ StorageDead(_3); -+ drop(_2) -> [return: bb1, unwind unreachable]; } } diff --git a/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff index e8299db47db72..d81a0a016f143 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff @@ -9,6 +9,10 @@ + debug g => _2; + let mut _3: &fn() {g}; + let _4: (); ++ let mut _5: *mut fn() {g}; ++ let mut _6: (); ++ scope 2 (inlined std::ptr::drop_in_place:: - shim(None)) { ++ } + } bb0: { @@ -17,12 +21,18 @@ + StorageLive(_2); + _2 = g; + StorageLive(_4); ++ StorageLive(_5); ++ StorageLive(_6); + StorageLive(_3); + _3 = &_2; -+ _4 = >::call(move _3, const ()) -> [return: bb2, unwind: bb3]; ++ _4 = >::call(move _3, const ()) -> [return: bb1, unwind: bb2]; } bb1: { ++ StorageDead(_3); ++ _5 = &raw mut _2; ++ StorageDead(_6); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_2); StorageDead(_1); @@ -30,16 +40,11 @@ return; + } + -+ bb2: { -+ StorageDead(_3); -+ drop(_2) -> [return: bb1, unwind continue]; ++ bb2 (cleanup): { ++ drop(_2) -> [return: bb3, unwind terminate(cleanup)]; + } + + bb3 (cleanup): { -+ drop(_2) -> [return: bb4, unwind terminate(cleanup)]; -+ } -+ -+ bb4 (cleanup): { + resume; } } diff --git a/tests/mir-opt/inline/cycle.rs b/tests/mir-opt/inline/cycle.rs index cb50638473f6c..95317a2f6ca47 100644 --- a/tests/mir-opt/inline/cycle.rs +++ b/tests/mir-opt/inline/cycle.rs @@ -23,5 +23,7 @@ fn main() { // CHECK-NOT: inlined // CHECK: (inlined f::) // CHECK-NOT: inlined + // CHECK: inlined std::ptr::drop_in_place + // CHECK-NOT: inlined f(g); } diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff index 757617e594021..7209cebb4d083 100644 --- a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff @@ -7,6 +7,8 @@ let mut _0: (); let mut _3: &mut std::boxed::Box>; let mut _4: I; ++ let mut _5: *mut std::boxed::Box>; ++ let mut _6: (); bb0: { StorageLive(_3); @@ -19,7 +21,9 @@ bb1: { StorageDead(_4); StorageDead(_3); - drop(_1) -> [return: bb2, unwind unreachable]; +- drop(_1) -> [return: bb2, unwind unreachable]; ++ _5 = &raw mut _1; ++ _6 = std::ptr::drop_in_place::>>(move _5) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff index b82961c2815d6..074627205bdc1 100644 --- a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff @@ -7,6 +7,8 @@ let mut _0: (); let mut _3: &mut std::boxed::Box>; let mut _4: I; ++ let mut _5: *mut std::boxed::Box>; ++ let mut _6: (); bb0: { StorageLive(_3); @@ -19,7 +21,9 @@ bb1: { StorageDead(_4); StorageDead(_3); - drop(_1) -> [return: bb2, unwind: bb4]; +- drop(_1) -> [return: bb2, unwind: bb4]; ++ _5 = &raw mut _1; ++ _6 = std::ptr::drop_in_place::>>(move _5) -> [return: bb2, unwind: bb4]; } bb2: { diff --git a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff index 4fa04b05e8993..8c84faf188447 100644 --- a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff @@ -7,6 +7,8 @@ let _2: (); let mut _3: &std::boxed::Box; let mut _4: (i32,); ++ let mut _5: *mut std::boxed::Box; ++ let mut _6: (); bb0: { StorageLive(_2); @@ -22,7 +24,9 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb2, unwind unreachable]; +- drop(_1) -> [return: bb2, unwind unreachable]; ++ _5 = &raw mut _1; ++ _6 = std::ptr::drop_in_place::>(move _5) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff index 47fd0ed079995..386cf1270bd2d 100644 --- a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff @@ -7,6 +7,8 @@ let _2: (); let mut _3: &std::boxed::Box; let mut _4: (i32,); ++ let mut _5: *mut std::boxed::Box; ++ let mut _6: (); bb0: { StorageLive(_2); @@ -22,7 +24,9 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb2, unwind: bb4]; +- drop(_1) -> [return: bb2, unwind: bb4]; ++ _5 = &raw mut _1; ++ _6 = std::ptr::drop_in_place::>(move _5) -> [return: bb2, unwind: bb4]; } bb2: { diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff index 07031a298bc36..841ead6fe7fa5 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff @@ -7,7 +7,9 @@ let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}>; let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; let mut _4: {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; -+ let mut _5: bool; ++ let mut _5: *mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; ++ let mut _6: (); ++ let mut _7: bool; scope 1 { debug _r => _1; } @@ -20,10 +22,19 @@ + } + } + scope 5 (inlined g::{closure#0}) { -+ debug a => _5; -+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; -+ let mut _7: u32; -+ let mut _8: i32; ++ debug a => _7; ++ let mut _8: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; ++ let mut _9: u32; ++ let mut _10: i32; ++ } ++ scope 6 (inlined std::ptr::drop_in_place::<{coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}> - shim(Some({coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}))) { ++ debug a => _15; ++ let mut _11: bool; ++ let mut _12: i32; ++ let mut _13: bool; ++ let mut _14: bool; ++ let _15: bool; ++ let mut _16: u32; + } bb0: { @@ -36,76 +47,90 @@ + _3 = &mut _4; + _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}> { __pointer: _3 }; + StorageDead(_3); -+ StorageLive(_5); -+ _5 = const false; -+ StorageLive(_6); + StorageLive(_7); -+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}); -+ _7 = discriminant((*_6)); -+ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; ++ _7 = const false; ++ StorageLive(_8); ++ StorageLive(_9); ++ _8 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}); ++ _9 = discriminant((*_8)); ++ switchInt(move _9) -> [0: bb2, 1: bb6, 3: bb7, otherwise: bb8]; } bb1: { - _3 = &mut _4; - _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}>::new(move _3) -> [return: bb2, unwind unreachable]; -+ StorageDead(_4); -+ _0 = const (); -+ StorageDead(_1); -+ return; ++ StorageDead(_9); ++ StorageDead(_8); ++ StorageDead(_7); ++ StorageDead(_2); ++ _5 = &raw mut _4; ++ StorageLive(_11); ++ StorageLive(_13); ++ StorageLive(_14); ++ StorageLive(_15); ++ StorageLive(_16); ++ _16 = discriminant((*_5)); ++ switchInt(move _16) -> [0: bb9, 3: bb10, otherwise: bb9]; } bb2: { - StorageDead(_3); - _1 = <{coroutine@$DIR/inline_coroutine.rs:20:5: 20:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; -+ StorageDead(_7); -+ StorageDead(_6); -+ StorageDead(_5); -+ StorageDead(_2); -+ drop(_4) -> [return: bb1, unwind unreachable]; ++ StorageLive(_10); ++ switchInt(_7) -> [0: bb3, otherwise: bb4]; } bb3: { - StorageDead(_2); - drop(_4) -> [return: bb4, unwind unreachable]; -+ StorageLive(_8); -+ switchInt(_5) -> [0: bb4, otherwise: bb5]; ++ _10 = const 13_i32; ++ goto -> bb5; } bb4: { -- StorageDead(_4); -- _0 = const (); -- StorageDead(_1); -- return; -+ _8 = const 13_i32; -+ goto -> bb6; ++ _10 = const 7_i32; ++ goto -> bb5; + } + + bb5: { -+ _8 = const 7_i32; -+ goto -> bb6; ++ _1 = CoroutineState::::Yielded(move _10); ++ StorageDead(_10); ++ discriminant((*_8)) = 3; ++ goto -> bb1; + } + + bb6: { -+ _1 = CoroutineState::::Yielded(move _8); -+ StorageDead(_8); -+ discriminant((*_6)) = 3; -+ goto -> bb2; ++ assert(const false, "coroutine resumed after completion") -> [success: bb6, unwind unreachable]; + } + + bb7: { -+ assert(const false, "coroutine resumed after completion") -> [success: bb7, unwind unreachable]; ++ StorageLive(_10); ++ StorageDead(_10); ++ _1 = CoroutineState::::Complete(_7); ++ discriminant((*_8)) = 1; ++ goto -> bb1; + } + + bb8: { -+ StorageLive(_8); -+ StorageDead(_8); -+ _1 = CoroutineState::::Complete(_5); -+ discriminant((*_6)) = 1; -+ goto -> bb2; ++ unreachable; + } + + bb9: { -+ unreachable; ++ StorageDead(_16); ++ StorageDead(_15); ++ StorageDead(_14); ++ StorageDead(_13); ++ StorageDead(_11); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; ++ } ++ ++ bb10: { ++ StorageLive(_12); ++ StorageDead(_12); ++ goto -> bb9; } } diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff index ab6c62b0baf56..9bb9c7cf9855d 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff @@ -7,7 +7,9 @@ let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}>; let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; let mut _4: {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; -+ let mut _5: bool; ++ let mut _5: *mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; ++ let mut _6: (); ++ let mut _7: bool; scope 1 { debug _r => _1; } @@ -20,10 +22,19 @@ + } + } + scope 5 (inlined g::{closure#0}) { -+ debug a => _5; -+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; -+ let mut _7: u32; -+ let mut _8: i32; ++ debug a => _7; ++ let mut _8: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; ++ let mut _9: u32; ++ let mut _10: i32; ++ } ++ scope 6 (inlined std::ptr::drop_in_place::<{coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}> - shim(Some({coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}))) { ++ debug a => _15; ++ let mut _11: bool; ++ let mut _12: i32; ++ let mut _13: bool; ++ let mut _14: bool; ++ let _15: bool; ++ let mut _16: u32; + } bb0: { @@ -36,90 +47,105 @@ + _3 = &mut _4; + _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}> { __pointer: _3 }; + StorageDead(_3); -+ StorageLive(_5); -+ _5 = const false; -+ StorageLive(_6); + StorageLive(_7); -+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}); -+ _7 = discriminant((*_6)); -+ switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; ++ _7 = const false; ++ StorageLive(_8); ++ StorageLive(_9); ++ _8 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}); ++ _9 = discriminant((*_8)); ++ switchInt(move _9) -> [0: bb4, 1: bb8, 3: bb9, otherwise: bb10]; } - bb1: { +- bb1: { - _3 = &mut _4; - _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}>::new(move _3) -> [return: bb2, unwind: bb5]; -+ StorageDead(_4); -+ _0 = const (); -+ StorageDead(_1); -+ return; ++ bb1 (cleanup): { ++ drop(_4) -> [return: bb2, unwind terminate(cleanup)]; } - bb2: { - StorageDead(_3); - _1 = <{coroutine@$DIR/inline_coroutine.rs:20:5: 20:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; + bb2 (cleanup): { -+ drop(_4) -> [return: bb3, unwind terminate(cleanup)]; - } - -- bb3: { -- StorageDead(_2); -- drop(_4) -> [return: bb4, unwind: bb6]; -+ bb3 (cleanup): { + resume; } - bb4: { -- StorageDead(_4); -- _0 = const (); -- StorageDead(_1); -- return; + bb3: { ++ StorageDead(_9); ++ StorageDead(_8); + StorageDead(_7); -+ StorageDead(_6); -+ StorageDead(_5); -+ StorageDead(_2); -+ drop(_4) -> [return: bb1, unwind: bb3]; + StorageDead(_2); +- drop(_4) -> [return: bb4, unwind: bb6]; ++ _5 = &raw mut _4; ++ StorageLive(_11); ++ StorageLive(_13); ++ StorageLive(_14); ++ StorageLive(_15); ++ StorageLive(_16); ++ _16 = discriminant((*_5)); ++ switchInt(move _16) -> [0: bb11, 3: bb12, otherwise: bb11]; } -- bb5 (cleanup): { -- drop(_4) -> [return: bb6, unwind terminate(cleanup)]; + bb4: { ++ StorageLive(_10); ++ switchInt(_7) -> [0: bb5, otherwise: bb6]; ++ } ++ + bb5: { -+ StorageLive(_8); -+ switchInt(_5) -> [0: bb6, otherwise: bb7]; - } - -- bb6 (cleanup): { -- resume; ++ _10 = const 13_i32; ++ goto -> bb7; ++ } ++ + bb6: { -+ _8 = const 13_i32; -+ goto -> bb8; ++ _10 = const 7_i32; ++ goto -> bb7; + } + + bb7: { -+ _8 = const 7_i32; -+ goto -> bb8; ++ _1 = CoroutineState::::Yielded(move _10); ++ StorageDead(_10); ++ discriminant((*_8)) = 3; ++ goto -> bb3; + } + + bb8: { -+ _1 = CoroutineState::::Yielded(move _8); -+ StorageDead(_8); -+ discriminant((*_6)) = 3; -+ goto -> bb4; ++ assert(const false, "coroutine resumed after completion") -> [success: bb8, unwind: bb1]; + } + + bb9: { -+ assert(const false, "coroutine resumed after completion") -> [success: bb9, unwind: bb2]; ++ StorageLive(_10); ++ StorageDead(_10); ++ _1 = CoroutineState::::Complete(_7); ++ discriminant((*_8)) = 1; ++ goto -> bb3; + } + + bb10: { -+ StorageLive(_8); -+ StorageDead(_8); -+ _1 = CoroutineState::::Complete(_5); -+ discriminant((*_6)) = 1; -+ goto -> bb4; ++ unreachable; + } + + bb11: { -+ unreachable; ++ StorageDead(_16); ++ StorageDead(_15); ++ StorageDead(_14); ++ StorageDead(_13); ++ StorageDead(_11); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } + +- bb5 (cleanup): { +- drop(_4) -> [return: bb6, unwind terminate(cleanup)]; +- } +- +- bb6 (cleanup): { +- resume; ++ bb12: { ++ StorageLive(_12); ++ StorageDead(_12); ++ goto -> bb11; } } diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff index 2bbb830fc7790..17044ead5459e 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff @@ -10,6 +10,8 @@ + let mut _3: &fn() -> ! {sleep}; + let _4: !; + let mut _5: &fn() -> ! {sleep}; ++ let mut _7: *mut fn() -> ! {sleep}; ++ let mut _8: (); + scope 2 { + debug a => _4; + let _6: !; @@ -17,6 +19,8 @@ + debug b => _6; + } + } ++ scope 4 (inlined std::ptr::drop_in_place:: ! {sleep}> - shim(None)) { ++ } + } bb0: { @@ -26,6 +30,8 @@ + _2 = sleep; + StorageLive(_4); + StorageLive(_6); ++ StorageLive(_7); ++ StorageLive(_8); + StorageLive(_3); + _3 = &_2; + _4 = ! {sleep} as Fn<()>>::call(move _3, const ()) -> [return: bb1, unwind unreachable]; @@ -41,10 +47,7 @@ + bb2: { + StorageDead(_5); + _1 = (_4, _6); -+ drop(_2) -> [return: bb3, unwind unreachable]; -+ } -+ -+ bb3: { ++ _7 = &raw mut _2; + unreachable; } } diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff index bc4f2d24df0b5..14fa84629d568 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff @@ -11,6 +11,8 @@ + let _4: !; + let mut _5: &fn() -> ! {sleep}; + let mut _7: !; ++ let mut _8: *mut fn() -> ! {sleep}; ++ let mut _9: (); + scope 2 { + debug a => _4; + let _6: !; @@ -18,6 +20,8 @@ + debug b => _6; + } + } ++ scope 4 (inlined std::ptr::drop_in_place:: ! {sleep}> - shim(None)) { ++ } + } bb0: { @@ -26,17 +30,19 @@ + StorageLive(_2); + _2 = sleep; + StorageLive(_6); ++ StorageLive(_8); ++ StorageLive(_9); + StorageLive(_4); + StorageLive(_3); + _3 = &_2; -+ _4 = ! {sleep} as Fn<()>>::call(move _3, const ()) -> [return: bb1, unwind: bb5]; ++ _4 = ! {sleep} as Fn<()>>::call(move _3, const ()) -> [return: bb1, unwind: bb4]; + } + + bb1: { + StorageDead(_3); + StorageLive(_5); + _5 = &_2; -+ _6 = ! {sleep} as Fn<()>>::call(move _5, const ()) -> [return: bb2, unwind: bb4]; ++ _6 = ! {sleep} as Fn<()>>::call(move _5, const ()) -> [return: bb2, unwind: bb3]; + } + + bb2: { @@ -46,22 +52,19 @@ + _1 = (move _7, _6); + StorageDead(_7); + StorageDead(_4); -+ drop(_2) -> [return: bb3, unwind continue]; ++ _8 = &raw mut _2; ++ unreachable; + } + -+ bb3: { -+ unreachable; ++ bb3 (cleanup): { ++ drop(_4) -> [return: bb4, unwind terminate(cleanup)]; + } + + bb4 (cleanup): { -+ drop(_4) -> [return: bb5, unwind terminate(cleanup)]; ++ drop(_2) -> [return: bb5, unwind terminate(cleanup)]; + } + + bb5 (cleanup): { -+ drop(_2) -> [return: bb6, unwind terminate(cleanup)]; -+ } -+ -+ bb6 (cleanup): { + resume; } } diff --git a/tests/mir-opt/inline/inline_diverging.rs b/tests/mir-opt/inline/inline_diverging.rs index e1cea3618f176..2404eccd26031 100644 --- a/tests/mir-opt/inline/inline_diverging.rs +++ b/tests/mir-opt/inline/inline_diverging.rs @@ -27,6 +27,9 @@ pub fn h() { // CHECK-LABEL: fn h( // CHECK: (inlined call_twice:: ! {sleep}>) // CHECK-NOT: inlined + // CHECK: inlined std::ptr::drop_in_place:: ! {sleep}> + // CHECK-NOT: inlined + // CHECK-COUNT-2: ! {sleep} as Fn<()>>::call call_twice(sleep); } diff --git a/tests/mir-opt/inline/inline_drop.drop_both_arguments.Inline.diff b/tests/mir-opt/inline/inline_drop.drop_both_arguments.Inline.diff index 53db1a4b562e0..cee84b9ac0f7b 100644 --- a/tests/mir-opt/inline/inline_drop.drop_both_arguments.Inline.diff +++ b/tests/mir-opt/inline/inline_drop.drop_both_arguments.Inline.diff @@ -5,26 +5,70 @@ debug _a => _1; debug _b => _2; let mut _0: (); ++ let mut _3: *mut CallThingOnDrop; ++ let mut _4: (); ++ let mut _5: *mut CallThingOnDrop; ++ scope 1 (inlined std::ptr::drop_in_place:: - shim(Some(CallThingOnDrop))) { ++ let mut _6: &mut CallThingOnDrop; ++ let mut _7: (); ++ scope 2 (inlined ::drop) { ++ let _8: (); ++ } ++ } ++ scope 3 (inlined std::ptr::drop_in_place:: - shim(Some(CallThingOnDrop))) { ++ let mut _9: &mut CallThingOnDrop; ++ let mut _10: (); ++ scope 4 (inlined ::drop) { ++ let _11: (); ++ } ++ } bb0: { _0 = const (); - drop(_2) -> [return: bb1, unwind: bb3]; +- drop(_2) -> [return: bb1, unwind: bb3]; ++ _3 = &raw mut _2; ++ StorageLive(_6); ++ StorageLive(_7); ++ _6 = &mut (*_3); ++ StorageLive(_8); ++ _8 = thing() -> [return: bb3, unwind: bb1]; } - bb1: { - drop(_1) -> [return: bb2, unwind: bb4]; +- bb1: { +- drop(_1) -> [return: bb2, unwind: bb4]; ++ bb1 (cleanup): { ++ drop(_1) -> [return: bb2, unwind terminate(cleanup)]; } - bb2: { - return; +- bb2: { +- return; ++ bb2 (cleanup): { ++ resume; } - bb3 (cleanup): { - drop(_1) -> [return: bb4, unwind terminate(cleanup)]; +- bb3 (cleanup): { +- drop(_1) -> [return: bb4, unwind terminate(cleanup)]; ++ bb3: { ++ StorageDead(_8); ++ _7 = const (); ++ StorageDead(_7); ++ StorageDead(_6); ++ _5 = &raw mut _1; ++ StorageLive(_9); ++ StorageLive(_10); ++ _9 = &mut (*_5); ++ StorageLive(_11); ++ _11 = thing() -> [return: bb4, unwind: bb2]; } - bb4 (cleanup): { - resume; +- bb4 (cleanup): { +- resume; ++ bb4: { ++ StorageDead(_11); ++ _10 = const (); ++ StorageDead(_10); ++ StorageDead(_9); ++ return; } } diff --git a/tests/mir-opt/inline/inline_drop.rs b/tests/mir-opt/inline/inline_drop.rs index 3b64fb325bb92..fd8ab88f8636d 100644 --- a/tests/mir-opt/inline/inline_drop.rs +++ b/tests/mir-opt/inline/inline_drop.rs @@ -19,6 +19,6 @@ impl Drop for CallThingOnDrop { // EMIT_MIR inline_drop.drop_both_arguments.Inline.diff pub fn drop_both_arguments(_a: CallThingOnDrop, _b: CallThingOnDrop) { - // CHECK: drop(_2) - // CHECK: drop(_1) + // CHECK: = thing() -> + // CHECK: = thing() -> } diff --git a/tests/mir-opt/inline/inline_instruction_set.rs b/tests/mir-opt/inline/inline_instruction_set.rs index 44faf3a4ed9ad..6672707da6f77 100644 --- a/tests/mir-opt/inline/inline_instruction_set.rs +++ b/tests/mir-opt/inline/inline_instruction_set.rs @@ -22,10 +22,14 @@ macro_rules! asm { }; } +// FIXME: Does this *really* need to be a no_core test? + #[lang = "sized"] trait Sized {} #[lang = "copy"] trait Copy {} +#[lang = "drop_in_place"] +fn drop_in_place(_: *mut T) {} #[instruction_set(arm::a32)] #[inline] diff --git a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff index 2a36ccaab110a..02419c5b87953 100644 --- a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff @@ -8,53 +8,39 @@ let _3: (); let mut _4: *mut std::vec::Vec; let mut _5: *mut std::option::Option; -+ scope 1 (inlined std::ptr::drop_in_place::> - shim(Some(Vec))) { -+ let mut _6: &mut std::vec::Vec; -+ let mut _7: (); -+ } -+ scope 2 (inlined std::ptr::drop_in_place::> - shim(Some(Option))) { -+ let mut _8: isize; -+ let mut _9: isize; ++ scope 1 (inlined std::ptr::drop_in_place::> - shim(Some(Option))) { ++ let mut _6: isize; ++ let mut _7: isize; + } bb0: { StorageLive(_3); StorageLive(_4); _4 = _1; -- _3 = std::ptr::drop_in_place::>(move _4) -> [return: bb1, unwind unreachable]; -+ StorageLive(_6); -+ StorageLive(_7); -+ _6 = &mut (*_4); -+ _7 = as Drop>::drop(move _6) -> [return: bb2, unwind unreachable]; + _3 = std::ptr::drop_in_place::>(move _4) -> [return: bb1, unwind unreachable]; } bb1: { -+ StorageDead(_7); -+ StorageDead(_6); StorageDead(_4); StorageDead(_3); StorageLive(_5); _5 = _2; - _0 = std::ptr::drop_in_place::>(move _5) -> [return: bb2, unwind unreachable]; -+ StorageLive(_8); -+ StorageLive(_9); -+ _8 = discriminant((*_5)); -+ switchInt(move _8) -> [0: bb3, otherwise: bb4]; ++ StorageLive(_6); ++ StorageLive(_7); ++ _6 = discriminant((*_5)); ++ switchInt(move _6) -> [0: bb2, otherwise: bb3]; } bb2: { -+ drop(((*_4).0: alloc::raw_vec::RawVec)) -> [return: bb1, unwind unreachable]; -+ } -+ -+ bb3: { -+ StorageDead(_9); -+ StorageDead(_8); ++ StorageDead(_7); ++ StorageDead(_6); StorageDead(_5); return; + } + -+ bb4: { -+ drop((((*_5) as Some).0: B)) -> [return: bb3, unwind unreachable]; ++ bb3: { ++ drop((((*_5) as Some).0: B)) -> [return: bb2, unwind unreachable]; } } diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff index b9f268df35150..ff869352863bc 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff @@ -8,6 +8,8 @@ let mut _3: &fn() {foo}; let _4: fn() {foo}; let mut _5: (); ++ let mut _6: *mut P; ++ let mut _7: (); + scope 1 (inlined hide_foo) { + } @@ -34,7 +36,8 @@ StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind unreachable]; -+ drop(_1) -> [return: bb2, unwind unreachable]; ++ _6 = &raw mut _1; ++ _7 = std::ptr::drop_in_place::

(move _6) -> [return: bb2, unwind unreachable]; } - bb3: { diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff index 8495164df9c62..d91e536852be1 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff @@ -8,6 +8,8 @@ let mut _3: &fn() {foo}; let _4: fn() {foo}; let mut _5: (); ++ let mut _6: *mut P; ++ let mut _7: (); + scope 1 (inlined hide_foo) { + } @@ -34,7 +36,8 @@ StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind: bb5]; -+ drop(_1) -> [return: bb2, unwind: bb4]; ++ _6 = &raw mut _1; ++ _7 = std::ptr::drop_in_place::

(move _6) -> [return: bb2, unwind: bb4]; } - bb3: { diff --git a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff index 37083973fd159..22edffdc15f74 100644 --- a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff +++ b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff @@ -7,6 +7,8 @@ let _2: (); let mut _3: std::boxed::Box<[i32]>; let mut _4: *const [i32]; ++ let mut _5: *mut std::boxed::Box<[i32]>; ++ let mut _6: (); bb0: { StorageLive(_2); @@ -17,7 +19,9 @@ } bb1: { - drop(_3) -> [return: bb2, unwind: bb4]; +- drop(_3) -> [return: bb2, unwind: bb4]; ++ _5 = &raw mut _3; ++ _6 = std::ptr::drop_in_place::>(move _5) -> [return: bb2, unwind: bb4]; } bb2: { diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff index f8715789cec14..fb702038d6f07 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff @@ -13,6 +13,8 @@ let mut _8: std::pin::Pin<&mut {async fn body of ActionPermit<'_, T>::perform()}>; let mut _9: &mut std::task::Context<'_>; let mut _10: &mut std::task::Context<'_>; ++ let mut _11: *mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _12: (); scope 1 { debug fut => _2; let _4: std::pin::Pin<&mut {async fn body of ActionPermit<'_, T>::perform()}>; @@ -21,43 +23,43 @@ scope 3 { } + scope 6 (inlined ActionPermit::<'_, T>::perform::{closure#0}) { -+ let _11: ActionPermit<'_, T>; -+ let mut _12: std::future::Ready<()>; -+ let mut _13: std::future::Ready<()>; -+ let mut _14: (); ++ let _13: ActionPermit<'_, T>; ++ let mut _14: std::future::Ready<()>; ++ let mut _15: std::future::Ready<()>; + let mut _16: (); -+ let _17: (); -+ let mut _18: std::task::Poll<()>; -+ let mut _19: std::pin::Pin<&mut std::future::Ready<()>>; -+ let mut _20: &mut std::future::Ready<()>; -+ let mut _21: &mut std::future::Ready<()>; -+ let mut _22: &mut std::task::Context<'_>; -+ let mut _23: &mut std::task::Context<'_>; ++ let mut _18: (); ++ let _19: (); ++ let mut _20: std::task::Poll<()>; ++ let mut _21: std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _22: &mut std::future::Ready<()>; ++ let mut _23: &mut std::future::Ready<()>; + let mut _24: &mut std::task::Context<'_>; -+ let mut _25: isize; -+ let mut _27: !; -+ let mut _28: &mut std::task::Context<'_>; -+ let mut _29: (); -+ let mut _30: (); -+ let mut _31: &mut std::task::Context<'_>; -+ let mut _32: u32; -+ let mut _33: &mut {async fn body of ActionPermit<'_, T>::perform()}; -+ let mut _34: &mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _25: &mut std::task::Context<'_>; ++ let mut _26: &mut std::task::Context<'_>; ++ let mut _27: isize; ++ let mut _29: !; ++ let mut _30: &mut std::task::Context<'_>; ++ let mut _31: (); ++ let mut _32: (); ++ let mut _33: &mut std::task::Context<'_>; ++ let mut _34: u32; + let mut _35: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _36: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _37: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _38: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _39: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _40: &mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _41: &mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _42: &mut {async fn body of ActionPermit<'_, T>::perform()}; + scope 7 { -+ let mut _15: std::future::Ready<()>; ++ let mut _17: std::future::Ready<()>; + scope 8 { -+ let _26: (); ++ let _28: (); + scope 9 { + } + } + scope 10 (inlined ready::<()>) { -+ let mut _41: std::option::Option<()>; ++ let mut _43: std::option::Option<()>; + } + } + } @@ -95,13 +97,11 @@ _10 = deref_copy (_1.1: &mut std::task::Context<'_>); _9 = &mut (*_10); - _7 = <{async fn body of ActionPermit<'_, T>::perform()} as Future>::poll(move _8, move _9) -> [return: bb3, unwind unreachable]; -+ StorageLive(_11); -+ StorageLive(_15); -+ StorageLive(_16); -+ StorageLive(_25); ++ StorageLive(_13); ++ StorageLive(_17); ++ StorageLive(_18); + StorageLive(_27); -+ StorageLive(_30); -+ StorageLive(_31); ++ StorageLive(_29); + StorageLive(_32); + StorageLive(_33); + StorageLive(_34); @@ -111,9 +111,11 @@ + StorageLive(_38); + StorageLive(_39); + StorageLive(_40); -+ _33 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ _32 = discriminant((*_33)); -+ switchInt(move _32) -> [0: bb3, 1: bb13, 3: bb12, otherwise: bb8]; ++ StorageLive(_41); ++ StorageLive(_42); ++ _35 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ _34 = discriminant((*_35)); ++ switchInt(move _34) -> [0: bb3, 1: bb13, 3: bb12, otherwise: bb8]; } - bb3: { @@ -123,6 +125,8 @@ + } + + bb2: { ++ StorageDead(_42); ++ StorageDead(_41); + StorageDead(_40); + StorageDead(_39); + StorageDead(_38); @@ -132,13 +136,11 @@ + StorageDead(_34); + StorageDead(_33); + StorageDead(_32); -+ StorageDead(_31); -+ StorageDead(_30); ++ StorageDead(_29); + StorageDead(_27); -+ StorageDead(_25); -+ StorageDead(_16); -+ StorageDead(_15); -+ StorageDead(_11); ++ StorageDead(_18); ++ StorageDead(_17); ++ StorageDead(_13); StorageDead(_9); StorageDead(_8); StorageDead(_7); @@ -147,64 +149,65 @@ _0 = const (); StorageDead(_4); - drop(_2) -> [return: bb4, unwind unreachable]; -+ drop(_2) -> [return: bb1, unwind unreachable]; ++ _11 = &raw mut _2; ++ _12 = std::ptr::drop_in_place::<{async fn body of ActionPermit<'_, T>::perform()}>(move _11) -> [return: bb1, unwind unreachable]; } + bb3: { -+ _31 = move _9; -+ _34 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ _35 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ (((*_34) as variant#3).0: ActionPermit<'_, T>) = move ((*_35).0: ActionPermit<'_, T>); -+ StorageLive(_12); -+ StorageLive(_13); ++ _33 = move _9; ++ _36 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ _37 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ (((*_36) as variant#3).0: ActionPermit<'_, T>) = move ((*_37).0: ActionPermit<'_, T>); + StorageLive(_14); -+ _14 = (); -+ StorageLive(_41); -+ _41 = Option::<()>::Some(_14); -+ _13 = std::future::Ready::<()>(move _41); -+ StorageDead(_41); -+ StorageDead(_14); -+ _12 = as IntoFuture>::into_future(move _13) -> [return: bb4, unwind unreachable]; ++ StorageLive(_15); ++ StorageLive(_16); ++ _16 = (); ++ StorageLive(_43); ++ _43 = Option::<()>::Some(_16); ++ _15 = std::future::Ready::<()>(move _43); ++ StorageDead(_43); ++ StorageDead(_16); ++ _14 = as IntoFuture>::into_future(move _15) -> [return: bb4, unwind unreachable]; + } + bb4: { - StorageDead(_2); - return; -+ StorageDead(_13); -+ _36 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ (((*_36) as variant#3).1: std::future::Ready<()>) = move _12; ++ StorageDead(_15); ++ _38 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ (((*_38) as variant#3).1: std::future::Ready<()>) = move _14; + goto -> bb5; + } + + bb5: { -+ StorageLive(_17); -+ StorageLive(_18); + StorageLive(_19); + StorageLive(_20); + StorageLive(_21); -+ _37 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ _21 = &mut (((*_37) as variant#3).1: std::future::Ready<()>); -+ _20 = &mut (*_21); -+ _19 = Pin::<&mut std::future::Ready<()>>::new_unchecked(move _20) -> [return: bb6, unwind unreachable]; ++ StorageLive(_22); ++ StorageLive(_23); ++ _39 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ _23 = &mut (((*_39) as variant#3).1: std::future::Ready<()>); ++ _22 = &mut (*_23); ++ _21 = Pin::<&mut std::future::Ready<()>>::new_unchecked(move _22) -> [return: bb6, unwind unreachable]; + } + + bb6: { -+ StorageDead(_20); -+ StorageLive(_22); -+ StorageLive(_23); ++ StorageDead(_22); + StorageLive(_24); -+ _24 = _31; -+ _23 = move _24; -+ _22 = &mut (*_23); -+ StorageDead(_24); -+ _18 = as Future>::poll(move _19, move _22) -> [return: bb7, unwind unreachable]; ++ StorageLive(_25); ++ StorageLive(_26); ++ _26 = _33; ++ _25 = move _26; ++ _24 = &mut (*_25); ++ StorageDead(_26); ++ _20 = as Future>::poll(move _21, move _24) -> [return: bb7, unwind unreachable]; + } + + bb7: { -+ StorageDead(_22); -+ StorageDead(_19); -+ _25 = discriminant(_18); -+ switchInt(move _25) -> [0: bb10, 1: bb9, otherwise: bb8]; ++ StorageDead(_24); ++ StorageDead(_21); ++ _27 = discriminant(_20); ++ switchInt(move _27) -> [0: bb10, 1: bb9, otherwise: bb8]; + } + + bb8: { @@ -212,53 +215,53 @@ + } + + bb9: { -+ _17 = const (); ++ _19 = const (); ++ StorageDead(_25); + StorageDead(_23); -+ StorageDead(_21); -+ StorageDead(_18); -+ StorageDead(_17); -+ StorageLive(_28); -+ StorageLive(_29); -+ _29 = (); ++ StorageDead(_20); ++ StorageDead(_19); ++ StorageLive(_30); ++ StorageLive(_31); ++ _31 = (); + _7 = Poll::<()>::Pending; -+ StorageDead(_12); -+ StorageDead(_28); -+ StorageDead(_29); -+ _38 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ discriminant((*_38)) = 3; ++ StorageDead(_14); ++ StorageDead(_30); ++ StorageDead(_31); ++ _40 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ discriminant((*_40)) = 3; + goto -> bb2; + } + + bb10: { -+ StorageLive(_26); -+ _26 = ((_18 as Ready).0: ()); -+ _30 = _26; -+ StorageDead(_26); ++ StorageLive(_28); ++ _28 = ((_20 as Ready).0: ()); ++ _32 = _28; ++ StorageDead(_28); ++ StorageDead(_25); + StorageDead(_23); -+ StorageDead(_21); -+ StorageDead(_18); -+ StorageDead(_17); -+ StorageDead(_12); -+ _39 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ drop((((*_39) as variant#3).0: ActionPermit<'_, T>)) -> [return: bb11, unwind unreachable]; ++ StorageDead(_20); ++ StorageDead(_19); ++ StorageDead(_14); ++ _41 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ drop((((*_41) as variant#3).0: ActionPermit<'_, T>)) -> [return: bb11, unwind unreachable]; + } + + bb11: { -+ _7 = Poll::<()>::Ready(move _30); -+ _40 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ discriminant((*_40)) = 1; ++ _7 = Poll::<()>::Ready(move _32); ++ _42 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ discriminant((*_42)) = 1; + goto -> bb2; + } + + bb12: { -+ StorageLive(_12); -+ StorageLive(_28); -+ StorageLive(_29); -+ _28 = move _9; -+ StorageDead(_29); -+ _31 = move _28; -+ StorageDead(_28); -+ _16 = const (); ++ StorageLive(_14); ++ StorageLive(_30); ++ StorageLive(_31); ++ _30 = move _9; ++ StorageDead(_31); ++ _33 = move _30; ++ StorageDead(_30); ++ _18 = const (); + goto -> bb5; + } + diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff index 494f5591e3250..7c50e102e869b 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff @@ -13,6 +13,8 @@ let mut _8: std::pin::Pin<&mut {async fn body of ActionPermit<'_, T>::perform()}>; let mut _9: &mut std::task::Context<'_>; let mut _10: &mut std::task::Context<'_>; ++ let mut _11: *mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _12: (); scope 1 { debug fut => _2; let _4: std::pin::Pin<&mut {async fn body of ActionPermit<'_, T>::perform()}>; @@ -21,28 +23,26 @@ scope 3 { } + scope 6 (inlined ActionPermit::<'_, T>::perform::{closure#0}) { -+ let _11: ActionPermit<'_, T>; -+ let mut _12: std::future::Ready<()>; -+ let mut _13: std::future::Ready<()>; -+ let mut _14: (); ++ let _13: ActionPermit<'_, T>; ++ let mut _14: std::future::Ready<()>; ++ let mut _15: std::future::Ready<()>; + let mut _16: (); -+ let _17: (); -+ let mut _18: std::task::Poll<()>; -+ let mut _19: std::pin::Pin<&mut std::future::Ready<()>>; -+ let mut _20: &mut std::future::Ready<()>; -+ let mut _21: &mut std::future::Ready<()>; -+ let mut _22: &mut std::task::Context<'_>; -+ let mut _23: &mut std::task::Context<'_>; ++ let mut _18: (); ++ let _19: (); ++ let mut _20: std::task::Poll<()>; ++ let mut _21: std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _22: &mut std::future::Ready<()>; ++ let mut _23: &mut std::future::Ready<()>; + let mut _24: &mut std::task::Context<'_>; -+ let mut _25: isize; -+ let mut _27: !; -+ let mut _28: &mut std::task::Context<'_>; -+ let mut _29: (); -+ let mut _30: (); -+ let mut _31: &mut std::task::Context<'_>; -+ let mut _32: u32; -+ let mut _33: &mut {async fn body of ActionPermit<'_, T>::perform()}; -+ let mut _34: &mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _25: &mut std::task::Context<'_>; ++ let mut _26: &mut std::task::Context<'_>; ++ let mut _27: isize; ++ let mut _29: !; ++ let mut _30: &mut std::task::Context<'_>; ++ let mut _31: (); ++ let mut _32: (); ++ let mut _33: &mut std::task::Context<'_>; ++ let mut _34: u32; + let mut _35: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _36: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _37: &mut {async fn body of ActionPermit<'_, T>::perform()}; @@ -51,15 +51,17 @@ + let mut _40: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _41: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _42: &mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _43: &mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _44: &mut {async fn body of ActionPermit<'_, T>::perform()}; + scope 7 { -+ let mut _15: std::future::Ready<()>; ++ let mut _17: std::future::Ready<()>; + scope 8 { -+ let _26: (); ++ let _28: (); + scope 9 { + } + } + scope 10 (inlined ready::<()>) { -+ let mut _43: std::option::Option<()>; ++ let mut _45: std::option::Option<()>; + } + } + } @@ -97,13 +99,11 @@ _10 = deref_copy (_1.1: &mut std::task::Context<'_>); _9 = &mut (*_10); - _7 = <{async fn body of ActionPermit<'_, T>::perform()} as Future>::poll(move _8, move _9) -> [return: bb3, unwind: bb5]; -+ StorageLive(_11); -+ StorageLive(_15); -+ StorageLive(_16); -+ StorageLive(_25); ++ StorageLive(_13); ++ StorageLive(_17); ++ StorageLive(_18); + StorageLive(_27); -+ StorageLive(_30); -+ StorageLive(_31); ++ StorageLive(_29); + StorageLive(_32); + StorageLive(_33); + StorageLive(_34); @@ -115,9 +115,11 @@ + StorageLive(_40); + StorageLive(_41); + StorageLive(_42); -+ _33 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ _32 = discriminant((*_33)); -+ switchInt(move _32) -> [0: bb5, 1: bb22, 2: bb21, 3: bb20, otherwise: bb10]; ++ StorageLive(_43); ++ StorageLive(_44); ++ _35 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ _34 = discriminant((*_35)); ++ switchInt(move _34) -> [0: bb5, 1: bb22, 2: bb21, 3: bb20, otherwise: bb10]; } - bb3: { @@ -135,6 +137,8 @@ + } + + bb4: { ++ StorageDead(_44); ++ StorageDead(_43); + StorageDead(_42); + StorageDead(_41); + StorageDead(_40); @@ -146,13 +150,11 @@ + StorageDead(_34); + StorageDead(_33); + StorageDead(_32); -+ StorageDead(_31); -+ StorageDead(_30); ++ StorageDead(_29); + StorageDead(_27); -+ StorageDead(_25); -+ StorageDead(_16); -+ StorageDead(_15); -+ StorageDead(_11); ++ StorageDead(_18); ++ StorageDead(_17); ++ StorageDead(_13); StorageDead(_9); StorageDead(_8); StorageDead(_7); @@ -161,69 +163,70 @@ _0 = const (); StorageDead(_4); - drop(_2) -> [return: bb4, unwind: bb6]; -+ drop(_2) -> [return: bb1, unwind: bb3]; ++ _11 = &raw mut _2; ++ _12 = std::ptr::drop_in_place::<{async fn body of ActionPermit<'_, T>::perform()}>(move _11) -> [return: bb1, unwind: bb3]; } - bb4: { - StorageDead(_2); - return; + bb5: { -+ _31 = move _9; -+ _34 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ _35 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ (((*_34) as variant#3).0: ActionPermit<'_, T>) = move ((*_35).0: ActionPermit<'_, T>); -+ StorageLive(_12); -+ StorageLive(_13); ++ _33 = move _9; ++ _36 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ _37 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ (((*_36) as variant#3).0: ActionPermit<'_, T>) = move ((*_37).0: ActionPermit<'_, T>); + StorageLive(_14); -+ _14 = (); -+ StorageLive(_43); -+ _43 = Option::<()>::Some(_14); -+ _13 = std::future::Ready::<()>(move _43); -+ StorageDead(_43); -+ StorageDead(_14); -+ _12 = as IntoFuture>::into_future(move _13) -> [return: bb6, unwind: bb17]; ++ StorageLive(_15); ++ StorageLive(_16); ++ _16 = (); ++ StorageLive(_45); ++ _45 = Option::<()>::Some(_16); ++ _15 = std::future::Ready::<()>(move _45); ++ StorageDead(_45); ++ StorageDead(_16); ++ _14 = as IntoFuture>::into_future(move _15) -> [return: bb6, unwind: bb17]; } - bb5 (cleanup): { - drop(_2) -> [return: bb6, unwind terminate(cleanup)]; + bb6: { -+ StorageDead(_13); -+ _36 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ (((*_36) as variant#3).1: std::future::Ready<()>) = move _12; ++ StorageDead(_15); ++ _38 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ (((*_38) as variant#3).1: std::future::Ready<()>) = move _14; + goto -> bb7; } - bb6 (cleanup): { - resume; + bb7: { -+ StorageLive(_17); -+ StorageLive(_18); + StorageLive(_19); + StorageLive(_20); + StorageLive(_21); -+ _37 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ _21 = &mut (((*_37) as variant#3).1: std::future::Ready<()>); -+ _20 = &mut (*_21); -+ _19 = Pin::<&mut std::future::Ready<()>>::new_unchecked(move _20) -> [return: bb8, unwind: bb15]; ++ StorageLive(_22); ++ StorageLive(_23); ++ _39 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ _23 = &mut (((*_39) as variant#3).1: std::future::Ready<()>); ++ _22 = &mut (*_23); ++ _21 = Pin::<&mut std::future::Ready<()>>::new_unchecked(move _22) -> [return: bb8, unwind: bb15]; + } + + bb8: { -+ StorageDead(_20); -+ StorageLive(_22); -+ StorageLive(_23); ++ StorageDead(_22); + StorageLive(_24); -+ _24 = _31; -+ _23 = move _24; -+ _22 = &mut (*_23); -+ StorageDead(_24); -+ _18 = as Future>::poll(move _19, move _22) -> [return: bb9, unwind: bb14]; ++ StorageLive(_25); ++ StorageLive(_26); ++ _26 = _33; ++ _25 = move _26; ++ _24 = &mut (*_25); ++ StorageDead(_26); ++ _20 = as Future>::poll(move _21, move _24) -> [return: bb9, unwind: bb14]; + } + + bb9: { -+ StorageDead(_22); -+ StorageDead(_19); -+ _25 = discriminant(_18); -+ switchInt(move _25) -> [0: bb12, 1: bb11, otherwise: bb10]; ++ StorageDead(_24); ++ StorageDead(_21); ++ _27 = discriminant(_20); ++ switchInt(move _27) -> [0: bb12, 1: bb11, otherwise: bb10]; + } + + bb10: { @@ -231,90 +234,90 @@ + } + + bb11: { -+ _17 = const (); ++ _19 = const (); ++ StorageDead(_25); + StorageDead(_23); -+ StorageDead(_21); -+ StorageDead(_18); -+ StorageDead(_17); -+ StorageLive(_28); -+ StorageLive(_29); -+ _29 = (); ++ StorageDead(_20); ++ StorageDead(_19); ++ StorageLive(_30); ++ StorageLive(_31); ++ _31 = (); + _7 = Poll::<()>::Pending; -+ StorageDead(_12); -+ StorageDead(_28); -+ StorageDead(_29); -+ _38 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ discriminant((*_38)) = 3; ++ StorageDead(_14); ++ StorageDead(_30); ++ StorageDead(_31); ++ _40 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ discriminant((*_40)) = 3; + goto -> bb4; + } + + bb12: { -+ StorageLive(_26); -+ _26 = ((_18 as Ready).0: ()); -+ _30 = _26; -+ StorageDead(_26); ++ StorageLive(_28); ++ _28 = ((_20 as Ready).0: ()); ++ _32 = _28; ++ StorageDead(_28); ++ StorageDead(_25); + StorageDead(_23); -+ StorageDead(_21); -+ StorageDead(_18); -+ StorageDead(_17); -+ StorageDead(_12); -+ _39 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ drop((((*_39) as variant#3).0: ActionPermit<'_, T>)) -> [return: bb13, unwind: bb19]; ++ StorageDead(_20); ++ StorageDead(_19); ++ StorageDead(_14); ++ _41 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ drop((((*_41) as variant#3).0: ActionPermit<'_, T>)) -> [return: bb13, unwind: bb19]; + } + + bb13: { -+ _7 = Poll::<()>::Ready(move _30); -+ _40 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ discriminant((*_40)) = 1; ++ _7 = Poll::<()>::Ready(move _32); ++ _42 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ discriminant((*_42)) = 1; + goto -> bb4; + } + + bb14 (cleanup): { -+ StorageDead(_22); -+ StorageDead(_19); -+ StorageDead(_23); ++ StorageDead(_24); ++ StorageDead(_21); ++ StorageDead(_25); + goto -> bb16; + } + + bb15 (cleanup): { -+ StorageDead(_20); -+ StorageDead(_19); ++ StorageDead(_22); ++ StorageDead(_21); + goto -> bb16; + } + + bb16 (cleanup): { -+ StorageDead(_21); -+ StorageDead(_18); -+ StorageDead(_17); ++ StorageDead(_23); ++ StorageDead(_20); ++ StorageDead(_19); + goto -> bb18; + } + + bb17 (cleanup): { -+ StorageDead(_13); ++ StorageDead(_15); + goto -> bb18; + } + + bb18 (cleanup): { -+ StorageDead(_12); -+ _41 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ drop((((*_41) as variant#3).0: ActionPermit<'_, T>)) -> [return: bb19, unwind terminate(cleanup)]; ++ StorageDead(_14); ++ _43 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ drop((((*_43) as variant#3).0: ActionPermit<'_, T>)) -> [return: bb19, unwind terminate(cleanup)]; + } + + bb19 (cleanup): { -+ _42 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); -+ discriminant((*_42)) = 2; ++ _44 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); ++ discriminant((*_44)) = 2; + goto -> bb2; + } + + bb20: { -+ StorageLive(_12); -+ StorageLive(_28); -+ StorageLive(_29); -+ _28 = move _9; -+ StorageDead(_29); -+ _31 = move _28; -+ StorageDead(_28); -+ _16 = const (); ++ StorageLive(_14); ++ StorageLive(_30); ++ StorageLive(_31); ++ _30 = move _9; ++ StorageDead(_31); ++ _33 = move _30; ++ StorageDead(_30); ++ _18 = const (); + goto -> bb7; + } + diff --git a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir index 8d182069adc99..39c5981d18e9b 100644 --- a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir @@ -9,12 +9,14 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () let mut _5: &mut std::iter::FilterMap, impl Fn(T) -> Option>; let mut _8: std::option::Option; let mut _9: isize; - let _11: (); + let mut _10: *mut std::iter::FilterMap, impl Fn(T) -> Option>; + let mut _11: (); + let _13: (); scope 1 { debug iter => _4; - let _10: U; + let _12: U; scope 2 { - debug x => _10; + debug x => _12; } scope 4 (inlined , impl Fn(T) -> Option> as Iterator>::next) { debug self => _5; @@ -55,7 +57,8 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () bb4: { StorageDead(_8); - drop(_4) -> [return: bb5, unwind continue]; + _10 = &raw mut _4; + _11 = std::ptr::drop_in_place::, impl Fn(T) -> Option>>(move _10) -> [return: bb5, unwind continue]; } bb5: { @@ -64,8 +67,8 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () } bb6: { - _10 = move ((_8 as Some).0: U); - _11 = opaque::(move _10) -> [return: bb7, unwind: bb9]; + _12 = move ((_8 as Some).0: U); + _13 = opaque::(move _12) -> [return: bb7, unwind: bb9]; } bb7: { 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 51d41e9ff051a..48672a0867d79 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -7,13 +7,15 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { let mut _3: std::iter::Map, impl Fn(T) -> U>; let mut _4: std::iter::Map, impl Fn(T) -> U>; let mut _5: &mut std::iter::Map, impl Fn(T) -> U>; - let mut _13: std::option::Option; - let _15: (); + let mut _10: *mut std::iter::Map, impl Fn(T) -> U>; + let mut _11: (); + let mut _15: std::option::Option; + let _17: (); scope 1 { debug iter => _4; - let _14: U; + let _16: U; scope 2 { - debug x => _14; + debug x => _16; } scope 4 (inlined , impl Fn(T) -> U> as Iterator>::next) { debug self => _5; @@ -24,11 +26,13 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { debug self => _7; debug f => _8; let mut _9: isize; - let _10: T; - let mut _11: (T,); - let mut _12: U; + let _12: T; + let mut _13: (T,); + let mut _14: U; scope 6 { - debug x => _10; + debug x => _12; + } + scope 7 (inlined std::ptr::drop_in_place::<&mut impl Fn(T) -> U> - shim(None)) { } } } @@ -48,7 +52,7 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { } bb2: { - StorageLive(_13); + StorageLive(_15); _5 = &mut _4; StorageLive(_8); StorageLive(_7); @@ -61,18 +65,19 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { StorageDead(_6); _8 = &mut (_4.1: impl Fn(T) -> U); StorageLive(_9); - StorageLive(_10); + StorageLive(_12); _9 = discriminant(_7); switchInt(move _9) -> [0: bb4, 1: bb6, otherwise: bb9]; } bb4: { - StorageDead(_10); + StorageDead(_12); StorageDead(_9); StorageDead(_7); StorageDead(_8); - StorageDead(_13); - drop(_4) -> [return: bb5, unwind continue]; + StorageDead(_15); + _10 = &raw mut _4; + _11 = std::ptr::drop_in_place::, impl Fn(T) -> U>>(move _10) -> [return: bb5, unwind continue]; } bb5: { @@ -81,27 +86,27 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { } bb6: { - _10 = move ((_7 as Some).0: T); - StorageLive(_12); - StorageLive(_11); - _11 = (_10,); - _12 = <&mut impl Fn(T) -> U as FnOnce<(T,)>>::call_once(move _8, move _11) -> [return: bb7, unwind: bb10]; + _12 = move ((_7 as Some).0: T); + StorageLive(_14); + StorageLive(_13); + _13 = (_12,); + _14 = <&mut impl Fn(T) -> U as FnOnce<(T,)>>::call_once(move _8, move _13) -> [return: bb7, unwind: bb10]; } bb7: { - StorageDead(_11); - _13 = Option::::Some(move _12); + StorageDead(_13); + _15 = Option::::Some(move _14); + StorageDead(_14); StorageDead(_12); - StorageDead(_10); StorageDead(_9); StorageDead(_7); StorageDead(_8); - _14 = move ((_13 as Some).0: U); - _15 = opaque::(move _14) -> [return: bb8, unwind: bb10]; + _16 = move ((_15 as Some).0: U); + _17 = opaque::(move _16) -> [return: bb8, unwind: bb10]; } bb8: { - StorageDead(_13); + StorageDead(_15); goto -> bb2; } 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 e537dd6a28ef8..a2b112c57c986 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 @@ -8,14 +8,18 @@ fn vec_move(_1: Vec) -> () { let mut _4: &mut std::vec::IntoIter; let mut _5: std::option::Option; let mut _6: isize; - let _8: (); + let _10: (); scope 1 { debug iter => _3; - let _7: impl Sized; + let _9: impl Sized; scope 2 { - debug x => _7; + debug x => _9; } } + scope 3 (inlined std::ptr::drop_in_place::> - shim(Some(std::vec::IntoIter))) { + let mut _7: &mut std::vec::IntoIter; + let mut _8: (); + } bb0: { StorageLive(_2); @@ -41,18 +45,21 @@ fn vec_move(_1: Vec) -> () { bb4: { StorageDead(_5); - drop(_3) -> [return: bb5, unwind continue]; + StorageLive(_7); + _7 = &mut _3; + _8 = as Drop>::drop(move _7) -> [return: bb5, unwind continue]; } bb5: { + StorageDead(_7); StorageDead(_3); StorageDead(_2); return; } bb6: { - _7 = move ((_5 as Some).0: impl Sized); - _8 = opaque::(move _7) -> [return: bb7, unwind: bb9]; + _9 = move ((_5 as Some).0: impl Sized); + _10 = opaque::(move _9) -> [return: bb7, unwind: bb9]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir index 96b4962854de9..39308b3bdd969 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -6,22 +6,24 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { debug f => _3; let mut _0: (); let mut _4: u32; - let mut _9: std::option::Option; - let mut _11: &impl Fn(u32); - let mut _12: (u32,); - let _13: (); + let mut _7: *mut impl Fn(u32); + let mut _8: (); + let mut _11: std::option::Option; + let mut _13: &impl Fn(u32); + let mut _14: (u32,); + let _15: (); scope 1 { debug ((iter: std::ops::Range).0: u32) => _4; debug ((iter: std::ops::Range).1: u32) => _2; - let _10: u32; + let _12: u32; scope 2 { - debug x => _10; + debug x => _12; } scope 4 (inlined iter::range::>::next) { scope 5 (inlined as iter::range::RangeIteratorImpl>::spec_next) { let mut _6: bool; - let _7: u32; - let mut _8: u32; + let _9: u32; + let mut _10: u32; scope 6 { } scope 7 (inlined std::cmp::impls::::lt) { @@ -40,8 +42,8 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { + StorageLive(_11); StorageLive(_9); - StorageLive(_7); StorageLive(_6); StorageLive(_5); _5 = _4; @@ -52,10 +54,11 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb2: { StorageDead(_6); - StorageDead(_7); StorageDead(_9); + StorageDead(_11); StorageDead(_4); - drop(_3) -> [return: bb3, unwind unreachable]; + _7 = &raw mut _3; + _8 = std::ptr::drop_in_place::(move _7) -> [return: bb3, unwind unreachable]; } bb3: { @@ -63,29 +66,29 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb4: { - _7 = _4; - StorageLive(_8); - _8 = ::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind unreachable]; + _9 = _4; + StorageLive(_10); + _10 = ::forward_unchecked(_9, const 1_usize) -> [return: bb5, unwind unreachable]; } bb5: { - _4 = move _8; - StorageDead(_8); - _9 = Option::::Some(_7); + _4 = move _10; + StorageDead(_10); + _11 = Option::::Some(_9); StorageDead(_6); - StorageDead(_7); - _10 = ((_9 as Some).0: u32); - StorageLive(_11); - _11 = &_3; - StorageLive(_12); - _12 = (_10,); - _13 = >::call(move _11, move _12) -> [return: bb6, unwind unreachable]; + StorageDead(_9); + _12 = ((_11 as Some).0: u32); + StorageLive(_13); + _13 = &_3; + StorageLive(_14); + _14 = (_12,); + _15 = >::call(move _13, move _14) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_12); + StorageDead(_14); + StorageDead(_13); StorageDead(_11); - StorageDead(_9); goto -> bb1; } } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index ce8e2bd083ed4..59eb4bc967e68 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -6,22 +6,24 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { debug f => _3; let mut _0: (); let mut _4: u32; - let mut _9: std::option::Option; - let mut _11: &impl Fn(u32); - let mut _12: (u32,); - let _13: (); + let mut _7: *mut impl Fn(u32); + let mut _8: (); + let mut _11: std::option::Option; + let mut _13: &impl Fn(u32); + let mut _14: (u32,); + let _15: (); scope 1 { debug ((iter: std::ops::Range).0: u32) => _4; debug ((iter: std::ops::Range).1: u32) => _2; - let _10: u32; + let _12: u32; scope 2 { - debug x => _10; + debug x => _12; } scope 4 (inlined iter::range::>::next) { scope 5 (inlined as iter::range::RangeIteratorImpl>::spec_next) { let mut _6: bool; - let _7: u32; - let mut _8: u32; + let _9: u32; + let mut _10: u32; scope 6 { } scope 7 (inlined std::cmp::impls::::lt) { @@ -40,8 +42,8 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { + StorageLive(_11); StorageLive(_9); - StorageLive(_7); StorageLive(_6); StorageLive(_5); _5 = _4; @@ -52,10 +54,11 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb2: { StorageDead(_6); - StorageDead(_7); StorageDead(_9); + StorageDead(_11); StorageDead(_4); - drop(_3) -> [return: bb3, unwind continue]; + _7 = &raw mut _3; + _8 = std::ptr::drop_in_place::(move _7) -> [return: bb3, unwind continue]; } bb3: { @@ -63,29 +66,29 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb4: { - _7 = _4; - StorageLive(_8); - _8 = ::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind: bb7]; + _9 = _4; + StorageLive(_10); + _10 = ::forward_unchecked(_9, const 1_usize) -> [return: bb5, unwind: bb7]; } bb5: { - _4 = move _8; - StorageDead(_8); - _9 = Option::::Some(_7); + _4 = move _10; + StorageDead(_10); + _11 = Option::::Some(_9); StorageDead(_6); - StorageDead(_7); - _10 = ((_9 as Some).0: u32); - StorageLive(_11); - _11 = &_3; - StorageLive(_12); - _12 = (_10,); - _13 = >::call(move _11, move _12) -> [return: bb6, unwind: bb7]; + StorageDead(_9); + _12 = ((_11 as Some).0: u32); + StorageLive(_13); + _13 = &_3; + StorageLive(_14); + _14 = (_12,); + _15 = >::call(move _13, move _14) -> [return: bb6, unwind: bb7]; } bb6: { - StorageDead(_12); + StorageDead(_14); + StorageDead(_13); StorageDead(_11); - StorageDead(_9); goto -> bb1; } 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 a7fe52d8390e9..5b31aebca3c38 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 @@ -10,14 +10,16 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _6: &mut std::ops::RangeInclusive; let mut _7: std::option::Option; let mut _8: isize; - let mut _10: &impl Fn(u32); - let mut _11: (u32,); - let _12: (); + let mut _9: *mut impl Fn(u32); + let mut _10: (); + let mut _12: &impl Fn(u32); + let mut _13: (u32,); + let _14: (); scope 1 { debug iter => _5; - let _9: u32; + let _11: u32; scope 2 { - debug x => _9; + debug x => _11; } scope 5 (inlined iter::range::>::next) { } @@ -48,7 +50,8 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb3: { StorageDead(_7); StorageDead(_5); - drop(_3) -> [return: bb4, unwind unreachable]; + _9 = &raw mut _3; + _10 = std::ptr::drop_in_place::(move _9) -> [return: bb4, unwind unreachable]; } bb4: { @@ -56,17 +59,17 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb5: { - _9 = ((_7 as Some).0: u32); - StorageLive(_10); - _10 = &_3; - StorageLive(_11); - _11 = (_9,); - _12 = >::call(move _10, move _11) -> [return: bb6, unwind unreachable]; + _11 = ((_7 as Some).0: u32); + StorageLive(_12); + _12 = &_3; + StorageLive(_13); + _13 = (_11,); + _14 = >::call(move _12, move _13) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_11); - StorageDead(_10); + StorageDead(_13); + StorageDead(_12); StorageDead(_7); goto -> bb1; } 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 3e2bbcd3c916f..d79d5c0866886 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 @@ -10,14 +10,16 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _6: &mut std::ops::RangeInclusive; let mut _7: std::option::Option; let mut _8: isize; - let mut _10: &impl Fn(u32); - let mut _11: (u32,); - let _12: (); + let mut _9: *mut impl Fn(u32); + let mut _10: (); + let mut _12: &impl Fn(u32); + let mut _13: (u32,); + let _14: (); scope 1 { debug iter => _5; - let _9: u32; + let _11: u32; scope 2 { - debug x => _9; + debug x => _11; } scope 5 (inlined iter::range::>::next) { } @@ -48,7 +50,8 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb3: { StorageDead(_7); StorageDead(_5); - drop(_3) -> [return: bb4, unwind continue]; + _9 = &raw mut _3; + _10 = std::ptr::drop_in_place::(move _9) -> [return: bb4, unwind continue]; } bb4: { @@ -56,17 +59,17 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb5: { - _9 = ((_7 as Some).0: u32); - StorageLive(_10); - _10 = &_3; - StorageLive(_11); - _11 = (_9,); - _12 = >::call(move _10, move _11) -> [return: bb6, unwind: bb8]; + _11 = ((_7 as Some).0: u32); + StorageLive(_12); + _12 = &_3; + StorageLive(_13); + _13 = (_11,); + _14 = >::call(move _12, move _13) -> [return: bb6, unwind: bb8]; } bb6: { - StorageDead(_11); - StorageDead(_10); + StorageDead(_13); + StorageDead(_12); StorageDead(_7); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.panic-abort.mir new file mode 100644 index 0000000000000..6a19f19b66a66 --- /dev/null +++ b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.panic-abort.mir @@ -0,0 +1,57 @@ +// MIR for `ezmap` after PreCodegen + +fn ezmap(_1: Option) -> Option { + debug x => _1; + let mut _0: std::option::Option; + scope 1 (inlined map::) { + let mut _2: isize; + let _3: i32; + let mut _4: (i32,); + let mut _5: i32; + scope 2 { + } + scope 3 (inlined std::ptr::drop_in_place::<{closure@$DIR/simple_option_map.rs:18:12: 18:15}> - shim(None)) { + } + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _2 = discriminant(_1); + switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb5]; + } + + bb1: { + _0 = const Option::::None; + goto -> bb4; + } + + bb2: { + _3 = ((_1 as Some).0: i32); + StorageLive(_5); + StorageLive(_4); + _4 = (_3,); + _5 = <{closure@$DIR/simple_option_map.rs:18:12: 18:15} as FnOnce<(i32,)>>::call_once(const ZeroSized: {closure@$DIR/simple_option_map.rs:18:12: 18:15}, move _4) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_4); + _0 = Option::::Some(move _5); + StorageDead(_5); + goto -> bb4; + } + + bb4: { + StorageDead(_3); + StorageDead(_2); + return; + } + + bb5: { + unreachable; + } +} + +ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ +} diff --git a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.panic-unwind.mir similarity index 51% rename from tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir rename to tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.panic-unwind.mir index 030f9c3b93e0c..6da43e87ca83e 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.panic-unwind.mir @@ -3,42 +3,51 @@ fn ezmap(_1: Option) -> Option { debug x => _1; let mut _0: std::option::Option; - scope 1 (inlined map::) { + scope 1 (inlined map::) { let mut _2: isize; let _3: i32; - let mut _4: i32; + let mut _4: (i32,); + let mut _5: i32; scope 2 { - scope 3 (inlined ezmap::{closure#0}) { - } + } + scope 3 (inlined std::ptr::drop_in_place::<{closure@$DIR/simple_option_map.rs:18:12: 18:15}> - shim(None)) { } } bb0: { StorageLive(_2); + StorageLive(_3); _2 = discriminant(_1); - switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4]; + switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb5]; } bb1: { _0 = const Option::::None; - goto -> bb3; + goto -> bb4; } bb2: { _3 = ((_1 as Some).0: i32); + StorageLive(_5); StorageLive(_4); - _4 = Add(_3, const 1_i32); - _0 = Option::::Some(move _4); - StorageDead(_4); - goto -> bb3; + _4 = (_3,); + _5 = <{closure@$DIR/simple_option_map.rs:18:12: 18:15} as FnOnce<(i32,)>>::call_once(const ZeroSized: {closure@$DIR/simple_option_map.rs:18:12: 18:15}, move _4) -> [return: bb3, unwind continue]; } bb3: { + StorageDead(_4); + _0 = Option::::Some(move _5); + StorageDead(_5); + goto -> bb4; + } + + bb4: { + StorageDead(_3); StorageDead(_2); return; } - bb4: { + bb5: { unreachable; } } diff --git a/tests/mir-opt/pre-codegen/simple_option_map.rs b/tests/mir-opt/pre-codegen/simple_option_map.rs index 0c432be0419bc..82f074c0855c8 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.rs +++ b/tests/mir-opt/pre-codegen/simple_option_map.rs @@ -1,3 +1,4 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // skip-filecheck //@ compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 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 953e7550479da..b955d6785a222 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 @@ -7,25 +7,27 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _11: std::slice::Iter<'_, T>; let mut _12: std::iter::Enumerate>; let mut _13: std::iter::Enumerate>; - let mut _21: std::option::Option<(usize, &T)>; - let mut _24: &impl Fn(usize, &T); - let mut _25: (usize, &T); - let _26: (); + let mut _17: *mut impl Fn(usize, &T); + let mut _18: (); + let mut _23: std::option::Option<(usize, &T)>; + let mut _26: &impl Fn(usize, &T); + let mut _27: (usize, &T); + let _28: (); scope 1 { debug iter => _13; - let _22: usize; - let _23: &T; + let _24: usize; + let _25: &T; scope 2 { - debug i => _22; - debug x => _23; + debug i => _24; + debug x => _25; } scope 17 (inlined > as Iterator>::next) { let mut _14: &mut std::slice::Iter<'_, T>; let mut _15: std::option::Option<&T>; - let mut _19: (usize, bool); - let mut _20: (usize, &T); + let mut _21: (usize, bool); + let mut _22: (usize, &T); scope 18 { - let _18: usize; + let _20: usize; scope 23 { } } @@ -41,7 +43,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } scope 24 (inlined as Try>::branch) { let mut _16: isize; - let _17: &T; + let _19: &T; scope 25 { } } @@ -132,9 +134,9 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { + StorageLive(_23); + StorageLive(_20); StorageLive(_21); - StorageLive(_18); - StorageLive(_19); StorageLive(_15); StorageLive(_14); _14 = &mut (_13.0: std::slice::Iter<'_, T>); @@ -151,11 +153,12 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb6: { StorageDead(_16); StorageDead(_15); - StorageDead(_19); - StorageDead(_18); StorageDead(_21); + StorageDead(_20); + StorageDead(_23); StorageDead(_13); - drop(_2) -> [return: bb7, unwind unreachable]; + _17 = &raw mut _2; + _18 = std::ptr::drop_in_place::(move _17) -> [return: bb7, unwind unreachable]; } bb7: { @@ -163,35 +166,35 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _17 = move ((_15 as Some).0: &T); + _19 = move ((_15 as Some).0: &T); StorageDead(_16); StorageDead(_15); - _18 = (_13.1: usize); - _19 = AddWithOverflow((_13.1: usize), const 1_usize); - assert(!move (_19.1: bool), "attempt to compute `{} + {}`, which would overflow", (_13.1: usize), const 1_usize) -> [success: bb9, unwind unreachable]; + _20 = (_13.1: usize); + _21 = AddWithOverflow((_13.1: usize), const 1_usize); + assert(!move (_21.1: bool), "attempt to compute `{} + {}`, which would overflow", (_13.1: usize), const 1_usize) -> [success: bb9, unwind unreachable]; } bb9: { - (_13.1: usize) = move (_19.0: usize); - StorageLive(_20); - _20 = (_18, _17); - _21 = Option::<(usize, &T)>::Some(move _20); + (_13.1: usize) = move (_21.0: usize); + StorageLive(_22); + _22 = (_20, _19); + _23 = Option::<(usize, &T)>::Some(move _22); + StorageDead(_22); + StorageDead(_21); StorageDead(_20); - StorageDead(_19); - StorageDead(_18); - _22 = (((_21 as Some).0: (usize, &T)).0: usize); - _23 = (((_21 as Some).0: (usize, &T)).1: &T); - StorageLive(_24); - _24 = &_2; - StorageLive(_25); - _25 = (_22, _23); - _26 = >::call(move _24, move _25) -> [return: bb10, unwind unreachable]; + _24 = (((_23 as Some).0: (usize, &T)).0: usize); + _25 = (((_23 as Some).0: (usize, &T)).1: &T); + StorageLive(_26); + _26 = &_2; + StorageLive(_27); + _27 = (_24, _25); + _28 = >::call(move _26, move _27) -> [return: bb10, unwind unreachable]; } bb10: { - StorageDead(_25); - StorageDead(_24); - StorageDead(_21); + StorageDead(_27); + StorageDead(_26); + StorageDead(_23); goto -> bb4; } 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 4c766c6497a2e..29d777bc750c9 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 @@ -10,16 +10,18 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _14: &mut std::iter::Enumerate>; let mut _15: std::option::Option<(usize, &T)>; let mut _16: isize; - let mut _19: &impl Fn(usize, &T); - let mut _20: (usize, &T); - let _21: (); + let mut _17: *mut impl Fn(usize, &T); + let mut _18: (); + let mut _21: &impl Fn(usize, &T); + let mut _22: (usize, &T); + let _23: (); scope 1 { debug iter => _13; - let _17: usize; - let _18: &T; + let _19: usize; + let _20: &T; scope 2 { - debug i => _17; - debug x => _18; + debug i => _19; + debug x => _20; } } scope 3 (inlined core::slice::::iter) { @@ -120,7 +122,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb6: { StorageDead(_15); StorageDead(_13); - drop(_2) -> [return: bb7, unwind continue]; + _17 = &raw mut _2; + _18 = std::ptr::drop_in_place::(move _17) -> [return: bb7, unwind continue]; } bb7: { @@ -128,18 +131,18 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _17 = (((_15 as Some).0: (usize, &T)).0: usize); - _18 = (((_15 as Some).0: (usize, &T)).1: &T); - StorageLive(_19); - _19 = &_2; - StorageLive(_20); - _20 = (_17, _18); - _21 = >::call(move _19, move _20) -> [return: bb9, unwind: bb11]; + _19 = (((_15 as Some).0: (usize, &T)).0: usize); + _20 = (((_15 as Some).0: (usize, &T)).1: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (_19, _20); + _23 = >::call(move _21, move _22) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_20); - StorageDead(_19); + StorageDead(_22); + StorageDead(_21); StorageDead(_15); goto -> bb4; } 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 03de9fd938ec4..16f8f40a7191f 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 @@ -9,14 +9,16 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _13: &mut std::slice::Iter<'_, T>; let mut _14: std::option::Option<&T>; let mut _15: isize; - let mut _17: &impl Fn(&T); - let mut _18: (&T,); - let _19: (); + let mut _16: *mut impl Fn(&T); + let mut _17: (); + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { debug iter => _12; - let _16: &T; + let _18: &T; scope 2 { - debug x => _16; + debug x => _18; } } scope 3 (inlined core::slice::::iter) { @@ -110,7 +112,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb6: { StorageDead(_14); StorageDead(_12); - drop(_2) -> [return: bb7, unwind unreachable]; + _16 = &raw mut _2; + _17 = std::ptr::drop_in_place::(move _16) -> [return: bb7, unwind unreachable]; } bb7: { @@ -118,17 +121,17 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _16 = ((_14 as Some).0: &T); - StorageLive(_17); - _17 = &_2; - StorageLive(_18); - _18 = (_16,); - _19 = >::call(move _17, move _18) -> [return: bb9, unwind unreachable]; + _18 = ((_14 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (_18,); + _21 = >::call(move _19, move _20) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_18); - StorageDead(_17); + StorageDead(_20); + StorageDead(_19); StorageDead(_14); goto -> bb4; } 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 c7c722274f24e..035c9213f97ed 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 @@ -9,14 +9,16 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _13: &mut std::slice::Iter<'_, T>; let mut _14: std::option::Option<&T>; let mut _15: isize; - let mut _17: &impl Fn(&T); - let mut _18: (&T,); - let _19: (); + let mut _16: *mut impl Fn(&T); + let mut _17: (); + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { debug iter => _12; - let _16: &T; + let _18: &T; scope 2 { - debug x => _16; + debug x => _18; } } scope 3 (inlined core::slice::::iter) { @@ -110,7 +112,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb6: { StorageDead(_14); StorageDead(_12); - drop(_2) -> [return: bb7, unwind continue]; + _16 = &raw mut _2; + _17 = std::ptr::drop_in_place::(move _16) -> [return: bb7, unwind continue]; } bb7: { @@ -118,17 +121,17 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _16 = ((_14 as Some).0: &T); - StorageLive(_17); - _17 = &_2; - StorageLive(_18); - _18 = (_16,); - _19 = >::call(move _17, move _18) -> [return: bb9, unwind: bb11]; + _18 = ((_14 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (_18,); + _21 = >::call(move _19, move _20) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_18); - StorageDead(_17); + StorageDead(_20); + StorageDead(_19); StorageDead(_14); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir index cea2fcbcdc0b2..ac230a025075b 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir @@ -6,28 +6,30 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _0: (); let mut _3: usize; let mut _4: usize; - let mut _9: std::option::Option; - let mut _11: usize; - let mut _12: bool; - let mut _14: &impl Fn(usize, &T); - let mut _15: (usize, &T); - let _16: (); + let mut _7: *mut impl Fn(usize, &T); + let mut _8: (); + let mut _11: std::option::Option; + let mut _13: usize; + let mut _14: bool; + let mut _16: &impl Fn(usize, &T); + let mut _17: (usize, &T); + let _18: (); scope 1 { debug ((iter: std::ops::Range).0: usize) => _4; debug ((iter: std::ops::Range).1: usize) => _3; - let _10: usize; + let _12: usize; scope 2 { - debug i => _10; - let _13: &T; + debug i => _12; + let _15: &T; scope 3 { - debug x => _13; + debug x => _15; } } scope 5 (inlined iter::range::>::next) { scope 6 (inlined as iter::range::RangeIteratorImpl>::spec_next) { let mut _6: bool; - let _7: usize; - let mut _8: usize; + let _9: usize; + let mut _10: usize; scope 7 { } scope 8 (inlined std::cmp::impls::::lt) { @@ -47,8 +49,8 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb1: { + StorageLive(_11); StorageLive(_9); - StorageLive(_7); StorageLive(_6); StorageLive(_5); _5 = _4; @@ -59,10 +61,11 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb2: { StorageDead(_6); - StorageDead(_7); StorageDead(_9); + StorageDead(_11); StorageDead(_4); - drop(_2) -> [return: bb3, unwind unreachable]; + _7 = &raw mut _2; + _8 = std::ptr::drop_in_place::(move _7) -> [return: bb3, unwind unreachable]; } bb3: { @@ -70,36 +73,36 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { - _7 = _4; - StorageLive(_8); - _8 = ::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind unreachable]; + _9 = _4; + StorageLive(_10); + _10 = ::forward_unchecked(_9, const 1_usize) -> [return: bb5, unwind unreachable]; } bb5: { - _4 = move _8; - StorageDead(_8); - _9 = Option::::Some(_7); + _4 = move _10; + StorageDead(_10); + _11 = Option::::Some(_9); StorageDead(_6); - StorageDead(_7); - _10 = ((_9 as Some).0: usize); - _11 = Len((*_1)); - _12 = Lt(_10, _11); - assert(move _12, "index out of bounds: the length is {} but the index is {}", move _11, _10) -> [success: bb6, unwind unreachable]; + StorageDead(_9); + _12 = ((_11 as Some).0: usize); + _13 = Len((*_1)); + _14 = Lt(_12, _13); + assert(move _14, "index out of bounds: the length is {} but the index is {}", move _13, _12) -> [success: bb6, unwind unreachable]; } bb6: { - _13 = &(*_1)[_10]; - StorageLive(_14); - _14 = &_2; - StorageLive(_15); - _15 = (_10, _13); - _16 = >::call(move _14, move _15) -> [return: bb7, unwind unreachable]; + _15 = &(*_1)[_12]; + StorageLive(_16); + _16 = &_2; + StorageLive(_17); + _17 = (_12, _15); + _18 = >::call(move _16, move _17) -> [return: bb7, unwind unreachable]; } bb7: { - StorageDead(_15); - StorageDead(_14); - StorageDead(_9); + StorageDead(_17); + StorageDead(_16); + StorageDead(_11); goto -> bb1; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index bd658a770ea91..20049d40f6986 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -6,28 +6,30 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _0: (); let mut _3: usize; let mut _4: usize; - let mut _9: std::option::Option; - let mut _11: usize; - let mut _12: bool; - let mut _14: &impl Fn(usize, &T); - let mut _15: (usize, &T); - let _16: (); + let mut _7: *mut impl Fn(usize, &T); + let mut _8: (); + let mut _11: std::option::Option; + let mut _13: usize; + let mut _14: bool; + let mut _16: &impl Fn(usize, &T); + let mut _17: (usize, &T); + let _18: (); scope 1 { debug ((iter: std::ops::Range).0: usize) => _4; debug ((iter: std::ops::Range).1: usize) => _3; - let _10: usize; + let _12: usize; scope 2 { - debug i => _10; - let _13: &T; + debug i => _12; + let _15: &T; scope 3 { - debug x => _13; + debug x => _15; } } scope 5 (inlined iter::range::>::next) { scope 6 (inlined as iter::range::RangeIteratorImpl>::spec_next) { let mut _6: bool; - let _7: usize; - let mut _8: usize; + let _9: usize; + let mut _10: usize; scope 7 { } scope 8 (inlined std::cmp::impls::::lt) { @@ -47,8 +49,8 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb1: { + StorageLive(_11); StorageLive(_9); - StorageLive(_7); StorageLive(_6); StorageLive(_5); _5 = _4; @@ -59,10 +61,11 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb2: { StorageDead(_6); - StorageDead(_7); StorageDead(_9); + StorageDead(_11); StorageDead(_4); - drop(_2) -> [return: bb3, unwind continue]; + _7 = &raw mut _2; + _8 = std::ptr::drop_in_place::(move _7) -> [return: bb3, unwind continue]; } bb3: { @@ -70,36 +73,36 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { - _7 = _4; - StorageLive(_8); - _8 = ::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind: bb8]; + _9 = _4; + StorageLive(_10); + _10 = ::forward_unchecked(_9, const 1_usize) -> [return: bb5, unwind: bb8]; } bb5: { - _4 = move _8; - StorageDead(_8); - _9 = Option::::Some(_7); + _4 = move _10; + StorageDead(_10); + _11 = Option::::Some(_9); StorageDead(_6); - StorageDead(_7); - _10 = ((_9 as Some).0: usize); - _11 = Len((*_1)); - _12 = Lt(_10, _11); - assert(move _12, "index out of bounds: the length is {} but the index is {}", move _11, _10) -> [success: bb6, unwind: bb8]; + StorageDead(_9); + _12 = ((_11 as Some).0: usize); + _13 = Len((*_1)); + _14 = Lt(_12, _13); + assert(move _14, "index out of bounds: the length is {} but the index is {}", move _13, _12) -> [success: bb6, unwind: bb8]; } bb6: { - _13 = &(*_1)[_10]; - StorageLive(_14); - _14 = &_2; - StorageLive(_15); - _15 = (_10, _13); - _16 = >::call(move _14, move _15) -> [return: bb7, unwind: bb8]; + _15 = &(*_1)[_12]; + StorageLive(_16); + _16 = &_2; + StorageLive(_17); + _17 = (_12, _15); + _18 = >::call(move _16, move _17) -> [return: bb7, unwind: bb8]; } bb7: { - StorageDead(_15); - StorageDead(_14); - StorageDead(_9); + StorageDead(_17); + StorageDead(_16); + StorageDead(_11); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index fbb887fe76a59..24cebbb2c95fc 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -9,14 +9,16 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _13: std::iter::Rev>; let mut _15: std::option::Option<&T>; let mut _16: isize; - let mut _18: &impl Fn(&T); - let mut _19: (&T,); - let _20: (); + let mut _17: *mut impl Fn(&T); + let mut _18: (); + let mut _20: &impl Fn(&T); + let mut _21: (&T,); + let _22: (); scope 1 { debug iter => _13; - let _17: &T; + let _19: &T; scope 2 { - debug x => _17; + debug x => _19; } scope 17 (inlined > as Iterator>::next) { let mut _14: &mut std::slice::Iter<'_, T>; @@ -122,7 +124,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb6: { StorageDead(_15); StorageDead(_13); - drop(_2) -> [return: bb7, unwind unreachable]; + _17 = &raw mut _2; + _18 = std::ptr::drop_in_place::(move _17) -> [return: bb7, unwind unreachable]; } bb7: { @@ -130,17 +133,17 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _17 = ((_15 as Some).0: &T); - StorageLive(_18); - _18 = &_2; - StorageLive(_19); - _19 = (_17,); - _20 = >::call(move _18, move _19) -> [return: bb9, unwind unreachable]; + _19 = ((_15 as Some).0: &T); + StorageLive(_20); + _20 = &_2; + StorageLive(_21); + _21 = (_19,); + _22 = >::call(move _20, move _21) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_19); - StorageDead(_18); + StorageDead(_21); + StorageDead(_20); StorageDead(_15); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index db9409f72ab1a..400f57226e208 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -9,14 +9,16 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _13: std::iter::Rev>; let mut _15: std::option::Option<&T>; let mut _16: isize; - let mut _18: &impl Fn(&T); - let mut _19: (&T,); - let _20: (); + let mut _17: *mut impl Fn(&T); + let mut _18: (); + let mut _20: &impl Fn(&T); + let mut _21: (&T,); + let _22: (); scope 1 { debug iter => _13; - let _17: &T; + let _19: &T; scope 2 { - debug x => _17; + debug x => _19; } scope 17 (inlined > as Iterator>::next) { let mut _14: &mut std::slice::Iter<'_, T>; @@ -122,7 +124,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb6: { StorageDead(_15); StorageDead(_13); - drop(_2) -> [return: bb7, unwind continue]; + _17 = &raw mut _2; + _18 = std::ptr::drop_in_place::(move _17) -> [return: bb7, unwind continue]; } bb7: { @@ -130,17 +133,17 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _17 = ((_15 as Some).0: &T); - StorageLive(_18); - _18 = &_2; - StorageLive(_19); - _19 = (_17,); - _20 = >::call(move _18, move _19) -> [return: bb9, unwind: bb11]; + _19 = ((_15 as Some).0: &T); + StorageLive(_20); + _20 = &_2; + StorageLive(_21); + _21 = (_19,); + _22 = >::call(move _20, move _21) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_19); - StorageDead(_18); + StorageDead(_21); + StorageDead(_20); StorageDead(_15); goto -> bb4; } diff --git a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff index 0c73602bec84b..1f6879e5fbe84 100644 --- a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff +++ b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff @@ -7,16 +7,23 @@ let _2: (); let mut _3: T; scope 1 (inlined std::mem::drop::) { + let mut _4: *mut T; + let mut _5: (); } bb0: { nop; StorageLive(_3); _3 = move _1; - drop(_3) -> [return: bb1, unwind unreachable]; + StorageLive(_4); + nop; + _4 = &raw mut _3; + _5 = std::ptr::drop_in_place::(move _4) -> [return: bb1, unwind unreachable]; } bb1: { + nop; + StorageDead(_4); StorageDead(_3); nop; nop; diff --git a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff index 59cce9fbcdd0a..6efb9d80149a5 100644 --- a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff @@ -7,13 +7,18 @@ let _2: (); let mut _3: T; scope 1 (inlined std::mem::drop::) { + let mut _4: *mut T; + let mut _5: (); } bb0: { nop; StorageLive(_3); _3 = move _1; - drop(_3) -> [return: bb2, unwind: bb1]; + StorageLive(_4); + nop; + _4 = &raw mut _3; + _5 = std::ptr::drop_in_place::(move _4) -> [return: bb2, unwind: bb1]; } bb1 (cleanup): { @@ -21,6 +26,8 @@ } bb2: { + nop; + StorageDead(_4); StorageDead(_3); nop; nop; diff --git a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff index 428b366b5a684..8b1dcc3896ce4 100644 --- a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff +++ b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff @@ -7,16 +7,23 @@ let _2: (); let mut _3: std::vec::Vec; scope 1 (inlined std::mem::drop::>) { + let mut _4: *mut std::vec::Vec; + let mut _5: (); } bb0: { nop; StorageLive(_3); _3 = move _1; - drop(_3) -> [return: bb1, unwind unreachable]; + StorageLive(_4); + nop; + _4 = &raw mut _3; + _5 = std::ptr::drop_in_place::>(move _4) -> [return: bb1, unwind unreachable]; } bb1: { + nop; + StorageDead(_4); StorageDead(_3); nop; nop; diff --git a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff index 445c1f82a96f8..d891e0a45ee4c 100644 --- a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff @@ -7,13 +7,18 @@ let _2: (); let mut _3: std::vec::Vec; scope 1 (inlined std::mem::drop::>) { + let mut _4: *mut std::vec::Vec; + let mut _5: (); } bb0: { nop; StorageLive(_3); _3 = move _1; - drop(_3) -> [return: bb2, unwind: bb1]; + StorageLive(_4); + nop; + _4 = &raw mut _3; + _5 = std::ptr::drop_in_place::>(move _4) -> [return: bb2, unwind: bb1]; } bb1 (cleanup): { @@ -21,6 +26,8 @@ } bb2: { + nop; + StorageDead(_4); StorageDead(_3); nop; nop; diff --git a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff index 5afeb8620a176..aef5a88a6a74e 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff @@ -7,19 +7,24 @@ let _2: (); let mut _3: bool; scope 1 (inlined std::mem::drop::) { + let mut _4: *mut bool; + let mut _5: (); + scope 2 (inlined std::ptr::drop_in_place:: - shim(None)) { + } } bb0: { -- nop; + nop; StorageLive(_3); _3 = _1; -- drop(_3) -> [return: bb1, unwind unreachable]; -- } -- -- bb1: { + StorageLive(_4); + nop; + _4 = &raw mut _3; + nop; + StorageDead(_4); StorageDead(_3); -- nop; -- nop; + nop; + nop; return; } } diff --git a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff index b9919ddea568a..aef5a88a6a74e 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff @@ -7,19 +7,24 @@ let _2: (); let mut _3: bool; scope 1 (inlined std::mem::drop::) { + let mut _4: *mut bool; + let mut _5: (); + scope 2 (inlined std::ptr::drop_in_place:: - shim(None)) { + } } bb0: { -- nop; + nop; StorageLive(_3); _3 = _1; -- drop(_3) -> [return: bb1, unwind continue]; -- } -- -- bb1: { + StorageLive(_4); + nop; + _4 = &raw mut _3; + nop; + StorageDead(_4); StorageDead(_3); -- nop; -- nop; + nop; + nop; return; } } diff --git a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff index b89432dd6d626..cc7aa95748af9 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff @@ -7,19 +7,24 @@ let _2: (); let mut _3: T; scope 1 (inlined std::mem::drop::) { + let mut _4: *mut T; + let mut _5: (); + scope 2 (inlined std::ptr::drop_in_place:: - shim(None)) { + } } bb0: { -- nop; + nop; StorageLive(_3); _3 = _1; -- drop(_3) -> [return: bb1, unwind unreachable]; -- } -- -- bb1: { + StorageLive(_4); + nop; + _4 = &raw mut _3; + nop; + StorageDead(_4); StorageDead(_3); -- nop; -- nop; + nop; + nop; return; } } diff --git a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff index 48d0260533223..cc7aa95748af9 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff @@ -7,19 +7,24 @@ let _2: (); let mut _3: T; scope 1 (inlined std::mem::drop::) { + let mut _4: *mut T; + let mut _5: (); + scope 2 (inlined std::ptr::drop_in_place:: - shim(None)) { + } } bb0: { -- nop; + nop; StorageLive(_3); _3 = _1; -- drop(_3) -> [return: bb1, unwind continue]; -- } -- -- bb1: { + StorageLive(_4); + nop; + _4 = &raw mut _3; + nop; + StorageDead(_4); StorageDead(_3); -- nop; -- nop; + nop; + nop; return; } } diff --git a/tests/mir-opt/remove_unneeded_drops.opt_in_place.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.opt_in_place.RemoveUnneededDrops.panic-abort.diff new file mode 100644 index 0000000000000..79fb1bae124db --- /dev/null +++ b/tests/mir-opt/remove_unneeded_drops.opt_in_place.RemoveUnneededDrops.panic-abort.diff @@ -0,0 +1,22 @@ +- // MIR for `opt_in_place` before RemoveUnneededDrops ++ // MIR for `opt_in_place` after RemoveUnneededDrops + + fn opt_in_place(_1: u32) -> () { + debug x => _1; + let mut _0: (); + let mut _2: *mut u32; + let mut _3: &mut u32; + scope 1 (inlined std::ptr::drop_in_place:: - shim(None)) { + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &mut _1; + _2 = &raw mut (*_3); + StorageDead(_2); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/remove_unneeded_drops.opt_in_place.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.opt_in_place.RemoveUnneededDrops.panic-unwind.diff new file mode 100644 index 0000000000000..79fb1bae124db --- /dev/null +++ b/tests/mir-opt/remove_unneeded_drops.opt_in_place.RemoveUnneededDrops.panic-unwind.diff @@ -0,0 +1,22 @@ +- // MIR for `opt_in_place` before RemoveUnneededDrops ++ // MIR for `opt_in_place` after RemoveUnneededDrops + + fn opt_in_place(_1: u32) -> () { + debug x => _1; + let mut _0: (); + let mut _2: *mut u32; + let mut _3: &mut u32; + scope 1 (inlined std::ptr::drop_in_place:: - shim(None)) { + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &mut _1; + _2 = &raw mut (*_3); + StorageDead(_2); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/remove_unneeded_drops.rs b/tests/mir-opt/remove_unneeded_drops.rs index cad79e0aa0cbc..86c8d08795605 100644 --- a/tests/mir-opt/remove_unneeded_drops.rs +++ b/tests/mir-opt/remove_unneeded_drops.rs @@ -22,9 +22,15 @@ fn cannot_opt_generic(x: T) { drop(x); } +// EMIT_MIR remove_unneeded_drops.opt_in_place.RemoveUnneededDrops.diff +fn opt_in_place(mut x: u32) { + unsafe { std::ptr::drop_in_place(&mut x) } +} + fn main() { opt(true); opt_generic_copy(42); cannot_opt_generic(42); dont_opt(vec![true]); + opt_in_place(42); }