diff --git a/compiler/rustc_mir_dataflow/src/impls/initialized.rs b/compiler/rustc_mir_dataflow/src/impls/initialized.rs index 18165b0b9bd08..961a6d42891ed 100644 --- a/compiler/rustc_mir_dataflow/src/impls/initialized.rs +++ b/compiler/rustc_mir_dataflow/src/impls/initialized.rs @@ -558,6 +558,80 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> { } } +/// A dataflow analysis that tracks locals that are maybe uninitialized. +/// +/// This is a simpler analysis than `MaybeUninitializedPlaces`, because it does not track +/// individual fields. +pub struct MaybeUninitializedLocals; + +impl MaybeUninitializedLocals { + pub fn new() -> Self { + Self {} + } +} + +impl<'tcx> Analysis<'tcx> for MaybeUninitializedLocals { + type Domain = DenseBitSet; + + const NAME: &'static str = "maybe_uninit_locals"; + + fn bottom_value(&self, body: &Body<'tcx>) -> Self::Domain { + // bottom = all locals are initialized. + DenseBitSet::new_empty(body.local_decls.len()) + } + + fn initialize_start_block(&self, body: &Body<'tcx>, state: &mut Self::Domain) { + // All locals start as uninitialized... + state.insert_all(); + // ...except for arguments, which are definitely initialized. + for arg in body.args_iter() { + state.remove(arg); + } + } + + fn apply_primary_statement_effect( + &mut self, + state: &mut Self::Domain, + statement: &mir::Statement<'tcx>, + _location: Location, + ) { + match statement.kind { + // An assignment makes a local initialized. + mir::StatementKind::Assign(box (place, _)) => { + if let Some(local) = place.as_local() { + state.remove(local); + } + } + // Deinit makes the local uninitialized. + mir::StatementKind::Deinit(box place) => { + // A deinit makes a local uninitialized. + if let Some(local) = place.as_local() { + state.insert(local); + } + } + // Storage{Live,Dead} makes a local uninitialized. + mir::StatementKind::StorageLive(local) | mir::StatementKind::StorageDead(local) => { + state.insert(local); + } + _ => {} + } + } + + fn apply_call_return_effect( + &mut self, + state: &mut Self::Domain, + _block: mir::BasicBlock, + return_places: CallReturnPlaces<'_, 'tcx>, + ) { + // The return place of a call is initialized. + return_places.for_each(|place| { + if let Some(local) = place.as_local() { + state.remove(local); + } + }); + } +} + /// There can be many more `InitIndex` than there are locals in a MIR body. /// We use a mixed bitset to avoid paying too high a memory footprint. pub type EverInitializedPlacesDomain = MixedBitSet; diff --git a/compiler/rustc_mir_dataflow/src/impls/mod.rs b/compiler/rustc_mir_dataflow/src/impls/mod.rs index 3f29b819a6d18..695298529c19c 100644 --- a/compiler/rustc_mir_dataflow/src/impls/mod.rs +++ b/compiler/rustc_mir_dataflow/src/impls/mod.rs @@ -6,7 +6,7 @@ mod storage_liveness; pub use self::borrowed_locals::{MaybeBorrowedLocals, borrowed_locals}; pub use self::initialized::{ EverInitializedPlaces, EverInitializedPlacesDomain, MaybeInitializedPlaces, - MaybeUninitializedPlaces, MaybeUninitializedPlacesDomain, + MaybeUninitializedLocals, MaybeUninitializedPlaces, MaybeUninitializedPlacesDomain, }; pub use self::liveness::{ MaybeLiveLocals, MaybeTransitiveLiveLocals, TransferFunction as LivenessTransferFunction, diff --git a/compiler/rustc_mir_transform/src/copy_prop.rs b/compiler/rustc_mir_transform/src/copy_prop.rs index fe78a104fa0b6..d8b35f2358930 100644 --- a/compiler/rustc_mir_transform/src/copy_prop.rs +++ b/compiler/rustc_mir_transform/src/copy_prop.rs @@ -3,6 +3,8 @@ use rustc_index::bit_set::DenseBitSet; use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; +use rustc_mir_dataflow::impls::MaybeUninitializedLocals; +use rustc_mir_dataflow::{Analysis, ResultsCursor}; use tracing::{debug, instrument}; use crate::ssa::SsaLocals; @@ -16,7 +18,7 @@ use crate::ssa::SsaLocals; /// _d = move? _c /// where each of the locals is only assigned once. /// -/// We want to replace all those locals by `_a`, either copied or moved. +/// We want to replace all those locals by `_a` (the "head"), either copied or moved. pub(super) struct CopyProp; impl<'tcx> crate::MirPass<'tcx> for CopyProp { @@ -30,21 +32,56 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp { let typing_env = body.typing_env(tcx); let ssa = SsaLocals::new(tcx, body, typing_env); - debug!(borrowed_locals = ?ssa.borrowed_locals()); + let borrowed_locals = ssa.borrowed_locals().clone(); + + debug!(?borrowed_locals); debug!(copy_classes = ?ssa.copy_classes()); let fully_moved = fully_moved_locals(&ssa, body); debug!(?fully_moved); + let mut head_storage_to_check = DenseBitSet::new_empty(fully_moved.domain_size()); let mut storage_to_remove = DenseBitSet::new_empty(fully_moved.domain_size()); + for (local, &head) in ssa.copy_classes().iter_enumerated() { if local != head { - storage_to_remove.insert(head); + // We need to determine if we can keep the head's storage statements (which enables better optimizations). + // For every local's usage location, if the head is maybe-uninitialized, we'll need to remove it's storage statements. + head_storage_to_check.insert(head); + + if borrowed_locals.contains(local) { + // To keep the storage of a head, we require that none of the locals in it's copy class are borrowed, + // since otherwise we cannot easily identify when it is used. + storage_to_remove.insert(head); + } } } let any_replacement = ssa.copy_classes().iter_enumerated().any(|(l, &h)| l != h); + // Debug builds have no use for the storage statements, so avoid extra work. + let storage_to_remove = if any_replacement && tcx.sess.emit_lifetime_markers() { + let maybe_uninit = MaybeUninitializedLocals::new() + .iterate_to_fixpoint(tcx, body, Some("mir_opt::copy_prop")) + .into_results_cursor(body); + + let mut storage_checker = StorageChecker { + maybe_uninit, + copy_classes: ssa.copy_classes(), + head_storage_to_check, + storage_to_remove, + }; + + storage_checker.visit_body(body); + + storage_checker.storage_to_remove + } else { + // Conservatively remove all storage statements for the head locals. + head_storage_to_check + }; + + debug!(?storage_to_remove); + Replacer { tcx, copy_classes: ssa.copy_classes(), fully_moved, storage_to_remove } .visit_body_preserves_cfg(body); @@ -152,3 +189,51 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> { } } } + +// Marks heads of copy classes that are maybe uninitialized at the location of a local +// as needing storage statement removal. +struct StorageChecker<'a, 'tcx> { + maybe_uninit: ResultsCursor<'a, 'tcx, MaybeUninitializedLocals>, + copy_classes: &'a IndexSlice, + head_storage_to_check: DenseBitSet, + storage_to_remove: DenseBitSet, +} + +impl<'a, 'tcx> Visitor<'tcx> for StorageChecker<'a, 'tcx> { + fn visit_local(&mut self, local: Local, context: PlaceContext, loc: Location) { + // We don't need to check storage statements and statements for which the local doesn't need to be initialized. + match context { + PlaceContext::MutatingUse( + MutatingUseContext::Store + | MutatingUseContext::Call + | MutatingUseContext::Yield + | MutatingUseContext::AsmOutput, + ) + | PlaceContext::NonUse(_) => { + return; + } + _ => {} + }; + + let head = self.copy_classes[local]; + + // The head must be initialized at the location of the local, otherwise we must remove it's storage statements. + if self.head_storage_to_check.contains(head) { + self.maybe_uninit.seek_before_primary_effect(loc); + + if self.maybe_uninit.get().contains(head) { + debug!( + ?loc, + ?context, + ?local, + ?head, + "found a head at a location in which it is maybe uninit, marking head for storage statement removal" + ); + self.storage_to_remove.insert(head); + + // Once we found a use of the head that is maybe uninit, we do not need to check it again. + self.head_storage_to_check.remove(head); + } + } + } +} diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index bda71ceaa551a..c023296d82ac4 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -104,6 +104,8 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf}; use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_mir_dataflow::impls::MaybeUninitializedLocals; +use rustc_mir_dataflow::{Analysis, ResultsCursor}; use rustc_span::DUMMY_SP; use rustc_span::def_id::DefId; use smallvec::SmallVec; @@ -140,10 +142,31 @@ impl<'tcx> crate::MirPass<'tcx> for GVN { state.visit_basic_block_data(bb, data); } - // For each local that is reused (`y` above), we remove its storage statements do avoid any - // difficulty. Those locals are SSA, so should be easy to optimize by LLVM without storage - // statements. - StorageRemover { tcx, reused_locals: state.reused_locals }.visit_body_preserves_cfg(body); + // If we emit storage annotations, use `MaybeStorageDead` to check which reused locals + // require storage removal (making them alive for the duration of the function). + let storage_to_remove = if tcx.sess.emit_lifetime_markers() { + let maybe_uninit = MaybeUninitializedLocals::new() + .iterate_to_fixpoint(tcx, body, Some("mir_opt::gvn")) + .into_results_cursor(body); + + let mut storage_checker = StorageChecker { + storage_to_check: state.reused_locals.clone(), + storage_to_remove: DenseBitSet::new_empty(body.local_decls.len()), + maybe_uninit, + }; + + storage_checker.visit_body(body); + + storage_checker.storage_to_remove + } else { + // Conservatively remove all storage statements for reused locals. + state.reused_locals.clone() + }; + + debug!(?storage_to_remove); + + StorageRemover { tcx, reused_locals: state.reused_locals, storage_to_remove } + .visit_body_preserves_cfg(body); } fn is_required(&self) -> bool { @@ -1824,6 +1847,7 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> { struct StorageRemover<'tcx> { tcx: TyCtxt<'tcx>, reused_locals: DenseBitSet, + storage_to_remove: DenseBitSet, } impl<'tcx> MutVisitor<'tcx> for StorageRemover<'tcx> { @@ -1844,7 +1868,7 @@ impl<'tcx> MutVisitor<'tcx> for StorageRemover<'tcx> { match stmt.kind { // When removing storage statements, we need to remove both (#107511). StatementKind::StorageLive(l) | StatementKind::StorageDead(l) - if self.reused_locals.contains(l) => + if self.storage_to_remove.contains(l) => { stmt.make_nop() } @@ -1852,3 +1876,40 @@ impl<'tcx> MutVisitor<'tcx> for StorageRemover<'tcx> { } } } + +struct StorageChecker<'a, 'tcx> { + storage_to_check: DenseBitSet, + storage_to_remove: DenseBitSet, + maybe_uninit: ResultsCursor<'a, 'tcx, MaybeUninitializedLocals>, +} + +impl<'a, 'tcx> Visitor<'tcx> for StorageChecker<'a, 'tcx> { + fn visit_local(&mut self, local: Local, context: PlaceContext, location: Location) { + match context { + // These mutating uses do not require the local to be initialized. + PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) + | PlaceContext::MutatingUse(MutatingUseContext::Call) + | PlaceContext::MutatingUse(MutatingUseContext::Store) + | PlaceContext::MutatingUse(MutatingUseContext::Yield) + | PlaceContext::NonUse(_) => { + return; + } + // Must check validity for other mutating usages and all non-mutating uses. + PlaceContext::MutatingUse(_) | PlaceContext::NonMutatingUse(_) => {} + } + + if self.storage_to_check.contains(local) { + self.maybe_uninit.seek_before_primary_effect(location); + + if self.maybe_uninit.get().contains(local) { + debug!( + ?location, + ?local, + "local is maybe uninit in this location, removing storage" + ); + self.storage_to_remove.insert(local); + self.storage_to_check.remove(local); + } + } + } +} diff --git a/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff b/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff index 8088984bc77ab..b3a908a154734 100644 --- a/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff +++ b/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff @@ -55,14 +55,14 @@ } bb0: { - nop; + StorageLive(_1); - _1 = const 1_u8; - nop; -- _2 = const 2_u8; - nop; -- _3 = const 3_u8; + nop; + StorageLive(_2); +- _2 = const 2_u8; + nop; + StorageLive(_3); +- _3 = const 3_u8; + nop; StorageLive(_4); StorageLive(_5); @@ -95,7 +95,7 @@ - _12 = const Point {{ x: 32_u32, y: 32_u32 }}; + nop; StorageLive(_13); - nop; + StorageLive(_14); - _14 = const 32_u32; + nop; StorageLive(_15); @@ -104,7 +104,7 @@ + nop; + nop; StorageDead(_15); - nop; + StorageDead(_14); _0 = const (); StorageDead(_13); StorageDead(_12); @@ -112,9 +112,9 @@ StorageDead(_10); StorageDead(_9); StorageDead(_4); - nop; - nop; - nop; + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff index 0a59c59c2ed2c..3371c19360f92 100644 --- a/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff @@ -13,8 +13,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); StorageLive(_3); _3 = (const 0_i32, const 1_u8, const 2_i32); @@ -36,8 +35,7 @@ StorageDead(_5); StorageDead(_4); _0 = const (); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff index 100369a2eee31..a0f9e7a117996 100644 --- a/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff @@ -13,8 +13,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); StorageLive(_3); _3 = (const 0_i32, const 1_u8, const 2_i32); @@ -36,8 +35,7 @@ StorageDead(_5); StorageDead(_4); _0 = const (); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff index 8c535b567c328..d6551b8e3e741 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff @@ -18,8 +18,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -48,8 +47,7 @@ StorageDead(_3); _0 = const (); StorageDead(_2); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff index 045f4d81db62e..3dbd6ca6769cb 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff @@ -18,8 +18,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -48,8 +47,7 @@ StorageDead(_3); _0 = const (); StorageDead(_2); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff index e5a8726b855c4..eac751a231bd3 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff @@ -18,8 +18,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -48,8 +47,7 @@ StorageDead(_3); _0 = const (); StorageDead(_2); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff index 1110ff186dc6e..72b13008f5c50 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff @@ -18,8 +18,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -48,8 +47,7 @@ StorageDead(_3); _0 = const (); StorageDead(_2); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff b/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff index 3fe70302b21cf..2b389e815ce4e 100644 --- a/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff +++ b/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff @@ -19,15 +19,13 @@ } bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _2; - _3 = BitOr(move _4, const true); + _3 = const true; StorageDead(_4); -- StorageLive(_5); -+ nop; + StorageLive(_5); StorageLive(_6); _6 = copy _1; - _5 = BitAnd(move _6, const false); @@ -43,10 +41,8 @@ + _0 = const false; StorageDead(_8); StorageDead(_7); -- StorageDead(_5); -- StorageDead(_3); -+ nop; -+ nop; + StorageDead(_5); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff index f43c0cca9ad28..fc22060f96ed1 100644 --- a/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff @@ -18,8 +18,7 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); - _4 = SizeOf(i32); - _5 = AlignOf(i32); @@ -39,9 +38,8 @@ _9 = copy ((_3.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); _2 = copy (*_9); - _1 = Add(move _2, const 0_i32); -- StorageDead(_2); + _1 = copy _2; -+ nop; + StorageDead(_2); drop(_3) -> [return: bb2, unwind unreachable]; } diff --git a/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff index 2c903b6d85349..857f6163ca5c6 100644 --- a/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff @@ -18,8 +18,7 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); - _4 = SizeOf(i32); - _5 = AlignOf(i32); @@ -39,9 +38,8 @@ _9 = copy ((_3.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); _2 = copy (*_9); - _1 = Add(move _2, const 0_i32); -- StorageDead(_2); + _1 = copy _2; -+ nop; + StorageDead(_2); drop(_3) -> [return: bb2, unwind: bb3]; } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff index 7ca1b39d77110..405ef7f54d654 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff @@ -22,8 +22,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = foo() -> [return: bb1, unwind unreachable]; } @@ -44,8 +43,7 @@ StorageDead(_5); StorageDead(_4); StorageDead(_2); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff index f637951380664..49782bb44c2a0 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff @@ -22,8 +22,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = foo() -> [return: bb1, unwind continue]; } @@ -44,8 +43,7 @@ StorageDead(_5); StorageDead(_4); StorageDead(_2); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/pointer_expose_provenance.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/pointer_expose_provenance.main.GVN.panic-abort.diff index 657fa7a5fea19..c6991c0a3bb4d 100644 --- a/tests/mir-opt/const_prop/pointer_expose_provenance.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/pointer_expose_provenance.main.GVN.panic-abort.diff @@ -13,8 +13,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); StorageLive(_3); _3 = const main::FOO; @@ -33,8 +32,7 @@ StorageDead(_5); StorageDead(_4); _0 = const (); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/pointer_expose_provenance.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/pointer_expose_provenance.main.GVN.panic-unwind.diff index 8fef6591d41d9..04a43e5973a88 100644 --- a/tests/mir-opt/const_prop/pointer_expose_provenance.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/pointer_expose_provenance.main.GVN.panic-unwind.diff @@ -13,8 +13,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); StorageLive(_3); _3 = const main::FOO; @@ -33,8 +32,7 @@ StorageDead(_5); StorageDead(_4); _0 = const (); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff index 8df262b351f12..1d8c05a4d6a9c 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff +++ b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff @@ -14,10 +14,8 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -- StorageLive(_3); -+ nop; -+ nop; + StorageLive(_2); + StorageLive(_3); _3 = const {ALLOC0: &u8}; - _2 = copy (*_3); + _2 = const 2_u8; @@ -29,11 +27,9 @@ + _4 = const 2_u8; + _1 = const 4_u8; StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); StorageDead(_5); -- StorageDead(_3); -+ nop; + StorageDead(_3); _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff index 3c73d34474c13..83093cc337cb3 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff @@ -11,8 +11,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 1_u32; StorageLive(_2); StorageLive(_3); @@ -26,8 +25,7 @@ StorageDead(_3); StorageDead(_2); _0 = const (); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff index 0a7fddee39b62..804763b4f399b 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff @@ -11,8 +11,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 1_u32; StorageLive(_2); StorageLive(_3); @@ -26,8 +25,7 @@ StorageDead(_3); StorageDead(_2); _0 = const (); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff index 01d86ce8717d1..402482eb4e006 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff @@ -11,9 +11,8 @@ } bb0: { -- StorageLive(_1); + StorageLive(_1); - _1 = (const 1_u32, const 2_u32); -+ nop; + _1 = const (1_u32, 2_u32); StorageLive(_2); StorageLive(_3); @@ -27,8 +26,7 @@ StorageDead(_3); StorageDead(_2); _0 = const (); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff index bd7d494212ce6..2f1c5f1c0b0de 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff @@ -11,9 +11,8 @@ } bb0: { -- StorageLive(_1); + StorageLive(_1); - _1 = (const 1_u32, const 2_u32); -+ nop; + _1 = const (1_u32, 2_u32); StorageLive(_2); StorageLive(_3); @@ -27,8 +26,7 @@ StorageDead(_3); StorageDead(_2); _0 = const (); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/copy-prop/copy_prop_borrowed_storage_not_removed.f.CopyProp.diff b/tests/mir-opt/copy-prop/copy_prop_borrowed_storage_not_removed.f.CopyProp.diff new file mode 100644 index 0000000000000..782b053cf2240 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_borrowed_storage_not_removed.f.CopyProp.diff @@ -0,0 +1,21 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: (T, T)) -> T { + let mut _0: T; + let mut _2: T; + let mut _3: T; + let mut _4: &T; + + bb0: { +- StorageLive(_2); + _2 = copy (_1.0: T); +- _3 = copy _2; +- _4 = &_3; +- StorageDead(_2); ++ _4 = &_2; + _0 = copy (*_4); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_prop_borrowed_storage_not_removed.rs b/tests/mir-opt/copy-prop/copy_prop_borrowed_storage_not_removed.rs new file mode 100644 index 0000000000000..39a3fda47a8e5 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_borrowed_storage_not_removed.rs @@ -0,0 +1,30 @@ +// skip-filecheck +//@ test-mir-pass: CopyProp + +#![feature(custom_mir, core_intrinsics, freeze)] + +// Check that we remove the storage statements if one of the locals is borrowed, +// and the head isn't borrowed. + +use std::intrinsics::mir::*; +use std::marker::Freeze; + +// EMIT_MIR copy_prop_borrowed_storage_not_removed.f.CopyProp.diff + +#[custom_mir(dialect = "runtime")] +pub fn f(_1: (T, T)) -> T { + mir! { + let _2: T; + let _3: T; + let _4: &T; + { + StorageLive(_2); + _2 = _1.0; + _3 = _2; + _4 = &_3; + StorageDead(_2); + RET = *_4; + Return() + } + } +} diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_twice.dead_twice.CopyProp.diff b/tests/mir-opt/copy-prop/copy_prop_storage_twice.dead_twice.CopyProp.diff new file mode 100644 index 0000000000000..0eb86de527219 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_twice.dead_twice.CopyProp.diff @@ -0,0 +1,28 @@ +- // MIR for `dead_twice` before CopyProp ++ // MIR for `dead_twice` after CopyProp + + fn dead_twice(_1: T) -> T { + let mut _0: T; + let mut _2: T; + let mut _3: T; + let mut _4: T; + + bb0: { +- StorageLive(_2); + _2 = opaque::(move _1) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- _4 = move _2; +- StorageDead(_2); +- StorageLive(_2); +- _0 = opaque::(move _4) -> [return: bb2, unwind unreachable]; ++ _0 = opaque::(move _2) -> [return: bb2, unwind unreachable]; + } + + bb2: { +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_twice.live_twice.CopyProp.diff b/tests/mir-opt/copy-prop/copy_prop_storage_twice.live_twice.CopyProp.diff new file mode 100644 index 0000000000000..01b59b547eaa8 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_twice.live_twice.CopyProp.diff @@ -0,0 +1,27 @@ +- // MIR for `live_twice` before CopyProp ++ // MIR for `live_twice` after CopyProp + + fn live_twice(_1: T) -> T { + let mut _0: T; + let mut _2: T; + let mut _3: T; + let mut _4: T; + + bb0: { +- StorageLive(_2); + _2 = opaque::(move _1) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- _4 = move _2; +- StorageLive(_2); +- _0 = opaque::(copy _4) -> [return: bb2, unwind unreachable]; ++ _0 = opaque::(copy _2) -> [return: bb2, unwind unreachable]; + } + + bb2: { +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_twice.rs b/tests/mir-opt/copy-prop/copy_prop_storage_twice.rs new file mode 100644 index 0000000000000..421bb55d62ecc --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_twice.rs @@ -0,0 +1,61 @@ +// skip-filecheck +//@ test-mir-pass: CopyProp +//@ compile-flags: -Zlint-mir=false + +#![feature(custom_mir, core_intrinsics)] + +// Check that we remove the storage statements if the head +// becomes uninitialized before it is used again. + +use std::intrinsics::mir::*; + +// EMIT_MIR copy_prop_storage_twice.dead_twice.CopyProp.diff +// EMIT_MIR copy_prop_storage_twice.live_twice.CopyProp.diff + +#[custom_mir(dialect = "runtime")] +pub fn dead_twice(_1: T) -> T { + mir! { + let _2: T; + let _3: T; + { + StorageLive(_2); + Call(_2 = opaque(Move(_1)), ReturnTo(bb1), UnwindUnreachable()) + } + bb1 = { + let _3 = Move(_2); + StorageDead(_2); + StorageLive(_2); + Call(RET = opaque(Move(_3)), ReturnTo(bb2), UnwindUnreachable()) + } + bb2 = { + StorageDead(_2); + Return() + } + } +} + +#[custom_mir(dialect = "runtime")] +pub fn live_twice(_1: T) -> T { + mir! { + let _2: T; + let _3: T; + { + StorageLive(_2); + Call(_2 = opaque(Move(_1)), ReturnTo(bb1), UnwindUnreachable()) + } + bb1 = { + let _3 = Move(_2); + StorageLive(_2); + Call(RET = opaque(_3), ReturnTo(bb2), UnwindUnreachable()) + } + bb2 = { + StorageDead(_2); + Return() + } + } +} + +#[inline(never)] +fn opaque(a: T) -> T { + a +} diff --git a/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-abort.diff index d133091e6a438..f11685467fd7d 100644 --- a/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-abort.diff @@ -26,7 +26,7 @@ } bb1: { -- StorageLive(_2); + StorageLive(_2); _2 = copy _1; - StorageLive(_3); - _3 = copy _2; @@ -46,7 +46,7 @@ StorageDead(_5); _0 = const (); - StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); StorageDead(_1); return; } diff --git a/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff index bd4ad737cec13..bf5d8d20b7a10 100644 --- a/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff @@ -26,7 +26,7 @@ } bb1: { -- StorageLive(_2); + StorageLive(_2); _2 = copy _1; - StorageLive(_3); - _3 = copy _2; @@ -46,7 +46,7 @@ StorageDead(_5); _0 = const (); - StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); StorageDead(_1); return; } diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-abort.mir b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-abort.mir index 4781fdfd902a4..90bd2b8e07a8f 100644 --- a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-abort.mir +++ b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-abort.mir @@ -11,6 +11,7 @@ fn f(_1: usize) -> usize { } bb0: { + StorageLive(_2); _2 = copy _1; _1 = const 5_usize; _1 = copy _2; @@ -21,6 +22,7 @@ fn f(_1: usize) -> usize { bb1: { StorageDead(_4); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir index f5fded45c13b4..72b51f0b60a7b 100644 --- a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir +++ b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir @@ -11,6 +11,7 @@ fn f(_1: usize) -> usize { } bb0: { + StorageLive(_2); _2 = copy _1; _1 = const 5_usize; _1 = copy _2; @@ -21,6 +22,7 @@ fn f(_1: usize) -> usize { bb1: { StorageDead(_4); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-abort.mir b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-abort.mir index 4781fdfd902a4..90bd2b8e07a8f 100644 --- a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-abort.mir +++ b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-abort.mir @@ -11,6 +11,7 @@ fn f(_1: usize) -> usize { } bb0: { + StorageLive(_2); _2 = copy _1; _1 = const 5_usize; _1 = copy _2; @@ -21,6 +22,7 @@ fn f(_1: usize) -> usize { bb1: { StorageDead(_4); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir index f5fded45c13b4..72b51f0b60a7b 100644 --- a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir +++ b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir @@ -11,6 +11,7 @@ fn f(_1: usize) -> usize { } bb0: { + StorageLive(_2); _2 = copy _1; _1 = const 5_usize; _1 = copy _2; @@ -21,6 +22,7 @@ fn f(_1: usize) -> usize { bb1: { StorageDead(_4); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff index 689083dfc1d3a..fb2aa9c055a64 100644 --- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff @@ -86,7 +86,7 @@ } bb6: { -- StorageLive(_16); + StorageLive(_16); _16 = copy ((_11 as Some).0: usize); StorageLive(_17); - StorageLive(_18); @@ -116,7 +116,7 @@ StorageDead(_17); - StorageDead(_18); - _10 = const (); -- StorageDead(_16); + StorageDead(_16); StorageDead(_13); StorageDead(_11); - StorageDead(_10); diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff index 7f768a9f834d9..df3a7793bfdd3 100644 --- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff @@ -86,7 +86,7 @@ } bb6: { -- StorageLive(_16); + StorageLive(_16); _16 = copy ((_11 as Some).0: usize); StorageLive(_17); - StorageLive(_18); @@ -116,7 +116,7 @@ StorageDead(_17); - StorageDead(_18); - _10 = const (); -- StorageDead(_16); + StorageDead(_16); StorageDead(_13); StorageDead(_11); - StorageDead(_10); diff --git a/tests/mir-opt/copy-prop/issue_141649.main.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/issue_141649.main.CopyProp.panic-abort.diff new file mode 100644 index 0000000000000..c68bfb1b8e94a --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649.main.CopyProp.panic-abort.diff @@ -0,0 +1,142 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); + let _1: (); + let _2: main::S; + let _3: (); + let mut _4: main::S; + let _5: (); + let _6: main::S; + let _7: (); + let mut _8: main::S; + let _9: (); + let _10: main::S; + let _12: &main::S; + let mut _13: &main::S; + let _14: (); + let mut _15: main::S; + let _16: (); + let _17: main::C; + let _18: (); + let mut _19: main::C; + let _20: main::C; + let _21: (); + let mut _22: main::C; + scope 1 { + debug s1 => _2; + } + scope 2 { + debug s2 => _6; + } + scope 3 { + debug s3 => _10; + let _11: &main::S; + scope 4 { + debug borrowed_s3 => _11; + } + } + scope 5 { + debug c1 => _17; + } + scope 6 { + debug c2 => _20; + } + + bb0: { +- StorageLive(_1); + StorageLive(_2); + _2 = S(const 1_usize, const 2_usize); + StorageLive(_3); +- StorageLive(_4); +- _4 = move _2; +- _3 = std::mem::drop::(move _4) -> [return: bb1, unwind unreachable]; ++ _3 = std::mem::drop::(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_4); + StorageDead(_3); +- _1 = const (); + StorageDead(_2); +- StorageDead(_1); +- StorageLive(_5); + StorageLive(_6); + _6 = S(const 3_usize, const 4_usize); + StorageLive(_7); +- StorageLive(_8); +- _8 = move _6; +- _7 = std::mem::drop::(move _8) -> [return: bb2, unwind unreachable]; ++ _7 = std::mem::drop::(move _6) -> [return: bb2, unwind unreachable]; + } + + bb2: { +- StorageDead(_8); + StorageDead(_7); +- _5 = const (); + StorageDead(_6); +- StorageDead(_5); +- StorageLive(_9); + StorageLive(_10); + _10 = S(const 5_usize, const 6_usize); + StorageLive(_11); + _11 = &_10; + StorageLive(_12); +- StorageLive(_13); +- _13 = copy _11; +- _12 = opaque::<&S>(move _13) -> [return: bb3, unwind unreachable]; ++ _12 = opaque::<&S>(copy _11) -> [return: bb3, unwind unreachable]; + } + + bb3: { +- StorageDead(_13); + StorageDead(_12); + StorageLive(_14); +- StorageLive(_15); +- _15 = move _10; +- _14 = std::mem::drop::(move _15) -> [return: bb4, unwind unreachable]; ++ _14 = std::mem::drop::(move _10) -> [return: bb4, unwind unreachable]; + } + + bb4: { +- StorageDead(_15); + StorageDead(_14); +- _9 = const (); + StorageDead(_11); + StorageDead(_10); +- StorageDead(_9); +- StorageLive(_16); + StorageLive(_17); + _17 = C(const 1_usize, const 2_usize); + StorageLive(_18); +- StorageLive(_19); +- _19 = copy _17; +- _18 = std::mem::drop::(move _19) -> [return: bb5, unwind unreachable]; ++ _18 = std::mem::drop::(copy _17) -> [return: bb5, unwind unreachable]; + } + + bb5: { +- StorageDead(_19); + StorageDead(_18); +- _16 = const (); + StorageDead(_17); +- StorageDead(_16); + StorageLive(_20); + _20 = C(const 3_usize, const 4_usize); + StorageLive(_21); +- StorageLive(_22); +- _22 = copy _20; +- _21 = std::mem::drop::(move _22) -> [return: bb6, unwind unreachable]; ++ _21 = std::mem::drop::(copy _20) -> [return: bb6, unwind unreachable]; + } + + bb6: { +- StorageDead(_22); + StorageDead(_21); + _0 = const (); + StorageDead(_20); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/issue_141649.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/issue_141649.main.CopyProp.panic-unwind.diff new file mode 100644 index 0000000000000..3535a9840f685 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649.main.CopyProp.panic-unwind.diff @@ -0,0 +1,142 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); + let _1: (); + let _2: main::S; + let _3: (); + let mut _4: main::S; + let _5: (); + let _6: main::S; + let _7: (); + let mut _8: main::S; + let _9: (); + let _10: main::S; + let _12: &main::S; + let mut _13: &main::S; + let _14: (); + let mut _15: main::S; + let _16: (); + let _17: main::C; + let _18: (); + let mut _19: main::C; + let _20: main::C; + let _21: (); + let mut _22: main::C; + scope 1 { + debug s1 => _2; + } + scope 2 { + debug s2 => _6; + } + scope 3 { + debug s3 => _10; + let _11: &main::S; + scope 4 { + debug borrowed_s3 => _11; + } + } + scope 5 { + debug c1 => _17; + } + scope 6 { + debug c2 => _20; + } + + bb0: { +- StorageLive(_1); + StorageLive(_2); + _2 = S(const 1_usize, const 2_usize); + StorageLive(_3); +- StorageLive(_4); +- _4 = move _2; +- _3 = std::mem::drop::(move _4) -> [return: bb1, unwind continue]; ++ _3 = std::mem::drop::(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageDead(_4); + StorageDead(_3); +- _1 = const (); + StorageDead(_2); +- StorageDead(_1); +- StorageLive(_5); + StorageLive(_6); + _6 = S(const 3_usize, const 4_usize); + StorageLive(_7); +- StorageLive(_8); +- _8 = move _6; +- _7 = std::mem::drop::(move _8) -> [return: bb2, unwind continue]; ++ _7 = std::mem::drop::(move _6) -> [return: bb2, unwind continue]; + } + + bb2: { +- StorageDead(_8); + StorageDead(_7); +- _5 = const (); + StorageDead(_6); +- StorageDead(_5); +- StorageLive(_9); + StorageLive(_10); + _10 = S(const 5_usize, const 6_usize); + StorageLive(_11); + _11 = &_10; + StorageLive(_12); +- StorageLive(_13); +- _13 = copy _11; +- _12 = opaque::<&S>(move _13) -> [return: bb3, unwind continue]; ++ _12 = opaque::<&S>(copy _11) -> [return: bb3, unwind continue]; + } + + bb3: { +- StorageDead(_13); + StorageDead(_12); + StorageLive(_14); +- StorageLive(_15); +- _15 = move _10; +- _14 = std::mem::drop::(move _15) -> [return: bb4, unwind continue]; ++ _14 = std::mem::drop::(move _10) -> [return: bb4, unwind continue]; + } + + bb4: { +- StorageDead(_15); + StorageDead(_14); +- _9 = const (); + StorageDead(_11); + StorageDead(_10); +- StorageDead(_9); +- StorageLive(_16); + StorageLive(_17); + _17 = C(const 1_usize, const 2_usize); + StorageLive(_18); +- StorageLive(_19); +- _19 = copy _17; +- _18 = std::mem::drop::(move _19) -> [return: bb5, unwind continue]; ++ _18 = std::mem::drop::(copy _17) -> [return: bb5, unwind continue]; + } + + bb5: { +- StorageDead(_19); + StorageDead(_18); +- _16 = const (); + StorageDead(_17); +- StorageDead(_16); + StorageLive(_20); + _20 = C(const 3_usize, const 4_usize); + StorageLive(_21); +- StorageLive(_22); +- _22 = copy _20; +- _21 = std::mem::drop::(move _22) -> [return: bb6, unwind continue]; ++ _21 = std::mem::drop::(copy _20) -> [return: bb6, unwind continue]; + } + + bb6: { +- StorageDead(_22); + StorageDead(_21); + _0 = const (); + StorageDead(_20); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/issue_141649.rs b/tests/mir-opt/copy-prop/issue_141649.rs new file mode 100644 index 0000000000000..e3b9062d65101 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649.rs @@ -0,0 +1,38 @@ +// skip-filecheck +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +//@ test-mir-pass: CopyProp + +// EMIT_MIR issue_141649.main.CopyProp.diff +fn main() { + struct S(usize, usize); + { + let s1 = S(1, 2); + drop(s1); + } + { + let s2 = S(3, 4); + drop(s2); + } + { + let s3 = S(5, 6); + let borrowed_s3 = &s3; + opaque(borrowed_s3); + drop(s3); + } + + #[derive(Clone, Copy)] + struct C(usize, usize); + { + let c1 = C(1, 2); + drop(c1); + } + { + let c2 = C(3, 4); + drop(c2); + } +} + +#[inline(never)] +fn opaque(a: T) -> T { + a +} diff --git a/tests/mir-opt/copy-prop/issue_141649_debug.main.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/issue_141649_debug.main.CopyProp.panic-abort.diff new file mode 100644 index 0000000000000..93629b0f9f3f9 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649_debug.main.CopyProp.panic-abort.diff @@ -0,0 +1,100 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); + let _1: (); + let _2: main::S; + let _3: (); + let mut _4: main::S; + let _5: (); + let _6: main::S; + let _7: (); + let mut _8: main::S; + let _9: (); + let _10: main::C; + let _11: (); + let mut _12: main::C; + let _13: main::C; + let _14: (); + let mut _15: main::C; + scope 1 { + debug s1 => _2; + } + scope 2 { + debug s2 => _6; + } + scope 3 { + debug c1 => _10; + } + scope 4 { + debug c2 => _13; + } + + bb0: { +- StorageLive(_1); +- StorageLive(_2); + _2 = S(const 1_usize, const 2_usize); + StorageLive(_3); +- StorageLive(_4); +- _4 = move _2; +- _3 = std::mem::drop::(move _4) -> [return: bb1, unwind unreachable]; ++ _3 = std::mem::drop::(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_4); + StorageDead(_3); +- _1 = const (); +- StorageDead(_2); +- StorageDead(_1); +- StorageLive(_5); +- StorageLive(_6); + _6 = S(const 3_usize, const 4_usize); + StorageLive(_7); +- StorageLive(_8); +- _8 = move _6; +- _7 = std::mem::drop::(move _8) -> [return: bb2, unwind unreachable]; ++ _7 = std::mem::drop::(move _6) -> [return: bb2, unwind unreachable]; + } + + bb2: { +- StorageDead(_8); + StorageDead(_7); +- _5 = const (); +- StorageDead(_6); +- StorageDead(_5); +- StorageLive(_9); +- StorageLive(_10); + _10 = C(const 1_usize, const 2_usize); + StorageLive(_11); +- StorageLive(_12); +- _12 = copy _10; +- _11 = std::mem::drop::(move _12) -> [return: bb3, unwind unreachable]; ++ _11 = std::mem::drop::(copy _10) -> [return: bb3, unwind unreachable]; + } + + bb3: { +- StorageDead(_12); + StorageDead(_11); +- _9 = const (); +- StorageDead(_10); +- StorageDead(_9); +- StorageLive(_13); + _13 = C(const 3_usize, const 4_usize); + StorageLive(_14); +- StorageLive(_15); +- _15 = copy _13; +- _14 = std::mem::drop::(move _15) -> [return: bb4, unwind unreachable]; ++ _14 = std::mem::drop::(copy _13) -> [return: bb4, unwind unreachable]; + } + + bb4: { +- StorageDead(_15); + StorageDead(_14); + _0 = const (); +- StorageDead(_13); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/issue_141649_debug.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/issue_141649_debug.main.CopyProp.panic-unwind.diff new file mode 100644 index 0000000000000..e02fe72a47a7b --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649_debug.main.CopyProp.panic-unwind.diff @@ -0,0 +1,100 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); + let _1: (); + let _2: main::S; + let _3: (); + let mut _4: main::S; + let _5: (); + let _6: main::S; + let _7: (); + let mut _8: main::S; + let _9: (); + let _10: main::C; + let _11: (); + let mut _12: main::C; + let _13: main::C; + let _14: (); + let mut _15: main::C; + scope 1 { + debug s1 => _2; + } + scope 2 { + debug s2 => _6; + } + scope 3 { + debug c1 => _10; + } + scope 4 { + debug c2 => _13; + } + + bb0: { +- StorageLive(_1); +- StorageLive(_2); + _2 = S(const 1_usize, const 2_usize); + StorageLive(_3); +- StorageLive(_4); +- _4 = move _2; +- _3 = std::mem::drop::(move _4) -> [return: bb1, unwind continue]; ++ _3 = std::mem::drop::(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageDead(_4); + StorageDead(_3); +- _1 = const (); +- StorageDead(_2); +- StorageDead(_1); +- StorageLive(_5); +- StorageLive(_6); + _6 = S(const 3_usize, const 4_usize); + StorageLive(_7); +- StorageLive(_8); +- _8 = move _6; +- _7 = std::mem::drop::(move _8) -> [return: bb2, unwind continue]; ++ _7 = std::mem::drop::(move _6) -> [return: bb2, unwind continue]; + } + + bb2: { +- StorageDead(_8); + StorageDead(_7); +- _5 = const (); +- StorageDead(_6); +- StorageDead(_5); +- StorageLive(_9); +- StorageLive(_10); + _10 = C(const 1_usize, const 2_usize); + StorageLive(_11); +- StorageLive(_12); +- _12 = copy _10; +- _11 = std::mem::drop::(move _12) -> [return: bb3, unwind continue]; ++ _11 = std::mem::drop::(copy _10) -> [return: bb3, unwind continue]; + } + + bb3: { +- StorageDead(_12); + StorageDead(_11); +- _9 = const (); +- StorageDead(_10); +- StorageDead(_9); +- StorageLive(_13); + _13 = C(const 3_usize, const 4_usize); + StorageLive(_14); +- StorageLive(_15); +- _15 = copy _13; +- _14 = std::mem::drop::(move _15) -> [return: bb4, unwind continue]; ++ _14 = std::mem::drop::(copy _13) -> [return: bb4, unwind continue]; + } + + bb4: { +- StorageDead(_15); + StorageDead(_14); + _0 = const (); +- StorageDead(_13); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/issue_141649_debug.rs b/tests/mir-opt/copy-prop/issue_141649_debug.rs new file mode 100644 index 0000000000000..5769118700ca1 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649_debug.rs @@ -0,0 +1,29 @@ +// skip-filecheck +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +//! Tests that in lower opt levels we remove (more) storage statements using a simpler strategy. +//@ test-mir-pass: CopyProp +//@ compile-flags: -Copt-level=0 + +// EMIT_MIR issue_141649_debug.main.CopyProp.diff +fn main() { + struct S(usize, usize); + { + let s1 = S(1, 2); + drop(s1); + } + { + let s2 = S(3, 4); + drop(s2); + } + + #[derive(Clone, Copy)] + struct C(usize, usize); + { + let c1 = C(1, 2); + drop(c1); + } + { + let c2 = C(3, 4); + drop(c2); + } +} diff --git a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-abort.diff index 676c5cee34387..ccd1e1caf003a 100644 --- a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-abort.diff @@ -22,7 +22,7 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); _2 = &raw mut _1; StorageLive(_3); StorageLive(_4); @@ -44,7 +44,7 @@ _0 = const (); - StorageDead(_5); StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff index ca2232ce54a1f..6cfb4af1fcf2e 100644 --- a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff @@ -22,7 +22,7 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); _2 = &raw mut _1; StorageLive(_3); StorageLive(_4); @@ -44,7 +44,7 @@ _0 = const (); - StorageDead(_5); StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-abort.diff index 1968696905fc7..b5f6a6e22f29f 100644 --- a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-abort.diff @@ -21,7 +21,7 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); _2 = &raw mut _1; StorageLive(_3); _3 = &raw mut (*_2); @@ -40,7 +40,7 @@ _0 = const (); - StorageDead(_4); StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff index 9a3c9665bc8f3..c28f7d037fd1d 100644 --- a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff @@ -21,7 +21,7 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); _2 = &raw mut _1; StorageLive(_3); _3 = &raw mut (*_2); @@ -40,7 +40,7 @@ _0 = const (); - StorageDead(_4); StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff index 2026c1982f299..aebd98d85b54c 100644 --- a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff @@ -21,7 +21,7 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); _2 = &mut _1; StorageLive(_3); _3 = &mut (*_2); @@ -40,7 +40,7 @@ _0 = const (); - StorageDead(_4); StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff index 67763fdce6676..a836d439c3eac 100644 --- a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff @@ -21,7 +21,7 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); _2 = &mut _1; StorageLive(_3); _3 = &mut (*_2); @@ -40,7 +40,7 @@ _0 = const (); - StorageDead(_4); StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff index dfc8dd0975638..38801bc7811a8 100644 --- a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff @@ -21,7 +21,7 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); _2 = &mut _1; StorageLive(_3); _3 = &raw mut (*_2); @@ -40,7 +40,7 @@ _0 = const (); - StorageDead(_4); StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff index becc425632104..f7af4681014b3 100644 --- a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff @@ -21,7 +21,7 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); _2 = &mut _1; StorageLive(_3); _3 = &raw mut (*_2); @@ -40,7 +40,7 @@ _0 = const (); - StorageDead(_4); StorageDead(_3); -- StorageDead(_2); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff index 25ffff619e60b..4ef4bd4c5a2c6 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff @@ -78,9 +78,8 @@ - _12 = AlignOf(()); + _11 = const 0_usize; + _12 = const 1_usize; - StorageLive(_14); StorageLive(_16); - StorageLive(_17); + StorageLive(_14); StorageLive(_19); _19 = const false; - switchInt(move _19) -> [0: bb6, otherwise: bb5]; @@ -103,15 +102,16 @@ } bb4: { + StorageLive(_17); _17 = copy ((_15 as Ok).0: std::ptr::NonNull<[u8]>); StorageLive(_22); _22 = copy _17 as *mut [u8] (Transmute); _13 = copy _22 as *mut u8 (PtrToPtr); StorageDead(_22); - StorageDead(_15); StorageDead(_17); - StorageDead(_16); + StorageDead(_15); StorageDead(_14); + StorageDead(_16); _3 = ShallowInitBox(move _13, ()); StorageDead(_13); StorageDead(_12); @@ -124,8 +124,7 @@ + _9 = copy _3; _10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _4 = copy _10; -- StorageLive(_5); -+ nop; + StorageLive(_5); StorageLive(_6); - _6 = copy _4; + _6 = copy _10; @@ -142,8 +141,7 @@ + _7 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *mut () (Transmute); StorageDead(_8); StorageDead(_7); -- StorageDead(_5); -+ nop; + StorageDead(_5); StorageDead(_4); drop(_3) -> [return: bb1, unwind unreachable]; } diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff index b2085afb71379..30d8d63850a21 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff @@ -49,8 +49,7 @@ + _9 = copy _3; _10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _4 = copy _10; -- StorageLive(_5); -+ nop; + StorageLive(_5); StorageLive(_6); - _6 = copy _4; + _6 = copy _10; @@ -67,8 +66,7 @@ + _7 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *mut () (Transmute); StorageDead(_8); StorageDead(_7); -- StorageDead(_5); -+ nop; + StorageDead(_5); StorageDead(_4); drop(_3) -> [return: bb2, unwind: bb3]; } diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff index 839b53e3b0b3b..a9a58f7f0c400 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff @@ -78,9 +78,8 @@ - _12 = AlignOf(()); + _11 = const 0_usize; + _12 = const 1_usize; - StorageLive(_14); StorageLive(_16); - StorageLive(_17); + StorageLive(_14); StorageLive(_19); _19 = const false; - switchInt(move _19) -> [0: bb6, otherwise: bb5]; @@ -103,15 +102,16 @@ } bb4: { + StorageLive(_17); _17 = copy ((_15 as Ok).0: std::ptr::NonNull<[u8]>); StorageLive(_22); _22 = copy _17 as *mut [u8] (Transmute); _13 = copy _22 as *mut u8 (PtrToPtr); StorageDead(_22); - StorageDead(_15); StorageDead(_17); - StorageDead(_16); + StorageDead(_15); StorageDead(_14); + StorageDead(_16); _3 = ShallowInitBox(move _13, ()); StorageDead(_13); StorageDead(_12); @@ -124,8 +124,7 @@ + _9 = copy _3; _10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _4 = copy _10; -- StorageLive(_5); -+ nop; + StorageLive(_5); StorageLive(_6); - _6 = copy _4; + _6 = copy _10; @@ -142,8 +141,7 @@ + _7 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *mut () (Transmute); StorageDead(_8); StorageDead(_7); -- StorageDead(_5); -+ nop; + StorageDead(_5); StorageDead(_4); drop(_3) -> [return: bb1, unwind unreachable]; } diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff index b2085afb71379..30d8d63850a21 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff @@ -49,8 +49,7 @@ + _9 = copy _3; _10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _4 = copy _10; -- StorageLive(_5); -+ nop; + StorageLive(_5); StorageLive(_6); - _6 = copy _4; + _6 = copy _10; @@ -67,8 +66,7 @@ + _7 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *mut () (Transmute); StorageDead(_8); StorageDead(_7); -- StorageDead(_5); -+ nop; + StorageDead(_5); StorageDead(_4); drop(_3) -> [return: bb2, unwind: bb3]; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff index 6baa902b6f4bd..14058c5944bb6 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff @@ -78,8 +78,7 @@ } bb4: { -- StorageLive(_8); -+ nop; + StorageLive(_8); _8 = copy ((_6 as Some).0: usize); StorageLive(_9); _9 = copy _1; @@ -108,8 +107,7 @@ StorageDead(_11); StorageDead(_10); StorageDead(_9); -- StorageDead(_8); -+ nop; + StorageDead(_8); goto -> bb8; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff index 36540e038654f..24c3ae1b1b2d4 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff @@ -78,8 +78,7 @@ } bb4: { -- StorageLive(_8); -+ nop; + StorageLive(_8); _8 = copy ((_6 as Some).0: usize); StorageLive(_9); _9 = copy _1; @@ -108,8 +107,7 @@ StorageDead(_11); StorageDead(_10); StorageDead(_9); -- StorageDead(_8); -+ nop; + StorageDead(_8); goto -> bb8; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff index 41c350f3eaeb5..ffbb51be657d9 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff @@ -78,8 +78,7 @@ } bb4: { -- StorageLive(_8); -+ nop; + StorageLive(_8); _8 = copy ((_6 as Some).0: usize); StorageLive(_9); _9 = copy _1; @@ -108,8 +107,7 @@ StorageDead(_11); StorageDead(_10); StorageDead(_9); -- StorageDead(_8); -+ nop; + StorageDead(_8); goto -> bb8; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff index b839bf81eaf45..1fbac464c9d34 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff @@ -78,8 +78,7 @@ } bb4: { -- StorageLive(_8); -+ nop; + StorageLive(_8); _8 = copy ((_6 as Some).0: usize); StorageLive(_9); _9 = copy _1; @@ -108,8 +107,7 @@ StorageDead(_11); StorageDead(_10); StorageDead(_9); -- StorageDead(_8); -+ nop; + StorageDead(_8); goto -> bb8; } diff --git a/tests/mir-opt/gvn.aggregate_struct_then_transmute.GVN.panic-abort.diff b/tests/mir-opt/gvn.aggregate_struct_then_transmute.GVN.panic-abort.diff index 5ae575f300afb..9f8a839eee9a0 100644 --- a/tests/mir-opt/gvn.aggregate_struct_then_transmute.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.aggregate_struct_then_transmute.GVN.panic-abort.diff @@ -91,8 +91,7 @@ } bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; - _3 = MyId(move _4); @@ -113,8 +112,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageLive(_8); -+ nop; + StorageLive(_8); StorageLive(_9); _9 = copy _1; StorageLive(_10); @@ -139,8 +137,7 @@ bb2: { StorageDead(_12); StorageDead(_11); -- StorageLive(_14); -+ nop; + StorageLive(_14); StorageLive(_15); _15 = copy _1; - _14 = Result::::Err(move _15); @@ -161,8 +158,7 @@ bb3: { StorageDead(_17); StorageDead(_16); -- StorageLive(_19); -+ nop; + StorageLive(_19); StorageLive(_20); _20 = copy _1; - _19 = Option::::Some(move _20); @@ -201,8 +197,7 @@ bb5: { StorageDead(_27); StorageDead(_26); -- StorageLive(_29); -+ nop; + StorageLive(_29); StorageLive(_30); _30 = copy _1; StorageLive(_31); @@ -248,8 +243,7 @@ bb7: { StorageDead(_39); StorageDead(_38); -- StorageLive(_41); -+ nop; + StorageLive(_41); StorageLive(_42); _42 = copy _1; - _41 = (move _42,); @@ -269,8 +263,7 @@ bb8: { StorageDead(_44); StorageDead(_43); -- StorageLive(_46); -+ nop; + StorageLive(_46); StorageLive(_47); _47 = copy _1; - _46 = [move _47]; @@ -290,8 +283,7 @@ bb9: { StorageDead(_49); StorageDead(_48); -- StorageLive(_51); -+ nop; + StorageLive(_51); StorageLive(_52); _52 = copy _2; StorageLive(_53); @@ -316,24 +308,16 @@ StorageDead(_55); StorageDead(_54); _0 = const (); -- StorageDead(_51); -- StorageDead(_46); -- StorageDead(_41); -+ nop; -+ nop; -+ nop; + StorageDead(_51); + StorageDead(_46); + StorageDead(_41); StorageDead(_35); -- StorageDead(_29); -+ nop; + StorageDead(_29); StorageDead(_24); -- StorageDead(_19); -- StorageDead(_14); -- StorageDead(_8); -- StorageDead(_3); -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_19); + StorageDead(_14); + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/gvn.aggregate_struct_then_transmute.GVN.panic-unwind.diff b/tests/mir-opt/gvn.aggregate_struct_then_transmute.GVN.panic-unwind.diff index 3119a93fb8912..f04f778349dba 100644 --- a/tests/mir-opt/gvn.aggregate_struct_then_transmute.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.aggregate_struct_then_transmute.GVN.panic-unwind.diff @@ -91,8 +91,7 @@ } bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; - _3 = MyId(move _4); @@ -113,8 +112,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageLive(_8); -+ nop; + StorageLive(_8); StorageLive(_9); _9 = copy _1; StorageLive(_10); @@ -139,8 +137,7 @@ bb2: { StorageDead(_12); StorageDead(_11); -- StorageLive(_14); -+ nop; + StorageLive(_14); StorageLive(_15); _15 = copy _1; - _14 = Result::::Err(move _15); @@ -161,8 +158,7 @@ bb3: { StorageDead(_17); StorageDead(_16); -- StorageLive(_19); -+ nop; + StorageLive(_19); StorageLive(_20); _20 = copy _1; - _19 = Option::::Some(move _20); @@ -201,8 +197,7 @@ bb5: { StorageDead(_27); StorageDead(_26); -- StorageLive(_29); -+ nop; + StorageLive(_29); StorageLive(_30); _30 = copy _1; StorageLive(_31); @@ -248,8 +243,7 @@ bb7: { StorageDead(_39); StorageDead(_38); -- StorageLive(_41); -+ nop; + StorageLive(_41); StorageLive(_42); _42 = copy _1; - _41 = (move _42,); @@ -269,8 +263,7 @@ bb8: { StorageDead(_44); StorageDead(_43); -- StorageLive(_46); -+ nop; + StorageLive(_46); StorageLive(_47); _47 = copy _1; - _46 = [move _47]; @@ -290,8 +283,7 @@ bb9: { StorageDead(_49); StorageDead(_48); -- StorageLive(_51); -+ nop; + StorageLive(_51); StorageLive(_52); _52 = copy _2; StorageLive(_53); @@ -316,24 +308,16 @@ StorageDead(_55); StorageDead(_54); _0 = const (); -- StorageDead(_51); -- StorageDead(_46); -- StorageDead(_41); -+ nop; -+ nop; -+ nop; + StorageDead(_51); + StorageDead(_46); + StorageDead(_41); StorageDead(_35); -- StorageDead(_29); -+ nop; + StorageDead(_29); StorageDead(_24); -- StorageDead(_19); -- StorageDead(_14); -- StorageDead(_8); -- StorageDead(_3); -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_19); + StorageDead(_14); + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff index f980645b1d092..363c2f6ad37cf 100644 --- a/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff @@ -108,8 +108,7 @@ StorageDead(_6); StorageDead(_5); StorageLive(_8); -- StorageLive(_9); -+ nop; + StorageLive(_9); StorageLive(_10); _10 = copy _1; StorageLive(_11); @@ -123,8 +122,7 @@ } bb3: { -- StorageDead(_9); -+ nop; + StorageDead(_9); StorageDead(_8); StorageLive(_12); StorageLive(_13); diff --git a/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff index b8e4967fe8b18..f135532a3f202 100644 --- a/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff @@ -108,8 +108,7 @@ StorageDead(_6); StorageDead(_5); StorageLive(_8); -- StorageLive(_9); -+ nop; + StorageLive(_9); StorageLive(_10); _10 = copy _1; StorageLive(_11); @@ -123,8 +122,7 @@ } bb3: { -- StorageDead(_9); -+ nop; + StorageDead(_9); StorageDead(_8); StorageLive(_12); StorageLive(_13); diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff index acf8bfc71beda..03db197c6a6cc 100644 --- a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff @@ -70,8 +70,7 @@ StorageDead(_7); StorageDead(_6); StorageLive(_10); -- StorageLive(_11); -+ nop; + StorageLive(_11); StorageLive(_12); _12 = copy _1; StorageLive(_13); @@ -92,8 +91,7 @@ } bb6: { -- StorageDead(_11); -+ nop; + StorageDead(_11); StorageDead(_10); StorageLive(_15); StorageLive(_16); diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff index f3f6b381a81ca..61d4ec54a14d7 100644 --- a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff @@ -70,8 +70,7 @@ StorageDead(_7); StorageDead(_6); StorageLive(_10); -- StorageLive(_11); -+ nop; + StorageLive(_11); StorageLive(_12); _12 = copy _1; StorageLive(_13); @@ -92,8 +91,7 @@ } bb6: { -- StorageDead(_11); -+ nop; + StorageDead(_11); StorageDead(_10); StorageLive(_15); StorageLive(_16); diff --git a/tests/mir-opt/gvn.array_len.GVN.panic-abort.diff b/tests/mir-opt/gvn.array_len.GVN.panic-abort.diff index 0d0477fe7729f..59b65a52f4ee6 100644 --- a/tests/mir-opt/gvn.array_len.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.array_len.GVN.panic-abort.diff @@ -12,8 +12,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _3 = &(*_1); _2 = move _3 as &[i32] (PointerCoercion(Unsize, Implicit)); @@ -23,8 +22,7 @@ - _0 = PtrMetadata(move _4); + _0 = const 42_usize; StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.array_len.GVN.panic-unwind.diff b/tests/mir-opt/gvn.array_len.GVN.panic-unwind.diff index 0d0477fe7729f..59b65a52f4ee6 100644 --- a/tests/mir-opt/gvn.array_len.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.array_len.GVN.panic-unwind.diff @@ -12,8 +12,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _3 = &(*_1); _2 = move _3 as &[i32] (PointerCoercion(Unsize, Implicit)); @@ -23,8 +22,7 @@ - _0 = PtrMetadata(move _4); + _0 = const 42_usize; StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.cast.GVN.panic-abort.diff b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff index 1d523d22ca646..71566213f4123 100644 --- a/tests/mir-opt/gvn.cast.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff @@ -104,14 +104,11 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 1_i64; -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = const 1_u64; -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = const 1f64; StorageLive(_4); StorageLive(_5); @@ -552,12 +549,9 @@ StorageDead(_90); StorageDead(_89); _0 = const (); -- StorageDead(_3); -- StorageDead(_2); -- StorageDead(_1); -+ nop; -+ nop; -+ nop; + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff index 3541c10da6437..c0cd4882cd67a 100644 --- a/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff @@ -104,14 +104,11 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 1_i64; -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = const 1_u64; -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = const 1f64; StorageLive(_4); StorageLive(_5); @@ -552,12 +549,9 @@ StorageDead(_90); StorageDead(_89); _0 = const (); -- StorageDead(_3); -- StorageDead(_2); -- StorageDead(_1); -+ nop; -+ nop; -+ nop; + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/gvn.cast_pointer_eq.GVN.panic-abort.diff b/tests/mir-opt/gvn.cast_pointer_eq.GVN.panic-abort.diff index f66aed0f44150..7dc5180a0a5cc 100644 --- a/tests/mir-opt/gvn.cast_pointer_eq.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.cast_pointer_eq.GVN.panic-abort.diff @@ -49,8 +49,7 @@ } bb0: { -- StorageLive(_5); -+ nop; + StorageLive(_5); StorageLive(_6); _6 = copy _1; - _5 = move _6 as *const u32 (PtrToPtr); @@ -78,10 +77,9 @@ StorageDead(_12); - _10 = move _11 as *const u32 (PtrToPtr); - StorageDead(_11); -- StorageLive(_13); + _10 = copy _11; + nop; -+ nop; + StorageLive(_13); StorageLive(_14); _14 = copy _4; - _13 = move _14 as *const u32 (PtrToPtr); @@ -122,12 +120,10 @@ StorageDead(_21); StorageDead(_18); StorageDead(_15); -- StorageDead(_13); -+ nop; + StorageDead(_13); StorageDead(_10); StorageDead(_7); -- StorageDead(_5); -+ nop; + StorageDead(_5); return; } } diff --git a/tests/mir-opt/gvn.cast_pointer_eq.GVN.panic-unwind.diff b/tests/mir-opt/gvn.cast_pointer_eq.GVN.panic-unwind.diff index f66aed0f44150..7dc5180a0a5cc 100644 --- a/tests/mir-opt/gvn.cast_pointer_eq.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.cast_pointer_eq.GVN.panic-unwind.diff @@ -49,8 +49,7 @@ } bb0: { -- StorageLive(_5); -+ nop; + StorageLive(_5); StorageLive(_6); _6 = copy _1; - _5 = move _6 as *const u32 (PtrToPtr); @@ -78,10 +77,9 @@ StorageDead(_12); - _10 = move _11 as *const u32 (PtrToPtr); - StorageDead(_11); -- StorageLive(_13); + _10 = copy _11; + nop; -+ nop; + StorageLive(_13); StorageLive(_14); _14 = copy _4; - _13 = move _14 as *const u32 (PtrToPtr); @@ -122,12 +120,10 @@ StorageDead(_21); StorageDead(_18); StorageDead(_15); -- StorageDead(_13); -+ nop; + StorageDead(_13); StorageDead(_10); StorageDead(_7); -- StorageDead(_5); -+ nop; + StorageDead(_5); return; } } diff --git a/tests/mir-opt/gvn.casts_before_aggregate_raw_ptr.GVN.panic-abort.diff b/tests/mir-opt/gvn.casts_before_aggregate_raw_ptr.GVN.panic-abort.diff index fd09310fabdeb..bb35b7ef57b2c 100644 --- a/tests/mir-opt/gvn.casts_before_aggregate_raw_ptr.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.casts_before_aggregate_raw_ptr.GVN.panic-abort.diff @@ -22,22 +22,19 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _3 = copy _1; - _2 = move _3 as *const [u8; 4] (PtrToPtr); + _2 = copy _1 as *const [u8; 4] (PtrToPtr); StorageDead(_3); -- StorageLive(_4); -+ nop; + StorageLive(_4); StorageLive(_5); _5 = copy _2; - _4 = move _5 as *const u8 (PtrToPtr); + _4 = copy _1 as *const u8 (PtrToPtr); StorageDead(_5); -- StorageLive(_6); -+ nop; + StorageLive(_6); StorageLive(_7); _7 = copy _4; - _6 = move _7 as *const () (PtrToPtr); @@ -48,12 +45,9 @@ - _0 = *const [u8] from (move _8, const 4_usize); + _0 = *const [u8] from (copy _1, const 4_usize); StorageDead(_8); -- StorageDead(_6); -- StorageDead(_4); -- StorageDead(_2); -+ nop; -+ nop; -+ nop; + StorageDead(_6); + StorageDead(_4); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.casts_before_aggregate_raw_ptr.GVN.panic-unwind.diff b/tests/mir-opt/gvn.casts_before_aggregate_raw_ptr.GVN.panic-unwind.diff index fd09310fabdeb..bb35b7ef57b2c 100644 --- a/tests/mir-opt/gvn.casts_before_aggregate_raw_ptr.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.casts_before_aggregate_raw_ptr.GVN.panic-unwind.diff @@ -22,22 +22,19 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _3 = copy _1; - _2 = move _3 as *const [u8; 4] (PtrToPtr); + _2 = copy _1 as *const [u8; 4] (PtrToPtr); StorageDead(_3); -- StorageLive(_4); -+ nop; + StorageLive(_4); StorageLive(_5); _5 = copy _2; - _4 = move _5 as *const u8 (PtrToPtr); + _4 = copy _1 as *const u8 (PtrToPtr); StorageDead(_5); -- StorageLive(_6); -+ nop; + StorageLive(_6); StorageLive(_7); _7 = copy _4; - _6 = move _7 as *const () (PtrToPtr); @@ -48,12 +45,9 @@ - _0 = *const [u8] from (move _8, const 4_usize); + _0 = *const [u8] from (copy _1, const 4_usize); StorageDead(_8); -- StorageDead(_6); -- StorageDead(_4); -- StorageDead(_2); -+ nop; -+ nop; -+ nop; + StorageDead(_6); + StorageDead(_4); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff index 183b4d2599f53..5ce130fbace82 100644 --- a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff @@ -25,9 +25,8 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); - _2 = const core::num::::MAX as usize (IntToInt); -+ nop; + _2 = const usize::MAX; StorageLive(_3); StorageLive(_4); @@ -96,8 +95,7 @@ bb7: { StorageDead(_14); StorageDead(_3); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff index 03e8aa3bd9b98..f81b8cbecb663 100644 --- a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff @@ -25,9 +25,8 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); - _2 = const core::num::::MAX as usize (IntToInt); -+ nop; + _2 = const usize::MAX; StorageLive(_3); StorageLive(_4); @@ -96,8 +95,7 @@ bb7: { StorageDead(_14); StorageDead(_3); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff index 3cce35d34e90d..f8180886e97be 100644 --- a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff @@ -35,8 +35,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = identity:: as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer, AsCast)); StorageLive(_2); StorageLive(_3); @@ -48,8 +47,7 @@ bb1: { StorageDead(_3); StorageDead(_2); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = identity:: as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer, AsCast)); StorageLive(_5); StorageLive(_6); @@ -61,12 +59,10 @@ bb2: { StorageDead(_6); StorageDead(_5); -- StorageLive(_7); + StorageLive(_7); - _7 = {closure@$DIR/gvn.rs:620:19: 620:21}; -- StorageLive(_8); -+ nop; + _7 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21}; -+ nop; + StorageLive(_8); StorageLive(_9); - _9 = copy _7; - _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); @@ -83,8 +79,7 @@ bb3: { StorageDead(_11); StorageDead(_10); -- StorageLive(_12); -+ nop; + StorageLive(_12); StorageLive(_13); - _13 = copy _7; - _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); @@ -102,16 +97,11 @@ StorageDead(_15); StorageDead(_14); _0 = const (); -- StorageDead(_12); -- StorageDead(_8); -- StorageDead(_7); -- StorageDead(_4); -- StorageDead(_1); -+ nop; -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_12); + StorageDead(_8); + StorageDead(_7); + StorageDead(_4); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff index d85aca040fe67..44e6e914cd92c 100644 --- a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff @@ -35,8 +35,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = identity:: as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer, AsCast)); StorageLive(_2); StorageLive(_3); @@ -48,8 +47,7 @@ bb1: { StorageDead(_3); StorageDead(_2); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = identity:: as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer, AsCast)); StorageLive(_5); StorageLive(_6); @@ -61,12 +59,10 @@ bb2: { StorageDead(_6); StorageDead(_5); -- StorageLive(_7); + StorageLive(_7); - _7 = {closure@$DIR/gvn.rs:620:19: 620:21}; -- StorageLive(_8); -+ nop; + _7 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21}; -+ nop; + StorageLive(_8); StorageLive(_9); - _9 = copy _7; - _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); @@ -83,8 +79,7 @@ bb3: { StorageDead(_11); StorageDead(_10); -- StorageLive(_12); -+ nop; + StorageLive(_12); StorageLive(_13); - _13 = copy _7; - _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); @@ -102,16 +97,11 @@ StorageDead(_15); StorageDead(_14); _0 = const (); -- StorageDead(_12); -- StorageDead(_8); -- StorageDead(_7); -- StorageDead(_4); -- StorageDead(_1); -+ nop; -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_12); + StorageDead(_8); + StorageDead(_7); + StorageDead(_4); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/gvn.manual_slice_mut_len.GVN.panic-abort.diff b/tests/mir-opt/gvn.manual_slice_mut_len.GVN.panic-abort.diff index 936fa3db82a73..7741d0907d2ba 100644 --- a/tests/mir-opt/gvn.manual_slice_mut_len.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.manual_slice_mut_len.GVN.panic-abort.diff @@ -16,11 +16,9 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = &raw mut (*_1); -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _2; - _3 = move _4 as *const [i32] (PtrToPtr); @@ -31,10 +29,8 @@ - _0 = PtrMetadata(move _5); + _0 = PtrMetadata(copy _1); StorageDead(_5); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.manual_slice_mut_len.GVN.panic-unwind.diff b/tests/mir-opt/gvn.manual_slice_mut_len.GVN.panic-unwind.diff index 936fa3db82a73..7741d0907d2ba 100644 --- a/tests/mir-opt/gvn.manual_slice_mut_len.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.manual_slice_mut_len.GVN.panic-unwind.diff @@ -16,11 +16,9 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = &raw mut (*_1); -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _2; - _3 = move _4 as *const [i32] (PtrToPtr); @@ -31,10 +29,8 @@ - _0 = PtrMetadata(move _5); + _0 = PtrMetadata(copy _1); StorageDead(_5); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.meta_of_ref_to_slice.GVN.panic-abort.diff b/tests/mir-opt/gvn.meta_of_ref_to_slice.GVN.panic-abort.diff index 3ed6c2b5308fb..1825d68f1939c 100644 --- a/tests/mir-opt/gvn.meta_of_ref_to_slice.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.meta_of_ref_to_slice.GVN.panic-abort.diff @@ -12,8 +12,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _3 = copy _1; - _2 = *const [i32] from (move _3, const 1_usize); @@ -24,8 +23,7 @@ - _0 = PtrMetadata(move _4); + _0 = const 1_usize; StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.meta_of_ref_to_slice.GVN.panic-unwind.diff b/tests/mir-opt/gvn.meta_of_ref_to_slice.GVN.panic-unwind.diff index 3ed6c2b5308fb..1825d68f1939c 100644 --- a/tests/mir-opt/gvn.meta_of_ref_to_slice.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.meta_of_ref_to_slice.GVN.panic-unwind.diff @@ -12,8 +12,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _3 = copy _1; - _2 = *const [i32] from (move _3, const 1_usize); @@ -24,8 +23,7 @@ - _0 = PtrMetadata(move _4); + _0 = const 1_usize; StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.references.GVN.panic-abort.diff b/tests/mir-opt/gvn.references.GVN.panic-abort.diff index 62a487dee8215..429c7df2f361e 100644 --- a/tests/mir-opt/gvn.references.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.references.GVN.panic-abort.diff @@ -112,8 +112,7 @@ bb8: { StorageDead(_17); StorageDead(_16); -- StorageLive(_18); -+ nop; + StorageLive(_18); _18 = &mut _1; StorageLive(_19); StorageLive(_20); @@ -168,8 +167,7 @@ StorageDead(_28); _0 = const (); StorageDead(_19); -- StorageDead(_18); -+ nop; + StorageDead(_18); drop(_1) -> [return: bb13, unwind unreachable]; } diff --git a/tests/mir-opt/gvn.references.GVN.panic-unwind.diff b/tests/mir-opt/gvn.references.GVN.panic-unwind.diff index 6dd986907fcc6..c2d67507c39d3 100644 --- a/tests/mir-opt/gvn.references.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.references.GVN.panic-unwind.diff @@ -112,8 +112,7 @@ bb8: { StorageDead(_17); StorageDead(_16); -- StorageLive(_18); -+ nop; + StorageLive(_18); _18 = &mut _1; StorageLive(_19); StorageLive(_20); @@ -168,8 +167,7 @@ StorageDead(_28); _0 = const (); StorageDead(_19); -- StorageDead(_18); -+ nop; + StorageDead(_18); drop(_1) -> [return: bb13, unwind: bb15]; } diff --git a/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff b/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff index ef2eb1a66779d..0b8b682ba52ce 100644 --- a/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff @@ -23,8 +23,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 5_i32; StorageLive(_2); StorageLive(_3); @@ -71,8 +70,7 @@ StorageDead(_3); _0 = const (); StorageDead(_2); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff b/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff index ef2eb1a66779d..0b8b682ba52ce 100644 --- a/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff @@ -23,8 +23,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 5_i32; StorageLive(_2); StorageLive(_3); @@ -71,8 +70,7 @@ StorageDead(_3); _0 = const (); StorageDead(_2); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/gvn.slice_const_length.GVN.panic-abort.diff b/tests/mir-opt/gvn.slice_const_length.GVN.panic-abort.diff index 1a6204e4ac8ae..412f908821ab6 100644 --- a/tests/mir-opt/gvn.slice_const_length.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slice_const_length.GVN.panic-abort.diff @@ -17,8 +17,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _3 = &(*_1); _2 = core::slice::::as_ptr(move _3) -> [return: bb1, unwind unreachable]; @@ -26,8 +25,7 @@ bb1: { StorageDead(_3); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = const 123_usize; StorageLive(_5); _5 = copy _2; @@ -38,10 +36,8 @@ + _0 = *const [i32] from (copy _2, const 123_usize); StorageDead(_6); StorageDead(_5); -- StorageDead(_4); -- StorageDead(_2); -+ nop; -+ nop; + StorageDead(_4); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.slice_const_length.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slice_const_length.GVN.panic-unwind.diff index 62d57b0fe2831..6f166971631c2 100644 --- a/tests/mir-opt/gvn.slice_const_length.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slice_const_length.GVN.panic-unwind.diff @@ -17,8 +17,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _3 = &(*_1); _2 = core::slice::::as_ptr(move _3) -> [return: bb1, unwind continue]; @@ -26,8 +25,7 @@ bb1: { StorageDead(_3); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = const 123_usize; StorageLive(_5); _5 = copy _2; @@ -38,10 +36,8 @@ + _0 = *const [i32] from (copy _2, const 123_usize); StorageDead(_6); StorageDead(_5); -- StorageDead(_4); -- StorageDead(_2); -+ nop; -+ nop; + StorageDead(_4); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn.slice_from_raw_parts_as_ptr.GVN.panic-abort.diff b/tests/mir-opt/gvn.slice_from_raw_parts_as_ptr.GVN.panic-abort.diff index 4a2cc25189191..ab4971cc6c017 100644 --- a/tests/mir-opt/gvn.slice_from_raw_parts_as_ptr.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slice_from_raw_parts_as_ptr.GVN.panic-abort.diff @@ -17,8 +17,7 @@ } bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; StorageLive(_5); @@ -43,8 +42,7 @@ + _0 = (copy _1, move _8); StorageDead(_8); StorageDead(_6); -- StorageDead(_3); -+ nop; + StorageDead(_3); return; } } diff --git a/tests/mir-opt/gvn.slice_from_raw_parts_as_ptr.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slice_from_raw_parts_as_ptr.GVN.panic-unwind.diff index 4a2cc25189191..ab4971cc6c017 100644 --- a/tests/mir-opt/gvn.slice_from_raw_parts_as_ptr.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slice_from_raw_parts_as_ptr.GVN.panic-unwind.diff @@ -17,8 +17,7 @@ } bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; StorageLive(_5); @@ -43,8 +42,7 @@ + _0 = (copy _1, move _8); StorageDead(_8); StorageDead(_6); -- StorageDead(_3); -+ nop; + StorageDead(_3); return; } } diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff index e8e99b44e721b..21a1292907c67 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff @@ -82,8 +82,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const "my favourite slice"; StorageLive(_2); StorageLive(_3); @@ -111,9 +110,8 @@ StorageLive(_7); StorageLive(_8); - StorageLive(_9); -- StorageLive(_10); -+ nop; + nop; + StorageLive(_10); StorageLive(_11); _11 = &(*_1); _10 = core::str::::as_ptr(move _11) -> [return: bb3, unwind unreachable]; @@ -123,9 +121,8 @@ StorageDead(_11); _9 = &_10; - StorageLive(_12); -- StorageLive(_13); -+ nop; + nop; + StorageLive(_13); StorageLive(_14); - _14 = &(*_4); + _14 = &(*_1); @@ -166,14 +163,11 @@ StorageDead(_17); StorageDead(_16); StorageDead(_15); -- StorageDead(_13); -- StorageDead(_10); -+ nop; -+ nop; + StorageDead(_13); + StorageDead(_10); StorageDead(_8); StorageDead(_7); -- StorageLive(_29); -+ nop; + StorageLive(_29); StorageLive(_30); _30 = &(*_1); _29 = move _30 as &[u8] (Transmute); @@ -188,9 +182,8 @@ bb6: { StorageDead(_19); StorageDead(_18); -- StorageLive(_21); + StorageLive(_21); - _21 = core::panicking::AssertKind::Eq; -+ nop; + _21 = const core::panicking::AssertKind::Eq; StorageLive(_22); StorageLive(_23); @@ -218,9 +211,8 @@ StorageLive(_33); StorageLive(_34); - StorageLive(_35); -- StorageLive(_36); -+ nop; + nop; + StorageLive(_36); StorageLive(_37); _37 = &(*_1); _36 = core::str::::as_ptr(move _37) -> [return: bb8, unwind unreachable]; @@ -230,9 +222,8 @@ StorageDead(_37); _35 = &_36; - StorageLive(_38); -- StorageLive(_39); -+ nop; + nop; + StorageLive(_39); StorageLive(_40); _40 = &(*_29); _39 = core::slice::::as_ptr(move _40) -> [return: bb9, unwind unreachable]; @@ -272,27 +263,22 @@ StorageDead(_43); StorageDead(_42); StorageDead(_41); -- StorageDead(_39); -- StorageDead(_36); -+ nop; -+ nop; + StorageDead(_39); + StorageDead(_36); StorageDead(_34); StorageDead(_33); _0 = const (); -- StorageDead(_29); -+ nop; + StorageDead(_29); StorageDead(_4); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } bb11: { StorageDead(_45); StorageDead(_44); -- StorageLive(_47); + StorageLive(_47); - _47 = core::panicking::AssertKind::Eq; -+ nop; + _47 = const core::panicking::AssertKind::Eq; StorageLive(_48); StorageLive(_49); diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff index 4296d4d4a5945..141d6346f4eb2 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff @@ -82,8 +82,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const "my favourite slice"; StorageLive(_2); StorageLive(_3); @@ -111,9 +110,8 @@ StorageLive(_7); StorageLive(_8); - StorageLive(_9); -- StorageLive(_10); -+ nop; + nop; + StorageLive(_10); StorageLive(_11); _11 = &(*_1); _10 = core::str::::as_ptr(move _11) -> [return: bb3, unwind continue]; @@ -123,9 +121,8 @@ StorageDead(_11); _9 = &_10; - StorageLive(_12); -- StorageLive(_13); -+ nop; + nop; + StorageLive(_13); StorageLive(_14); - _14 = &(*_4); + _14 = &(*_1); @@ -166,14 +163,11 @@ StorageDead(_17); StorageDead(_16); StorageDead(_15); -- StorageDead(_13); -- StorageDead(_10); -+ nop; -+ nop; + StorageDead(_13); + StorageDead(_10); StorageDead(_8); StorageDead(_7); -- StorageLive(_29); -+ nop; + StorageLive(_29); StorageLive(_30); _30 = &(*_1); _29 = move _30 as &[u8] (Transmute); @@ -188,9 +182,8 @@ bb6: { StorageDead(_19); StorageDead(_18); -- StorageLive(_21); + StorageLive(_21); - _21 = core::panicking::AssertKind::Eq; -+ nop; + _21 = const core::panicking::AssertKind::Eq; StorageLive(_22); StorageLive(_23); @@ -218,9 +211,8 @@ StorageLive(_33); StorageLive(_34); - StorageLive(_35); -- StorageLive(_36); -+ nop; + nop; + StorageLive(_36); StorageLive(_37); _37 = &(*_1); _36 = core::str::::as_ptr(move _37) -> [return: bb8, unwind continue]; @@ -230,9 +222,8 @@ StorageDead(_37); _35 = &_36; - StorageLive(_38); -- StorageLive(_39); -+ nop; + nop; + StorageLive(_39); StorageLive(_40); _40 = &(*_29); _39 = core::slice::::as_ptr(move _40) -> [return: bb9, unwind continue]; @@ -272,27 +263,22 @@ StorageDead(_43); StorageDead(_42); StorageDead(_41); -- StorageDead(_39); -- StorageDead(_36); -+ nop; -+ nop; + StorageDead(_39); + StorageDead(_36); StorageDead(_34); StorageDead(_33); _0 = const (); -- StorageDead(_29); -+ nop; + StorageDead(_29); StorageDead(_4); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } bb11: { StorageDead(_45); StorageDead(_44); -- StorageLive(_47); + StorageLive(_47); - _47 = core::panicking::AssertKind::Eq; -+ nop; + _47 = const core::panicking::AssertKind::Eq; StorageLive(_48); StorageLive(_49); diff --git a/tests/mir-opt/gvn.transmute_then_cast_pointer.GVN.panic-abort.diff b/tests/mir-opt/gvn.transmute_then_cast_pointer.GVN.panic-abort.diff index 0bec425dd9957..230a420d0c3d6 100644 --- a/tests/mir-opt/gvn.transmute_then_cast_pointer.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.transmute_then_cast_pointer.GVN.panic-abort.diff @@ -34,8 +34,7 @@ } bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; - _3 = move _4 as *mut u8 (Transmute); @@ -54,8 +53,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageLive(_8); -+ nop; + StorageLive(_8); StorageLive(_9); StorageLive(_10); StorageLive(_11); @@ -82,8 +80,7 @@ bb2: { StorageDead(_14); StorageDead(_13); -- StorageLive(_16); -+ nop; + StorageLive(_16); StorageLive(_17); _17 = copy _2; - _16 = move _17 as *const [u8] (Transmute); @@ -103,12 +100,9 @@ StorageDead(_19); StorageDead(_18); _0 = const (); -- StorageDead(_16); -- StorageDead(_8); -- StorageDead(_3); -+ nop; -+ nop; -+ nop; + StorageDead(_16); + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/gvn.transmute_then_cast_pointer.GVN.panic-unwind.diff b/tests/mir-opt/gvn.transmute_then_cast_pointer.GVN.panic-unwind.diff index 14f2fe08a86a2..a20b9cef59ae3 100644 --- a/tests/mir-opt/gvn.transmute_then_cast_pointer.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.transmute_then_cast_pointer.GVN.panic-unwind.diff @@ -34,8 +34,7 @@ } bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; - _3 = move _4 as *mut u8 (Transmute); @@ -54,8 +53,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageLive(_8); -+ nop; + StorageLive(_8); StorageLive(_9); StorageLive(_10); StorageLive(_11); @@ -82,8 +80,7 @@ bb2: { StorageDead(_14); StorageDead(_13); -- StorageLive(_16); -+ nop; + StorageLive(_16); StorageLive(_17); _17 = copy _2; - _16 = move _17 as *const [u8] (Transmute); @@ -103,12 +100,9 @@ StorageDead(_19); StorageDead(_18); _0 = const (); -- StorageDead(_16); -- StorageDead(_8); -- StorageDead(_3); -+ nop; -+ nop; -+ nop; + StorageDead(_16); + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-abort.diff b/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-abort.diff index 962fecd2586eb..7eea36055f57a 100644 --- a/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-abort.diff @@ -23,8 +23,7 @@ } bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; - _3 = move _4 as char (Transmute); @@ -43,8 +42,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageLive(_8); -+ nop; + StorageLive(_8); StorageLive(_9); _9 = copy _2; - _8 = move _9 as u32 (Transmute); @@ -64,10 +62,8 @@ StorageDead(_11); StorageDead(_10); _0 = const (); -- StorageDead(_8); -- StorageDead(_3); -+ nop; -+ nop; + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-unwind.diff b/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-unwind.diff index e32397c1aed07..b133b403729f4 100644 --- a/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.transmute_then_transmute_again.GVN.panic-unwind.diff @@ -23,8 +23,7 @@ } bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; - _3 = move _4 as char (Transmute); @@ -43,8 +42,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageLive(_8); -+ nop; + StorageLive(_8); StorageLive(_9); _9 = copy _2; - _8 = move _9 as u32 (Transmute); @@ -64,10 +62,8 @@ StorageDead(_11); StorageDead(_10); _0 = const (); -- StorageDead(_8); -- StorageDead(_3); -+ nop; -+ nop; + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/gvn.unary.GVN.panic-abort.diff b/tests/mir-opt/gvn.unary.GVN.panic-abort.diff index d14aec6df5fae..2b23b0a32d551 100644 --- a/tests/mir-opt/gvn.unary.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.unary.GVN.panic-abort.diff @@ -51,8 +51,7 @@ bb1: { StorageDead(_3); StorageDead(_2); -- StorageLive(_6); -+ nop; + StorageLive(_6); StorageLive(_7); _7 = copy _1; - _6 = Lt(move _7, const 13_i64); @@ -145,8 +144,7 @@ StorageDead(_23); StorageDead(_22); _0 = const (); -- StorageDead(_6); -+ nop; + StorageDead(_6); return; } } diff --git a/tests/mir-opt/gvn.unary.GVN.panic-unwind.diff b/tests/mir-opt/gvn.unary.GVN.panic-unwind.diff index 5978f1faa1f68..a2ca0dcb18dbd 100644 --- a/tests/mir-opt/gvn.unary.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.unary.GVN.panic-unwind.diff @@ -51,8 +51,7 @@ bb1: { StorageDead(_3); StorageDead(_2); -- StorageLive(_6); -+ nop; + StorageLive(_6); StorageLive(_7); _7 = copy _1; - _6 = Lt(move _7, const 13_i64); @@ -145,8 +144,7 @@ StorageDead(_23); StorageDead(_22); _0 = const (); -- StorageDead(_6); -+ nop; + StorageDead(_6); return; } } diff --git a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff index bb938f3ba6a9a..0d0c17c7c76a8 100644 --- a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff @@ -39,16 +39,14 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); - _2 = (const 1_usize, const 1_usize); - _1 = move _2 as *const [u8] (Transmute); + _2 = const (1_usize, 1_usize); + _1 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; StorageDead(_2); -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); - _4 = (const 1_usize, const 2_usize); - _3 = move _4 as *const [u8] (Transmute); @@ -170,10 +168,8 @@ StorageDead(_26); StorageDead(_25); _0 = const (); -- StorageDead(_3); -- StorageDead(_1); -+ nop; -+ nop; + StorageDead(_3); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff index 81432d687eb32..885ca25c32990 100644 --- a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff @@ -39,16 +39,14 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); - _2 = (const 1_usize, const 1_usize); - _1 = move _2 as *const [u8] (Transmute); + _2 = const (1_usize, 1_usize); + _1 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; StorageDead(_2); -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); - _4 = (const 1_usize, const 2_usize); - _3 = move _4 as *const [u8] (Transmute); @@ -170,10 +168,8 @@ StorageDead(_26); StorageDead(_25); _0 = const (); -- StorageDead(_3); -- StorageDead(_1); -+ nop; -+ nop; + StorageDead(_3); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/gvn_clone.{impl#0}-clone.GVN.diff b/tests/mir-opt/gvn_clone.{impl#0}-clone.GVN.diff index 0f23415ec53bb..9381c7c0af537 100644 --- a/tests/mir-opt/gvn_clone.{impl#0}-clone.GVN.diff +++ b/tests/mir-opt/gvn_clone.{impl#0}-clone.GVN.diff @@ -17,8 +17,7 @@ bb0: { StorageLive(_2); StorageLive(_3); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = &((*_1).0: i32); _3 = copy _4; - _2 = copy (*_3); @@ -30,8 +29,7 @@ StorageDead(_3); StorageLive(_5); StorageLive(_6); -- StorageLive(_7); -+ nop; + StorageLive(_7); _7 = &((*_1).1: u64); _6 = copy _7; - _5 = copy (*_6); @@ -43,8 +41,7 @@ StorageDead(_6); StorageLive(_8); StorageLive(_9); -- StorageLive(_10); -+ nop; + StorageLive(_10); _10 = &((*_1).2: [i8; 3]); _9 = copy _10; - _8 = copy (*_9); @@ -55,15 +52,12 @@ bb3: { StorageDead(_9); - _0 = AllCopy { a: move _2, b: move _5, c: move _8 }; -- StorageDead(_10); + _0 = copy (*_1); -+ nop; + StorageDead(_10); StorageDead(_8); -- StorageDead(_7); -+ nop; + StorageDead(_7); StorageDead(_5); -- StorageDead(_4); -+ nop; + StorageDead(_4); StorageDead(_2); return; } diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy.GVN.diff index f6345d5809f29..e88fc3e8553c3 100644 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.all_copy.GVN.diff @@ -21,14 +21,11 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = copy ((*_1).0: i32); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = copy ((*_1).1: u64); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = copy ((*_1).2: [i8; 3]); StorageLive(_5); _5 = copy _2; @@ -41,12 +38,9 @@ StorageDead(_7); StorageDead(_6); StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; -+ nop; + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy_2.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy_2.GVN.diff index 452d8a9332036..a9fb55f1d8f9a 100644 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy_2.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.all_copy_2.GVN.diff @@ -24,21 +24,18 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); - _8 = deref_copy (*_1); -+ nop; + _8 = copy (*_1); _2 = copy ((*_8).0: i32); -- StorageLive(_3); + StorageLive(_3); - _9 = deref_copy (*_1); - _3 = copy ((*_9).1: u64); -- StorageLive(_4); -- _10 = deref_copy (*_1); -- _4 = copy ((*_10).2: [i8; 3]); -+ nop; + _9 = copy _8; + _3 = copy ((*_8).1: u64); -+ nop; + StorageLive(_4); +- _10 = deref_copy (*_1); +- _4 = copy ((*_10).2: [i8; 3]); + _10 = copy _8; + _4 = copy ((*_8).2: [i8; 3]); StorageLive(_5); @@ -52,12 +49,9 @@ StorageDead(_7); StorageDead(_6); StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; -+ nop; + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy_different_type.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy_different_type.GVN.diff index 37652095fa440..5f22429b4a2a1 100644 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy_different_type.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.all_copy_different_type.GVN.diff @@ -21,14 +21,11 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = copy ((*_1).0: i32); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = copy ((*_1).1: u64); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = copy ((*_1).2: [i8; 3]); StorageLive(_5); _5 = copy _2; @@ -41,12 +38,9 @@ StorageDead(_7); StorageDead(_6); StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; -+ nop; + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy_has_changed.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy_has_changed.GVN.diff index 8012c26499c98..7a90189c4c496 100644 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy_has_changed.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.all_copy_has_changed.GVN.diff @@ -21,14 +21,11 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = copy ((*_1).0: i32); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = copy ((*_1).1: u64); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = copy ((*_1).2: [i8; 3]); ((*_1).0: i32) = const 1_i32; StorageLive(_5); @@ -42,12 +39,9 @@ StorageDead(_7); StorageDead(_6); StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; -+ nop; + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy_move.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy_move.GVN.diff index 911b787a64bdb..416ee4ce7eea1 100644 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy_move.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.all_copy_move.GVN.diff @@ -21,14 +21,11 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = copy (_1.0: i32); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = copy (_1.1: u64); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = copy (_1.2: [i8; 3]); StorageLive(_5); _5 = copy _2; @@ -41,12 +38,9 @@ StorageDead(_7); StorageDead(_6); StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; -+ nop; + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy_ret_2.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy_ret_2.GVN.diff index 5c6e2a6bc67db..fccbe492b4795 100644 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy_ret_2.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.all_copy_ret_2.GVN.diff @@ -26,17 +26,13 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = copy ((*_1).0: i32); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = copy ((*_1).1: u64); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = copy ((*_1).2: [i8; 3]); -- StorageLive(_5); -+ nop; + StorageLive(_5); StorageLive(_6); _6 = copy _2; StorageLive(_7); @@ -63,14 +59,10 @@ - _0 = (move _5, move _9); + _0 = (copy _5, copy _5); StorageDead(_9); -- StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy_use_changed.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy_use_changed.GVN.diff index dc65cccb7bd6e..e3842c9064fe4 100644 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy_use_changed.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.all_copy_use_changed.GVN.diff @@ -29,11 +29,9 @@ _3 = copy ((*_1).0: i32); _2 = move _3; StorageDead(_3); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = copy ((*_1).1: u64); -- StorageLive(_5); -+ nop; + StorageLive(_5); _5 = copy ((*_1).2: [i8; 3]); StorageLive(_6); _6 = copy _2; @@ -46,10 +44,8 @@ StorageDead(_8); StorageDead(_7); StorageDead(_6); -- StorageDead(_5); -- StorageDead(_4); -+ nop; -+ nop; + StorageDead(_5); + StorageDead(_4); StorageDead(_2); return; } diff --git a/tests/mir-opt/gvn_copy_aggregate.all_copy_use_changed_2.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.all_copy_use_changed_2.GVN.diff index 08a4a078adcb4..3769c3cfa2ee4 100644 --- a/tests/mir-opt/gvn_copy_aggregate.all_copy_use_changed_2.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.all_copy_use_changed_2.GVN.diff @@ -24,11 +24,9 @@ bb0: { StorageLive(_2); _2 = copy ((*_1).0: i32); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = copy ((*_1).1: u64); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = copy ((*_1).2: [i8; 3]); ((*_1).0: i32) = const 1_i32; StorageLive(_5); @@ -46,10 +44,8 @@ StorageDead(_8); StorageDead(_7); StorageDead(_6); -- StorageDead(_4); -- StorageDead(_3); -+ nop; -+ nop; + StorageDead(_4); + StorageDead(_3); StorageDead(_2); return; } diff --git a/tests/mir-opt/gvn_copy_aggregate.enum_different_variant.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.enum_different_variant.GVN.diff index 99318d395e218..a7063289e8ae6 100644 --- a/tests/mir-opt/gvn_copy_aggregate.enum_different_variant.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.enum_different_variant.GVN.diff @@ -66,20 +66,16 @@ bb2: { StorageLive(_12); _12 = &(((*_1) as B).0: AllCopy); -- StorageLive(_13); + StorageLive(_13); - _13 = copy ((*_12).0: i32); -- StorageLive(_14); -- _14 = copy ((*_12).1: u64); -- StorageLive(_15); -- _15 = copy ((*_12).2: [i8; 3]); -- StorageLive(_16); -+ nop; + _13 = copy ((((*_1) as B).0: AllCopy).0: i32); -+ nop; + StorageLive(_14); +- _14 = copy ((*_12).1: u64); + _14 = copy ((((*_1) as B).0: AllCopy).1: u64); -+ nop; + StorageLive(_15); +- _15 = copy ((*_12).2: [i8; 3]); + _15 = copy ((((*_1) as B).0: AllCopy).2: [i8; 3]); -+ nop; + StorageLive(_16); StorageLive(_17); _17 = copy _13; StorageLive(_18); @@ -97,14 +93,10 @@ + _20 = copy _16; + _0 = Enum1::A(copy _16); StorageDead(_20); -- StorageDead(_16); -- StorageDead(_15); -- StorageDead(_14); -- StorageDead(_13); -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_16); + StorageDead(_15); + StorageDead(_14); + StorageDead(_13); StorageDead(_12); goto -> bb4; } @@ -112,20 +104,16 @@ bb3: { StorageLive(_3); _3 = &(((*_1) as A).0: AllCopy); -- StorageLive(_4); + StorageLive(_4); - _4 = copy ((*_3).0: i32); -- StorageLive(_5); -- _5 = copy ((*_3).1: u64); -- StorageLive(_6); -- _6 = copy ((*_3).2: [i8; 3]); -- StorageLive(_7); -+ nop; + _4 = copy ((((*_1) as A).0: AllCopy).0: i32); -+ nop; + StorageLive(_5); +- _5 = copy ((*_3).1: u64); + _5 = copy ((((*_1) as A).0: AllCopy).1: u64); -+ nop; + StorageLive(_6); +- _6 = copy ((*_3).2: [i8; 3]); + _6 = copy ((((*_1) as A).0: AllCopy).2: [i8; 3]); -+ nop; + StorageLive(_7); StorageLive(_8); _8 = copy _4; StorageLive(_9); @@ -143,14 +131,10 @@ + _11 = copy _7; + _0 = Enum1::B(copy _7); StorageDead(_11); -- StorageDead(_7); -- StorageDead(_6); -- StorageDead(_5); -- StorageDead(_4); -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); StorageDead(_3); goto -> bb4; } diff --git a/tests/mir-opt/gvn_copy_aggregate.enum_identical_variant.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.enum_identical_variant.GVN.diff index b740ba6411bd2..22ebaa5ca1932 100644 --- a/tests/mir-opt/gvn_copy_aggregate.enum_identical_variant.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.enum_identical_variant.GVN.diff @@ -66,20 +66,16 @@ bb2: { StorageLive(_12); _12 = &(((*_1) as B).0: AllCopy); -- StorageLive(_13); + StorageLive(_13); - _13 = copy ((*_12).0: i32); -- StorageLive(_14); -- _14 = copy ((*_12).1: u64); -- StorageLive(_15); -- _15 = copy ((*_12).2: [i8; 3]); -- StorageLive(_16); -+ nop; + _13 = copy ((((*_1) as B).0: AllCopy).0: i32); -+ nop; + StorageLive(_14); +- _14 = copy ((*_12).1: u64); + _14 = copy ((((*_1) as B).0: AllCopy).1: u64); -+ nop; + StorageLive(_15); +- _15 = copy ((*_12).2: [i8; 3]); + _15 = copy ((((*_1) as B).0: AllCopy).2: [i8; 3]); -+ nop; + StorageLive(_16); StorageLive(_17); _17 = copy _13; StorageLive(_18); @@ -97,14 +93,10 @@ + _20 = copy _16; + _0 = copy (*_1); StorageDead(_20); -- StorageDead(_16); -- StorageDead(_15); -- StorageDead(_14); -- StorageDead(_13); -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_16); + StorageDead(_15); + StorageDead(_14); + StorageDead(_13); StorageDead(_12); goto -> bb4; } @@ -112,20 +104,16 @@ bb3: { StorageLive(_3); _3 = &(((*_1) as A).0: AllCopy); -- StorageLive(_4); + StorageLive(_4); - _4 = copy ((*_3).0: i32); -- StorageLive(_5); -- _5 = copy ((*_3).1: u64); -- StorageLive(_6); -- _6 = copy ((*_3).2: [i8; 3]); -- StorageLive(_7); -+ nop; + _4 = copy ((((*_1) as A).0: AllCopy).0: i32); -+ nop; + StorageLive(_5); +- _5 = copy ((*_3).1: u64); + _5 = copy ((((*_1) as A).0: AllCopy).1: u64); -+ nop; + StorageLive(_6); +- _6 = copy ((*_3).2: [i8; 3]); + _6 = copy ((((*_1) as A).0: AllCopy).2: [i8; 3]); -+ nop; + StorageLive(_7); StorageLive(_8); _8 = copy _4; StorageLive(_9); @@ -143,14 +131,10 @@ + _11 = copy _7; + _0 = copy (*_1); StorageDead(_11); -- StorageDead(_7); -- StorageDead(_6); -- StorageDead(_5); -- StorageDead(_4); -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); StorageDead(_3); goto -> bb4; } diff --git a/tests/mir-opt/gvn_copy_aggregate.nest_copy.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.nest_copy.GVN.diff index ee5906bab1161..f8515be75b8de 100644 --- a/tests/mir-opt/gvn_copy_aggregate.nest_copy.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.nest_copy.GVN.diff @@ -31,17 +31,13 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = copy (((*_1).1: AllCopy).0: i32); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = copy (((*_1).1: AllCopy).1: u64); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = copy (((*_1).1: AllCopy).2: [i8; 3]); -- StorageLive(_5); -+ nop; + StorageLive(_5); StorageLive(_6); _6 = copy _2; StorageLive(_7); @@ -53,8 +49,7 @@ StorageDead(_8); StorageDead(_7); StorageDead(_6); -- StorageLive(_9); -+ nop; + StorageLive(_9); _9 = copy ((*_1).0: i32); StorageLive(_10); _10 = copy _9; @@ -65,16 +60,11 @@ + _0 = copy (*_1); StorageDead(_11); StorageDead(_10); -- StorageDead(_9); -- StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; -+ nop; -+ nop; -+ nop; + StorageDead(_9); + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn_copy_aggregate.same_type_different_index.GVN.diff b/tests/mir-opt/gvn_copy_aggregate.same_type_different_index.GVN.diff index e3126b09a58e2..9c214330e352e 100644 --- a/tests/mir-opt/gvn_copy_aggregate.same_type_different_index.GVN.diff +++ b/tests/mir-opt/gvn_copy_aggregate.same_type_different_index.GVN.diff @@ -16,11 +16,9 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = copy ((*_1).1: i32); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = copy ((*_1).0: i32); StorageLive(_4); _4 = copy _2; @@ -30,10 +28,8 @@ + _0 = SameType { a: copy _2, b: copy _3 }; StorageDead(_5); StorageDead(_4); -- StorageDead(_3); -- StorageDead(_2); -+ nop; -+ nop; + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/gvn_copy_constant_projection.compare_constant_index.GVN.panic-abort.diff b/tests/mir-opt/gvn_copy_constant_projection.compare_constant_index.GVN.panic-abort.diff index e2e55304921b2..c107eec9ee65b 100644 --- a/tests/mir-opt/gvn_copy_constant_projection.compare_constant_index.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn_copy_constant_projection.compare_constant_index.GVN.panic-abort.diff @@ -17,8 +17,7 @@ } bb0: { -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = const 0_usize; - _5 = Lt(copy _4, const 1_usize); - assert(move _5, "index out of bounds: the length is {} but the index is {}", const 1_usize, copy _4) -> [success: bb1, unwind unreachable]; @@ -50,8 +49,7 @@ StorageDead(_10); StorageDead(_9); StorageDead(_7); -- StorageDead(_4); -+ nop; + StorageDead(_4); return; } } diff --git a/tests/mir-opt/gvn_copy_constant_projection.compare_constant_index.GVN.panic-unwind.diff b/tests/mir-opt/gvn_copy_constant_projection.compare_constant_index.GVN.panic-unwind.diff index 60611146a0eec..498df5adc1ef7 100644 --- a/tests/mir-opt/gvn_copy_constant_projection.compare_constant_index.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn_copy_constant_projection.compare_constant_index.GVN.panic-unwind.diff @@ -17,8 +17,7 @@ } bb0: { -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = const 0_usize; - _5 = Lt(copy _4, const 1_usize); - assert(move _5, "index out of bounds: the length is {} but the index is {}", const 1_usize, copy _4) -> [success: bb1, unwind continue]; @@ -50,8 +49,7 @@ StorageDead(_10); StorageDead(_9); StorageDead(_7); -- StorageDead(_4); -+ nop; + StorageDead(_4); return; } } diff --git a/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff b/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff index e28d04f1d5885..cef44cb99d66c 100644 --- a/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff +++ b/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff @@ -14,8 +14,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); _1 = const 1_i32; StorageLive(_2); StorageLive(_3); @@ -27,8 +26,7 @@ - _0 = move _2; + _0 = const {transmute(0x00000001): unsafe<> i32}; StorageDead(_2); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/gvn_storage_twice.repeat_local.GVN.diff b/tests/mir-opt/gvn_storage_twice.repeat_local.GVN.diff new file mode 100644 index 0000000000000..1c399d42d6fc9 --- /dev/null +++ b/tests/mir-opt/gvn_storage_twice.repeat_local.GVN.diff @@ -0,0 +1,17 @@ +- // MIR for `repeat_local` before GVN ++ // MIR for `repeat_local` after GVN + + fn repeat_local(_1: usize, _2: usize, _3: i32) -> i32 { + let mut _0: i32; + let mut _4: [i32; 5]; + let mut _5: &i32; + + bb0: { + _4 = [copy _3; 5]; + _5 = &_4[_1]; +- _0 = copy (*_5); ++ _0 = copy _3; + return; + } + } + diff --git a/tests/mir-opt/gvn_storage_twice.repeat_local_dead.GVN.diff b/tests/mir-opt/gvn_storage_twice.repeat_local_dead.GVN.diff new file mode 100644 index 0000000000000..ee044aa5a0b18 --- /dev/null +++ b/tests/mir-opt/gvn_storage_twice.repeat_local_dead.GVN.diff @@ -0,0 +1,19 @@ +- // MIR for `repeat_local_dead` before GVN ++ // MIR for `repeat_local_dead` after GVN + + fn repeat_local_dead(_1: usize, _2: usize, _3: i32) -> i32 { + let mut _0: i32; + let mut _4: [i32; 5]; + let mut _5: &i32; + + bb0: { + _4 = [copy _3; 5]; + _5 = &_4[_1]; +- StorageDead(_3); +- _0 = copy (*_5); ++ nop; ++ _0 = copy _3; + return; + } + } + diff --git a/tests/mir-opt/gvn_storage_twice.repeat_local_dead_live.GVN.diff b/tests/mir-opt/gvn_storage_twice.repeat_local_dead_live.GVN.diff new file mode 100644 index 0000000000000..9448e91d33a3e --- /dev/null +++ b/tests/mir-opt/gvn_storage_twice.repeat_local_dead_live.GVN.diff @@ -0,0 +1,21 @@ +- // MIR for `repeat_local_dead_live` before GVN ++ // MIR for `repeat_local_dead_live` after GVN + + fn repeat_local_dead_live(_1: usize, _2: usize, _3: i32) -> i32 { + let mut _0: i32; + let mut _4: [i32; 5]; + let mut _5: &i32; + + bb0: { + _4 = [copy _3; 5]; + _5 = &_4[_1]; +- StorageDead(_3); +- StorageLive(_3); +- _0 = copy (*_5); ++ nop; ++ nop; ++ _0 = copy _3; + return; + } + } + diff --git a/tests/mir-opt/gvn_storage_twice.rs b/tests/mir-opt/gvn_storage_twice.rs new file mode 100644 index 0000000000000..d6aa0ed87befe --- /dev/null +++ b/tests/mir-opt/gvn_storage_twice.rs @@ -0,0 +1,65 @@ +// skip-filecheck +//@ test-mir-pass: GVN +//@ compile-flags: -Zlint-mir=false + +#![feature(custom_mir, core_intrinsics)] + +use std::intrinsics::mir::*; + +// EMIT_MIR gvn_storage_twice.repeat_local.GVN.diff +// EMIT_MIR gvn_storage_twice.repeat_local_dead.GVN.diff +// EMIT_MIR gvn_storage_twice.repeat_local_dead_live.GVN.diff + +// Check that we remove the storage statements if the local +// doesn't have valid storage when it is used. +// +// Based on `gvn_repeat.rs::repeat_local`, were GVN should replace +// `let RET = *_5;` with `let RET = _3;`. + +#[custom_mir(dialect = "runtime")] +pub fn repeat_local(_1: usize, _2: usize, _3: i32) -> i32 { + mir! { + { + let _4 = [_3; 5]; + let _5 = &_4[_1]; + RET = *_5; + Return() + } + } +} + +// Since _3 is dead when we access _5, GVN should remove the storage statements. + +#[custom_mir(dialect = "runtime")] +pub fn repeat_local_dead(_1: usize, _2: usize, _3: i32) -> i32 { + mir! { + { + let _4 = [_3; 5]; + let _5 = &_4[_1]; + StorageDead(_3); + RET = *_5; + Return() + } + } +} + +// Since _3 is uninit due to storage when we access _5, GVN should remove the storage statements. + +#[custom_mir(dialect = "runtime")] +pub fn repeat_local_dead_live(_1: usize, _2: usize, _3: i32) -> i32 { + mir! { + { + let _4 = [_3; 5]; + let _5 = &_4[_1]; + StorageDead(_3); + StorageLive(_3); + RET = *_5; + Return() + } + } +} + +#[inline(never)] +fn opaque(a: T) -> T { + a +} 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 f099d763c3d8d..a116086a0ce14 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 @@ -35,7 +35,6 @@ + StorageLive(_2); + _2 = sleep; + StorageLive(_4); -+ StorageLive(_6); + StorageLive(_3); + _3 = &_2; + StorageLive(_7); 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 c33e0810739f2..978de2884c081 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 @@ -35,7 +35,6 @@ - _1 = call_twice:: ! {sleep}>(sleep) -> unwind continue; + StorageLive(_2); + _2 = sleep; -+ StorageLive(_6); + StorageLive(_4); + StorageLive(_3); + _3 = &_2; diff --git a/tests/mir-opt/issue_141649_gvn_storage_remove.main.GVN.panic-abort.diff b/tests/mir-opt/issue_141649_gvn_storage_remove.main.GVN.panic-abort.diff new file mode 100644 index 0000000000000..79230f8e354a5 --- /dev/null +++ b/tests/mir-opt/issue_141649_gvn_storage_remove.main.GVN.panic-abort.diff @@ -0,0 +1,124 @@ +- // MIR for `main` before GVN ++ // MIR for `main` after GVN + + fn main() -> () { + let mut _0: (); + let _1: (); + let _2: main::S; + let _3: (); + let mut _4: main::S; + let _5: (); + let _6: main::S; + let _7: (); + let mut _8: main::S; + let _9: (); + let _10: main::C; + let _11: (); + let mut _12: main::C; + let _13: main::C; + let _14: (); + let mut _15: main::C; + scope 1 { + debug s1 => _2; + } + scope 2 { + debug s2 => _6; + } + scope 3 { + debug c1 => _10; + } + scope 4 { + debug c2 => _13; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); +- _2 = S(const 1_u32, const 2_u32); ++ _2 = const S(1_u32, 2_u32); + StorageLive(_3); + StorageLive(_4); +- _4 = move _2; +- _3 = std::mem::drop::(move _4) -> [return: bb1, unwind unreachable]; ++ _4 = const S(1_u32, 2_u32); ++ _3 = std::mem::drop::(const S(1_u32, 2_u32)) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + _1 = const (); + StorageDead(_2); + StorageDead(_1); + StorageLive(_5); + StorageLive(_6); +- _6 = S(const 3_u32, const 4_u32); ++ _6 = const S(3_u32, 4_u32); + StorageLive(_7); + StorageLive(_8); +- _8 = move _6; +- _7 = std::mem::drop::(move _8) -> [return: bb2, unwind unreachable]; ++ _8 = const S(3_u32, 4_u32); ++ _7 = std::mem::drop::(const S(3_u32, 4_u32)) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_8); + StorageDead(_7); + _5 = const (); + StorageDead(_6); + StorageDead(_5); + StorageLive(_9); + StorageLive(_10); +- _10 = C(const 1_u32, const 2_u32); ++ _10 = const C(1_u32, 2_u32); + StorageLive(_11); + StorageLive(_12); +- _12 = copy _10; +- _11 = std::mem::drop::(move _12) -> [return: bb3, unwind unreachable]; ++ _12 = const C(1_u32, 2_u32); ++ _11 = std::mem::drop::(const C(1_u32, 2_u32)) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_12); + StorageDead(_11); + _9 = const (); + StorageDead(_10); + StorageDead(_9); + StorageLive(_13); +- _13 = C(const 3_u32, const 4_u32); ++ _13 = const C(3_u32, 4_u32); + StorageLive(_14); + StorageLive(_15); +- _15 = copy _13; +- _14 = std::mem::drop::(move _15) -> [return: bb4, unwind unreachable]; ++ _15 = const C(3_u32, 4_u32); ++ _14 = std::mem::drop::(const C(3_u32, 4_u32)) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_15); + StorageDead(_14); + _0 = const (); + StorageDead(_13); + return; + } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 03 00 00 00 04 00 00 00 │ ........ ++ } ++ ++ ALLOC1 (size: 8, align: 4) { ++ 01 00 00 00 02 00 00 00 │ ........ ++ } ++ ++ ALLOC2 (size: 8, align: 4) { ++ 03 00 00 00 04 00 00 00 │ ........ ++ } ++ ++ ALLOC3 (size: 8, align: 4) { ++ 01 00 00 00 02 00 00 00 │ ........ + } + diff --git a/tests/mir-opt/issue_141649_gvn_storage_remove.main.GVN.panic-unwind.diff b/tests/mir-opt/issue_141649_gvn_storage_remove.main.GVN.panic-unwind.diff new file mode 100644 index 0000000000000..a9c68d742f504 --- /dev/null +++ b/tests/mir-opt/issue_141649_gvn_storage_remove.main.GVN.panic-unwind.diff @@ -0,0 +1,124 @@ +- // MIR for `main` before GVN ++ // MIR for `main` after GVN + + fn main() -> () { + let mut _0: (); + let _1: (); + let _2: main::S; + let _3: (); + let mut _4: main::S; + let _5: (); + let _6: main::S; + let _7: (); + let mut _8: main::S; + let _9: (); + let _10: main::C; + let _11: (); + let mut _12: main::C; + let _13: main::C; + let _14: (); + let mut _15: main::C; + scope 1 { + debug s1 => _2; + } + scope 2 { + debug s2 => _6; + } + scope 3 { + debug c1 => _10; + } + scope 4 { + debug c2 => _13; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); +- _2 = S(const 1_u32, const 2_u32); ++ _2 = const S(1_u32, 2_u32); + StorageLive(_3); + StorageLive(_4); +- _4 = move _2; +- _3 = std::mem::drop::(move _4) -> [return: bb1, unwind continue]; ++ _4 = const S(1_u32, 2_u32); ++ _3 = std::mem::drop::(const S(1_u32, 2_u32)) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + _1 = const (); + StorageDead(_2); + StorageDead(_1); + StorageLive(_5); + StorageLive(_6); +- _6 = S(const 3_u32, const 4_u32); ++ _6 = const S(3_u32, 4_u32); + StorageLive(_7); + StorageLive(_8); +- _8 = move _6; +- _7 = std::mem::drop::(move _8) -> [return: bb2, unwind continue]; ++ _8 = const S(3_u32, 4_u32); ++ _7 = std::mem::drop::(const S(3_u32, 4_u32)) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_8); + StorageDead(_7); + _5 = const (); + StorageDead(_6); + StorageDead(_5); + StorageLive(_9); + StorageLive(_10); +- _10 = C(const 1_u32, const 2_u32); ++ _10 = const C(1_u32, 2_u32); + StorageLive(_11); + StorageLive(_12); +- _12 = copy _10; +- _11 = std::mem::drop::(move _12) -> [return: bb3, unwind continue]; ++ _12 = const C(1_u32, 2_u32); ++ _11 = std::mem::drop::(const C(1_u32, 2_u32)) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_12); + StorageDead(_11); + _9 = const (); + StorageDead(_10); + StorageDead(_9); + StorageLive(_13); +- _13 = C(const 3_u32, const 4_u32); ++ _13 = const C(3_u32, 4_u32); + StorageLive(_14); + StorageLive(_15); +- _15 = copy _13; +- _14 = std::mem::drop::(move _15) -> [return: bb4, unwind continue]; ++ _15 = const C(3_u32, 4_u32); ++ _14 = std::mem::drop::(const C(3_u32, 4_u32)) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_15); + StorageDead(_14); + _0 = const (); + StorageDead(_13); + return; + } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 03 00 00 00 04 00 00 00 │ ........ ++ } ++ ++ ALLOC1 (size: 8, align: 4) { ++ 01 00 00 00 02 00 00 00 │ ........ ++ } ++ ++ ALLOC2 (size: 8, align: 4) { ++ 03 00 00 00 04 00 00 00 │ ........ ++ } ++ ++ ALLOC3 (size: 8, align: 4) { ++ 01 00 00 00 02 00 00 00 │ ........ + } + diff --git a/tests/mir-opt/issue_141649_gvn_storage_remove.rs b/tests/mir-opt/issue_141649_gvn_storage_remove.rs new file mode 100644 index 0000000000000..eb2b5337d0c41 --- /dev/null +++ b/tests/mir-opt/issue_141649_gvn_storage_remove.rs @@ -0,0 +1,27 @@ +// skip-filecheck +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +//@ test-mir-pass: GVN + +// EMIT_MIR issue_141649_gvn_storage_remove.main.GVN.diff +fn main() { + struct S(u32, u32); + { + let s1 = S(1, 2); + drop(s1); + } + { + let s2 = S(3, 4); + drop(s2); + } + + #[derive(Clone, Copy)] + struct C(u32, u32); + { + let c1 = C(1, 2); + drop(c1); + } + { + let c2 = C(3, 4); + drop(c2); + } +} diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff index c02bab3524bca..a01b10364a01d 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff @@ -23,10 +23,12 @@ } bb0: { + StorageLive(_3); StorageLive(_4); _4 = [copy _1, copy _1, copy _1]; _3 = &_4; _2 = copy _3 as &[T] (PointerCoercion(Unsize, Implicit)); + StorageDead(_3); nop; nop; goto -> bb2; diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff index 49be042588cb3..dd5d700863646 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff @@ -23,10 +23,12 @@ } bb0: { + StorageLive(_3); StorageLive(_4); _4 = [copy _1, copy _1, copy _1]; _3 = &_4; _2 = copy _3 as &[T] (PointerCoercion(Unsize, Implicit)); + StorageDead(_3); nop; nop; goto -> bb2; diff --git a/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff b/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff index d8eace98d556e..febcb0944c710 100644 --- a/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff +++ b/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff @@ -29,11 +29,13 @@ } bb3: { + StorageLive(_3); _3 = copy _2[3 of 4]; StorageLive(_4); _4 = copy _3 as [u8; 4] (Transmute); _0 = Option::<[u8; 4]>::Some(move _4); StorageDead(_4); + StorageDead(_3); goto -> bb5; } diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff index 79599f856115d..09811088d25f6 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff @@ -47,8 +47,6 @@ StorageLive(_4); _4 = copy _1; StorageLive(_10); - StorageLive(_11); - StorageLive(_12); _10 = discriminant(_4); switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb1]; } @@ -92,8 +90,6 @@ } bb5: { - StorageDead(_12); - StorageDead(_11); StorageDead(_10); StorageDead(_4); _5 = discriminant(_3); @@ -102,24 +98,26 @@ } bb6: { + StorageLive(_12); _12 = move ((_4 as Err).0: i32); StorageLive(_13); _13 = Result::::Err(copy _12); _3 = ControlFlow::, i32>::Break(move _13); StorageDead(_13); + StorageDead(_12); - goto -> bb5; + goto -> bb8; } bb7: { + StorageLive(_11); _11 = move ((_4 as Ok).0: i32); _3 = ControlFlow::, i32>::Continue(copy _11); + StorageDead(_11); goto -> bb5; + } + + bb8: { -+ StorageDead(_12); -+ StorageDead(_11); + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff index 79599f856115d..09811088d25f6 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff @@ -47,8 +47,6 @@ StorageLive(_4); _4 = copy _1; StorageLive(_10); - StorageLive(_11); - StorageLive(_12); _10 = discriminant(_4); switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb1]; } @@ -92,8 +90,6 @@ } bb5: { - StorageDead(_12); - StorageDead(_11); StorageDead(_10); StorageDead(_4); _5 = discriminant(_3); @@ -102,24 +98,26 @@ } bb6: { + StorageLive(_12); _12 = move ((_4 as Err).0: i32); StorageLive(_13); _13 = Result::::Err(copy _12); _3 = ControlFlow::, i32>::Break(move _13); StorageDead(_13); + StorageDead(_12); - goto -> bb5; + goto -> bb8; } bb7: { + StorageLive(_11); _11 = move ((_4 as Ok).0: i32); _3 = ControlFlow::, i32>::Continue(copy _11); + StorageDead(_11); goto -> bb5; + } + + bb8: { -+ StorageDead(_12); -+ StorageDead(_11); + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); diff --git a/tests/mir-opt/lower_array_len.array_bound.GVN.panic-abort.diff b/tests/mir-opt/lower_array_len.array_bound.GVN.panic-abort.diff index 98c5e868046b5..c0500ca3bb835 100644 --- a/tests/mir-opt/lower_array_len.array_bound.GVN.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_bound.GVN.panic-abort.diff @@ -14,8 +14,7 @@ let mut _9: bool; bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; StorageLive(_5); @@ -63,8 +62,7 @@ } bb5: { -- StorageDead(_3); -+ nop; + StorageDead(_3); return; } } diff --git a/tests/mir-opt/lower_array_len.array_bound.GVN.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_bound.GVN.panic-unwind.diff index 72c7313786996..9e6d01764ccd5 100644 --- a/tests/mir-opt/lower_array_len.array_bound.GVN.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_bound.GVN.panic-unwind.diff @@ -14,8 +14,7 @@ let mut _9: bool; bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; StorageLive(_5); @@ -63,8 +62,7 @@ } bb5: { -- StorageDead(_3); -+ nop; + StorageDead(_3); return; } } diff --git a/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-abort.diff b/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-abort.diff index 9ffaf44c02bd2..b2d0efff8f30a 100644 --- a/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-abort.diff @@ -16,8 +16,7 @@ let mut _11: bool; bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; StorageLive(_5); @@ -77,8 +76,7 @@ } bb6: { -- StorageDead(_3); -+ nop; + StorageDead(_3); return; } } diff --git a/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-unwind.diff index 08008e463357f..ab5209eca7592 100644 --- a/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-unwind.diff @@ -16,8 +16,7 @@ let mut _11: bool; bb0: { -- StorageLive(_3); -+ nop; + StorageLive(_3); StorageLive(_4); _4 = copy _1; StorageLive(_5); @@ -77,8 +76,7 @@ } bb6: { -- StorageDead(_3); -+ nop; + StorageDead(_3); return; } } diff --git a/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-abort.diff b/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-abort.diff index 180a7db029794..714a12804e692 100644 --- a/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-abort.diff @@ -18,8 +18,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); StorageLive(_4); _4 = &_1; @@ -41,8 +40,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageDead(_2); -+ nop; + StorageDead(_2); StorageDead(_7); return; } diff --git a/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-unwind.diff index 180a7db029794..714a12804e692 100644 --- a/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-unwind.diff @@ -18,8 +18,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); StorageLive(_4); _4 = &_1; @@ -41,8 +40,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageDead(_2); -+ nop; + StorageDead(_2); StorageDead(_7); return; } diff --git a/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-abort.diff b/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-abort.diff index 49964f8b49e26..b236b22f067d8 100644 --- a/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-abort.diff @@ -17,8 +17,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); StorageLive(_4); _4 = &mut _1; @@ -38,8 +37,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-unwind.diff index 49964f8b49e26..b236b22f067d8 100644 --- a/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-unwind.diff @@ -17,8 +17,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); StorageLive(_4); _4 = &mut _1; @@ -38,8 +37,7 @@ bb1: { StorageDead(_6); StorageDead(_5); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.PreCodegen.after.panic-abort.mir index 3c475cd403091..426c114dfc2ab 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.PreCodegen.after.panic-abort.mir @@ -19,7 +19,7 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { StorageLive(_5); StorageLive(_3); _3 = Lt(copy _1, copy _2); - switchInt(move _3) -> [0: bb1, otherwise: bb2]; + switchInt(move _3) -> [0: bb1, otherwise: bb3]; } bb1: { @@ -28,16 +28,22 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { _5 = Option::::Some(move _4); StorageDead(_4); StorageDead(_3); + StorageLive(_6); _6 = copy ((_5 as Some).0: u32); - _7 = do_something(move _6) -> [return: bb3, unwind unreachable]; + _7 = do_something(move _6) -> [return: bb2, unwind unreachable]; } bb2: { - StorageDead(_3); - goto -> bb3; + StorageDead(_6); + goto -> bb4; } bb3: { + StorageDead(_3); + goto -> bb4; + } + + bb4: { StorageDead(_5); return; } diff --git a/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.PreCodegen.after.panic-unwind.mir index 3ef09764b1c5b..f73c64a9b0929 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.PreCodegen.after.panic-unwind.mir @@ -19,7 +19,7 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { StorageLive(_5); StorageLive(_3); _3 = Lt(copy _1, copy _2); - switchInt(move _3) -> [0: bb1, otherwise: bb2]; + switchInt(move _3) -> [0: bb1, otherwise: bb3]; } bb1: { @@ -28,16 +28,22 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { _5 = Option::::Some(move _4); StorageDead(_4); StorageDead(_3); + StorageLive(_6); _6 = copy ((_5 as Some).0: u32); - _7 = do_something(move _6) -> [return: bb3, unwind continue]; + _7 = do_something(move _6) -> [return: bb2, unwind continue]; } bb2: { - StorageDead(_3); - goto -> bb3; + StorageDead(_6); + goto -> bb4; } bb3: { + StorageDead(_3); + goto -> bb4; + } + + bb4: { StorageDead(_5); return; } diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-abort.diff b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-abort.diff index 993857f225a81..f64efed6b3814 100644 --- a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-abort.diff @@ -15,9 +15,8 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); - _6 = deref_copy (*_1); -+ nop; + _6 = copy (*_1); _2 = copy (*_6); _3 = unknown() -> [return: bb1, unwind unreachable]; @@ -34,8 +33,7 @@ + _0 = Eq(move _4, copy _2); StorageDead(_5); StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-unwind.diff b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-unwind.diff index d81bfa9310bc1..077bca2805d63 100644 --- a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-unwind.diff @@ -15,9 +15,8 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); - _6 = deref_copy (*_1); -+ nop; + _6 = copy (*_1); _2 = copy (*_6); _3 = unknown() -> [return: bb1, unwind continue]; @@ -34,8 +33,7 @@ + _0 = Eq(move _4, copy _2); StorageDead(_5); StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-abort.mir index 23b1c3f3f43ad..b3789dfab0cdc 100644 --- a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-abort.mir @@ -13,6 +13,7 @@ fn src(_1: &&u8) -> bool { } bb0: { + StorageLive(_3); _2 = copy (*_1); _3 = copy (*_2); _4 = unknown() -> [return: bb1, unwind unreachable]; @@ -24,6 +25,7 @@ fn src(_1: &&u8) -> bool { _6 = copy (*_5); _0 = Eq(move _6, copy _3); StorageDead(_6); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-unwind.mir index 4c01e9464bf49..a3cf4806010a6 100644 --- a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-unwind.mir @@ -13,6 +13,7 @@ fn src(_1: &&u8) -> bool { } bb0: { + StorageLive(_3); _2 = copy (*_1); _3 = copy (*_2); _4 = unknown() -> [return: bb1, unwind continue]; @@ -24,6 +25,7 @@ fn src(_1: &&u8) -> bool { _6 = copy (*_5); _0 = Eq(move _6, copy _3); StorageDead(_6); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/derived_ord.demo_le.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/derived_ord.demo_le.PreCodegen.after.mir index 8746cb0899166..63bdf8b3aa0ef 100644 --- a/tests/mir-opt/pre-codegen/derived_ord.demo_le.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/derived_ord.demo_le.PreCodegen.after.mir @@ -37,11 +37,10 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool { } bb0: { - StorageLive(_12); StorageLive(_11); StorageLive(_5); - StorageLive(_6); StorageLive(_7); + StorageLive(_6); StorageLive(_3); _3 = copy ((*_1).0: char); StorageLive(_4); @@ -65,28 +64,29 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool { StorageDead(_8); _11 = Option::::Some(move _10); StorageDead(_10); - StorageDead(_7); StorageDead(_6); + StorageDead(_7); StorageDead(_5); goto -> bb3; } bb2: { _11 = copy _6; - StorageDead(_7); StorageDead(_6); + StorageDead(_7); StorageDead(_5); goto -> bb3; } bb3: { + StorageLive(_12); _12 = move ((_11 as Some).0: std::cmp::Ordering); StorageLive(_13); _13 = discriminant(_12); _0 = Le(move _13, const 0_i8); StorageDead(_13); - StorageDead(_11); StorageDead(_12); + StorageDead(_11); return; } } diff --git a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir index de25eebee77ff..bdabedef4e166 100644 --- a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir @@ -21,6 +21,7 @@ fn ::partial_cmp(_1: &MultiField, _2: &M } bb0: { + StorageLive(_6); StorageLive(_3); _3 = copy ((*_1).0: char); StorageLive(_4); @@ -53,6 +54,7 @@ fn ::partial_cmp(_1: &MultiField, _2: &M } bb3: { + StorageDead(_6); return; } } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index 027c71dfaae46..2a959142112c4 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -41,8 +41,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); - _2 = Option::::None; + _2 = const Option::::None; @@ -84,13 +83,13 @@ StorageDead(_8); StorageDead(_7); StorageLive(_12); - StorageLive(_16); _12 = discriminant(_6); switchInt(move _12) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { StorageLive(_15); + StorageLive(_16); _16 = &_13; _15 = copy _16 as &dyn std::fmt::Debug (PointerCoercion(Unsize, Implicit)); _14 = result::unwrap_failed(const "called `Result::unwrap()` on an `Err` value", move _15) -> unwind unreachable; @@ -98,7 +97,6 @@ bb6: { _5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>); - StorageDead(_16); StorageDead(_12); StorageDead(_6); _4 = copy _5 as *mut [u8] (Transmute); @@ -106,8 +104,7 @@ _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } + } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index 88bd4628c297a..0f752cac5596f 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -30,8 +30,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); - _2 = Option::::None; + _2 = const Option::::None; @@ -49,8 +48,7 @@ _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index ebf305a6f1b12..6019197881c36 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -41,8 +41,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); - _2 = Option::::None; + _2 = const Option::::None; @@ -84,13 +83,13 @@ StorageDead(_8); StorageDead(_7); StorageLive(_12); - StorageLive(_16); _12 = discriminant(_6); switchInt(move _12) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { StorageLive(_15); + StorageLive(_16); _16 = &_13; _15 = copy _16 as &dyn std::fmt::Debug (PointerCoercion(Unsize, Implicit)); _14 = result::unwrap_failed(const "called `Result::unwrap()` on an `Err` value", move _15) -> unwind unreachable; @@ -98,7 +97,6 @@ bb6: { _5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>); - StorageDead(_16); StorageDead(_12); StorageDead(_6); _4 = copy _5 as *mut [u8] (Transmute); @@ -106,8 +104,7 @@ _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } + } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index 0c52f1e058367..d0e4b9ad24e8d 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -30,8 +30,7 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); - _2 = Option::::None; + _2 = const Option::::None; @@ -49,8 +48,7 @@ _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } 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 75e8cb1d8618c..48948acfad973 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 @@ -64,11 +64,13 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () } bb6: { + StorageLive(_10); _10 = move ((_8 as Some).0: U); _11 = opaque::(move _10) -> [return: bb7, unwind: bb9]; } bb7: { + StorageDead(_10); StorageDead(_8); goto -> bb2; } diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir index 154cbd3791cbd..e2abc718d06c4 100644 --- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir @@ -89,18 +89,22 @@ fn int_range(_1: usize, _2: usize) -> () { bb3: { StorageDead(_7); StorageDead(_6); + StorageLive(_11); _11 = copy (_4.0: usize); StorageLive(_12); _12 = AddUnchecked(copy _11, const 1_usize); (_4.0: usize) = move _12; StorageDead(_12); _13 = Option::::Some(copy _11); + StorageDead(_11); StorageDead(_10); + StorageLive(_14); _14 = copy ((_13 as Some).0: usize); _15 = opaque::(move _14) -> [return: bb4, unwind continue]; } bb4: { + StorageDead(_14); StorageDead(_13); goto -> bb1; } 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 d22ea54004c91..f04111485125a 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -54,7 +54,6 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { bb2: { StorageLive(_13); _5 = &mut _4; - StorageLive(_8); StorageLive(_7); StorageLive(_6); _6 = &mut (_4.0: impl Iterator); @@ -63,18 +62,17 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { bb3: { StorageDead(_6); + StorageLive(_8); _8 = &mut (_4.1: impl Fn(T) -> U); StorageLive(_9); - StorageLive(_10); _9 = discriminant(_7); switchInt(move _9) -> [0: bb4, 1: bb6, otherwise: bb9]; } bb4: { - StorageDead(_10); StorageDead(_9); - StorageDead(_7); StorageDead(_8); + StorageDead(_7); StorageDead(_13); drop(_4) -> [return: bb5, unwind continue]; } @@ -85,6 +83,7 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { } bb6: { + StorageLive(_10); _10 = move ((_7 as Some).0: T); StorageLive(_12); StorageLive(_11); @@ -98,13 +97,15 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { StorageDead(_12); StorageDead(_10); StorageDead(_9); - StorageDead(_7); StorageDead(_8); + StorageDead(_7); + StorageLive(_14); _14 = move ((_13 as Some).0: U); _15 = opaque::(move _14) -> [return: bb8, unwind: bb10]; } bb8: { + StorageDead(_14); StorageDead(_13); 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..9e6043919b5da 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -30,6 +30,7 @@ fn vec_move(_1: Vec) -> () { bb2: { StorageLive(_5); + StorageLive(_4); _4 = &mut _3; _5 = as Iterator>::next(move _4) -> [return: bb3, unwind: bb9]; } @@ -40,6 +41,7 @@ fn vec_move(_1: Vec) -> () { } bb4: { + StorageDead(_4); StorageDead(_5); drop(_3) -> [return: bb5, unwind continue]; } @@ -51,11 +53,14 @@ fn vec_move(_1: Vec) -> () { } bb6: { + StorageLive(_7); _7 = move ((_5 as Some).0: impl Sized); _8 = opaque::(move _7) -> [return: bb7, unwind: bb9]; } bb7: { + StorageDead(_7); + StorageDead(_4); StorageDead(_5); goto -> bb2; } 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 dfe618612ab96..3d44fd6807f19 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 @@ -69,13 +69,16 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb4: { + StorageLive(_7); _7 = copy _4; StorageLive(_8); _8 = AddUnchecked(copy _7, const 1_u32); _4 = move _8; StorageDead(_8); _9 = Option::::Some(copy _7); + StorageDead(_7); StorageDead(_6); + StorageLive(_10); _10 = copy ((_9 as Some).0: u32); StorageLive(_11); _11 = &_3; @@ -87,6 +90,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb5: { StorageDead(_12); StorageDead(_11); + StorageDead(_10); 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 e0fcfcaffc59a..b955501316549 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 @@ -69,13 +69,16 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb4: { + StorageLive(_7); _7 = copy _4; StorageLive(_8); _8 = AddUnchecked(copy _7, const 1_u32); _4 = move _8; StorageDead(_8); _9 = Option::::Some(copy _7); + StorageDead(_7); StorageDead(_6); + StorageLive(_10); _10 = copy ((_9 as Some).0: u32); StorageLive(_11); _11 = &_3; @@ -87,6 +90,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb5: { StorageDead(_12); StorageDead(_11); + StorageDead(_10); 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 3f000dcafb035..63d9b1d1d0038 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 @@ -36,6 +36,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); + StorageLive(_6); _6 = &mut _5; _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind unreachable]; } @@ -46,6 +47,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb3: { + StorageDead(_6); StorageDead(_7); StorageDead(_5); drop(_3) -> [return: bb4, unwind unreachable]; @@ -56,6 +58,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb5: { + StorageLive(_9); _9 = copy ((_7 as Some).0: u32); StorageLive(_10); _10 = &_3; @@ -67,6 +70,8 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb6: { StorageDead(_11); StorageDead(_10); + StorageDead(_9); + StorageDead(_6); 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 2353717362711..33c9b492c5f1a 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 @@ -36,6 +36,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); + StorageLive(_6); _6 = &mut _5; _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind: bb8]; } @@ -46,6 +47,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb3: { + StorageDead(_6); StorageDead(_7); StorageDead(_5); drop(_3) -> [return: bb4, unwind continue]; @@ -56,6 +58,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb5: { + StorageLive(_9); _9 = copy ((_7 as Some).0: u32); StorageLive(_10); _10 = &_3; @@ -67,6 +70,8 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb6: { StorageDead(_11); StorageDead(_10); + StorageDead(_9); + StorageDead(_6); StorageDead(_7); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir index 1f82fc59ac2c1..55caea9d8f96d 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir @@ -43,12 +43,14 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { } bb2: { + StorageLive(_5); _5 = copy ((*_1).0: u32); StorageLive(_6); _6 = AddUnchecked(copy _5, const 1_u32); ((*_1).0: u32) = move _6; StorageDead(_6); _0 = Option::::Some(copy _5); + StorageDead(_5); goto -> bb3; } diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir index 1f82fc59ac2c1..55caea9d8f96d 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir @@ -43,12 +43,14 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { } bb2: { + StorageLive(_5); _5 = copy ((*_1).0: u32); StorageLive(_6); _6 = AddUnchecked(copy _5, const 1_u32); ((*_1).0: u32) = move _6; StorageDead(_6); _0 = Option::::Some(copy _5); + StorageDead(_5); goto -> bb3; } 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.mir index 7595ad88d9df4..876fa96dfb6fe 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.mir @@ -25,11 +25,13 @@ fn ezmap(_1: Option) -> Option { } bb2: { + StorageLive(_3); _3 = copy ((_1 as Some).0: i32); StorageLive(_4); _4 = Add(copy _3, const 1_i32); _0 = Option::::Some(move _4); StorageDead(_4); + StorageDead(_3); goto -> bb3; } diff --git a/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.PreCodegen.after.mir index b921b96966b29..fae561ae4b927 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.PreCodegen.after.mir @@ -29,13 +29,11 @@ fn map_via_question_mark(_1: Option) -> Option { StorageLive(_6); StorageLive(_4); StorageLive(_2); - StorageLive(_3); _2 = discriminant(_1); switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4]; } bb1: { - StorageDead(_3); StorageDead(_2); _0 = const Option::::None; StorageDead(_6); @@ -44,6 +42,7 @@ fn map_via_question_mark(_1: Option) -> Option { } bb2: { + StorageLive(_3); _3 = copy ((_1 as Some).0: i32); _4 = ControlFlow::, i32>::Continue(copy _3); StorageDead(_3); diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index cbdd194afd3ab..bb93139c31be5 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -68,10 +68,14 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 } bb0: { + StorageLive(_4); _3 = copy (*_2); _4 = &((*_3).0: usize); + StorageLive(_5); _5 = &((*_3).1: usize); + StorageLive(_6); _6 = &((*_3).2: usize); + StorageLive(_7); _7 = &((*_3).3: usize); StorageLive(_13); StorageLive(_8); @@ -180,6 +184,10 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 bb9: { StorageDead(_19); StorageDead(_13); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir index bc7a31d52199b..1d0ebfc3bcd70 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir @@ -18,10 +18,14 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, } bb0: { + StorageLive(_4); _3 = copy (*_2); _4 = copy ((*_3).0: usize); + StorageLive(_5); _5 = copy ((*_3).1: usize); + StorageLive(_6); _6 = copy ((*_3).2: usize); + StorageLive(_7); _7 = copy ((*_3).3: usize); StorageLive(_8); _8 = Le(copy _4, copy _6); @@ -63,6 +67,10 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, bb7: { StorageDead(_9); StorageDead(_8); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index 6fb1637a6e02f..7af8d5998dbb2 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -31,12 +31,13 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> } bb0: { + StorageLive(_3); + StorageLive(_4); _3 = move (_2.0: usize); _4 = move (_2.1: usize); StorageLive(_11); StorageLive(_5); _5 = &raw mut (*_1); - StorageLive(_8); StorageLive(_6); _6 = PtrMetadata(copy _1); _7 = as SliceIndex<[T]>>::get_unchecked_mut::precondition_check(copy _3, copy _4, move _6) -> [return: bb1, unwind unreachable]; @@ -44,10 +45,11 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> bb1: { StorageDead(_6); + StorageLive(_8); _8 = SubUnchecked(copy _4, copy _3); StorageLive(_9); - StorageLive(_10); _9 = copy _5 as *mut u32 (PtrToPtr); + StorageLive(_10); _10 = Offset(copy _9, copy _3); _11 = *mut [u32] from (copy _10, copy _8); StorageDead(_10); @@ -56,6 +58,8 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> StorageDead(_5); _0 = &mut (*_11); StorageDead(_11); + StorageDead(_3); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index 6fb1637a6e02f..7af8d5998dbb2 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -31,12 +31,13 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> } bb0: { + StorageLive(_3); + StorageLive(_4); _3 = move (_2.0: usize); _4 = move (_2.1: usize); StorageLive(_11); StorageLive(_5); _5 = &raw mut (*_1); - StorageLive(_8); StorageLive(_6); _6 = PtrMetadata(copy _1); _7 = as SliceIndex<[T]>>::get_unchecked_mut::precondition_check(copy _3, copy _4, move _6) -> [return: bb1, unwind unreachable]; @@ -44,10 +45,11 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> bb1: { StorageDead(_6); + StorageLive(_8); _8 = SubUnchecked(copy _4, copy _3); StorageLive(_9); - StorageLive(_10); _9 = copy _5 as *mut u32 (PtrToPtr); + StorageLive(_10); _10 = Offset(copy _9, copy _3); _11 = *mut [u32] from (copy _10, copy _8); StorageDead(_10); @@ -56,6 +58,8 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> StorageDead(_5); _0 = &mut (*_11); StorageDead(_11); + StorageDead(_3); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir index ad1ca5dff43a9..bd8df2979c98e 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir @@ -29,9 +29,10 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - } bb0: { + StorageLive(_3); + StorageLive(_4); _3 = move (_2.0: usize); _4 = move (_2.1: usize); - StorageLive(_7); StorageLive(_5); _5 = PtrMetadata(copy _1); _6 = as SliceIndex<[T]>>::get_unchecked::precondition_check(copy _3, copy _4, move _5) -> [return: bb1, unwind unreachable]; @@ -39,15 +40,18 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - bb1: { StorageDead(_5); + StorageLive(_7); _7 = SubUnchecked(copy _4, copy _3); StorageLive(_8); - StorageLive(_9); _8 = copy _1 as *const u32 (PtrToPtr); + StorageLive(_9); _9 = Offset(copy _8, copy _3); _0 = *const [u32] from (copy _9, copy _7); StorageDead(_9); StorageDead(_8); StorageDead(_7); + StorageDead(_3); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir index ad1ca5dff43a9..bd8df2979c98e 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir @@ -29,9 +29,10 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - } bb0: { + StorageLive(_3); + StorageLive(_4); _3 = move (_2.0: usize); _4 = move (_2.1: usize); - StorageLive(_7); StorageLive(_5); _5 = PtrMetadata(copy _1); _6 = as SliceIndex<[T]>>::get_unchecked::precondition_check(copy _3, copy _4, move _5) -> [return: bb1, unwind unreachable]; @@ -39,15 +40,18 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - bb1: { StorageDead(_5); + StorageLive(_7); _7 = SubUnchecked(copy _4, copy _3); StorageLive(_8); - StorageLive(_9); _8 = copy _1 as *const u32 (PtrToPtr); + StorageLive(_9); _9 = Offset(copy _8, copy _3); _0 = *const [u32] from (copy _9, copy _7); StorageDead(_9); StorageDead(_8); StorageDead(_7); + StorageDead(_3); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir index baa01e28a9410..6035f245c4977 100644 --- a/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir @@ -29,8 +29,10 @@ fn new(_1: Result) -> Result { } bb1: { + StorageLive(_3); _3 = move ((_1 as Ok).0: T); _4 = ControlFlow::::Continue(copy _3); + StorageDead(_3); _5 = move ((_4 as Continue).0: T); _0 = Result::::Ok(copy _5); StorageDead(_4); @@ -38,10 +40,14 @@ fn new(_1: Result) -> Result { } bb2: { + StorageLive(_6); _6 = move ((_1 as Err).0: E); _4 = ControlFlow::::Break(copy _6); + StorageDead(_6); + StorageLive(_7); _7 = move ((_4 as Break).0: E); _0 = Result::::Err(copy _7); + StorageDead(_7); StorageDead(_4); goto -> bb3; } diff --git a/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir index 889e80d26e1cc..aec51bfd8d745 100644 --- a/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir @@ -19,14 +19,18 @@ fn old(_1: Result) -> Result { } bb1: { + StorageLive(_3); _3 = copy ((_1 as Ok).0: T); + StorageDead(_3); _0 = copy _1; goto -> bb3; } bb2: { + StorageLive(_4); _4 = copy ((_1 as Err).0: E); _0 = copy _1; + StorageDead(_4); goto -> bb3; } diff --git a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff index ce9d812701a8f..a388d0ae2d195 100644 --- a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff +++ b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff @@ -39,8 +39,6 @@ bb0: { StorageLive(_2); StorageLive(_6); - StorageLive(_7); - StorageLive(_8); _6 = discriminant(_1); switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb1]; } @@ -57,16 +55,18 @@ } bb3: { + StorageLive(_4); _4 = copy ((_2 as Break).0: std::result::Result); + StorageLive(_10); _10 = copy ((_4 as Err).0: i32); _0 = Result::::Err(copy _10); + StorageDead(_10); + StorageDead(_4); StorageDead(_2); return; } bb4: { - StorageDead(_8); - StorageDead(_7); StorageDead(_6); _3 = discriminant(_2); - switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; @@ -74,24 +74,26 @@ } bb5: { + StorageLive(_8); _8 = copy ((_1 as Err).0: i32); StorageLive(_9); _9 = Result::::Err(copy _8); _2 = ControlFlow::, i32>::Break(move _9); StorageDead(_9); + StorageDead(_8); - goto -> bb4; + goto -> bb7; } bb6: { + StorageLive(_7); _7 = copy ((_1 as Ok).0: i32); _2 = ControlFlow::, i32>::Continue(copy _7); + StorageDead(_7); goto -> bb4; + } + + bb7: { -+ StorageDead(_8); -+ StorageDead(_7); + StorageDead(_6); + _3 = discriminant(_2); + goto -> bb3; diff --git a/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff b/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff index c88c63e0c1334..97be532254528 100644 --- a/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff +++ b/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff @@ -35,15 +35,19 @@ } bb2: { + StorageLive(_5); _5 = copy ((_1 as Err).0: usize); _2 = ControlFlow::::Break(copy _5); + StorageDead(_5); - goto -> bb4; + goto -> bb8; } bb3: { + StorageLive(_4); _4 = copy ((_1 as Ok).0: i32); _2 = ControlFlow::::Continue(copy _4); + StorageDead(_4); goto -> bb4; } @@ -62,8 +66,10 @@ } bb6: { + StorageLive(_7); _7 = copy ((_2 as Continue).0: i32); _0 = Option::::Some(copy _7); + StorageDead(_7); goto -> bb7; } diff --git a/tests/mir-opt/simplify_aggregate_to_copy_miscompile.foo.GVN.diff b/tests/mir-opt/simplify_aggregate_to_copy_miscompile.foo.GVN.diff index 54c11679f0c69..9d1c9079a2465 100644 --- a/tests/mir-opt/simplify_aggregate_to_copy_miscompile.foo.GVN.diff +++ b/tests/mir-opt/simplify_aggregate_to_copy_miscompile.foo.GVN.diff @@ -30,8 +30,7 @@ } bb2: { -- StorageLive(_5); -+ nop; + StorageLive(_5); _5 = copy (((*_2) as Some).0: i32); StorageLive(_7); - _7 = Option::::None; @@ -44,8 +43,7 @@ - _0 = Option::::Some(move _8); + _0 = Option::::Some(copy _5); StorageDead(_8); -- StorageDead(_5); -+ nop; + StorageDead(_5); StorageDead(_2); return; } diff --git a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff index ff1bc58524bc2..c590c1aad4477 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff +++ b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff @@ -35,7 +35,9 @@ } bb2: { + StorageLive(_6); _6 = copy (((_1.0: std::option::Option) as Some).0: u8); + StorageDead(_6); goto -> bb3; } diff --git a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff index 2c289c664754a..9dd0195c86c97 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff +++ b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff @@ -35,7 +35,9 @@ } bb2: { + StorageLive(_6); _6 = copy (((_1.0: std::option::Option) as Some).0: u8); + StorageDead(_6); goto -> bb3; } diff --git a/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff index 9e798cbcac0c1..30c3b0bcfa1d7 100644 --- a/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff @@ -11,14 +11,12 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = const false; - _1 = copy _2; -- StorageDead(_2); -- switchInt(copy _1) -> [0: bb2, otherwise: bb1]; + _1 = const false; -+ nop; + StorageDead(_2); +- switchInt(copy _1) -> [0: bb2, otherwise: bb1]; + switchInt(const false) -> [0: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff index e243ff45ab0b2..7923d3210d83f 100644 --- a/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff @@ -11,14 +11,12 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = const false; - _1 = copy _2; -- StorageDead(_2); -- switchInt(copy _1) -> [0: bb2, otherwise: bb1]; + _1 = const false; -+ nop; + StorageDead(_2); +- switchInt(copy _1) -> [0: bb2, otherwise: bb1]; + switchInt(const false) -> [0: bb2, otherwise: bb1]; }