diff --git a/compiler/rustc_mir_transform/src/copy_prop.rs b/compiler/rustc_mir_transform/src/copy_prop.rs index 89ee96317ac93..3faf29063324b 100644 --- a/compiler/rustc_mir_transform/src/copy_prop.rs +++ b/compiler/rustc_mir_transform/src/copy_prop.rs @@ -3,9 +3,10 @@ use rustc_index::bit_set::DenseBitSet; use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; +use rustc_mir_dataflow::{Analysis, ResultsCursor}; use tracing::{debug, instrument}; -use crate::ssa::SsaLocals; +use crate::ssa::{MaybeUninitializedLocals, SsaLocals}; /// Unify locals that copy each other. /// @@ -16,7 +17,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 `copy _a`. +/// 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,15 +31,19 @@ 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()); debug!(copy_classes = ?ssa.copy_classes()); let mut any_replacement = false; // Locals that participate in copy propagation either as a source or a destination. let mut unified = DenseBitSet::new_empty(body.local_decls.len()); + let mut storage_to_remove = DenseBitSet::new_empty(body.local_decls.len()); + for (local, &head) in ssa.copy_classes().iter_enumerated() { if local != head { any_replacement = true; + storage_to_remove.insert(head); unified.insert(head); unified.insert(local); } @@ -48,7 +53,46 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp { return; } - Replacer { tcx, copy_classes: ssa.copy_classes(), unified }.visit_body_preserves_cfg(body); + // When emitting storage statements, we want to retain the head locals' storage statements, + // as this enables better optimizations. For each local use location, we mark the head for storage removal + // only if the head might be uninitialized at that point, or if the local is borrowed + // (since we cannot easily determine when it's used). + let storage_to_remove = if tcx.sess.emit_lifetime_markers() { + storage_to_remove.clear(); + + // If the local is borrowed, we cannot easily determine if it is used, so we have to remove the storage statements. + let borrowed_locals = ssa.borrowed_locals(); + + for (local, &head) in ssa.copy_classes().iter_enumerated() { + if local != head && borrowed_locals.contains(local) { + storage_to_remove.insert(head); + } + } + + let maybe_uninit = MaybeUninitializedLocals + .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(), + storage_to_remove, + }; + + for (bb, data) in traversal::reachable(body) { + storage_checker.visit_basic_block_data(bb, data); + } + + storage_checker.storage_to_remove + } else { + // Remove the storage statements of all the head locals. + storage_to_remove + }; + + debug!(?storage_to_remove); + + Replacer { tcx, copy_classes: ssa.copy_classes(), unified, storage_to_remove } + .visit_body_preserves_cfg(body); crate::simplify::remove_unused_definitions(body); } @@ -62,6 +106,7 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp { struct Replacer<'a, 'tcx> { tcx: TyCtxt<'tcx>, unified: DenseBitSet, + storage_to_remove: DenseBitSet, copy_classes: &'a IndexSlice, } @@ -72,7 +117,13 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> { #[tracing::instrument(level = "trace", skip(self))] fn visit_local(&mut self, local: &mut Local, ctxt: PlaceContext, _: Location) { - *local = self.copy_classes[*local]; + let new_local = self.copy_classes[*local]; + match ctxt { + // Do not modify the local in storage statements. + PlaceContext::NonUse(NonUseContext::StorageLive | NonUseContext::StorageDead) => {} + // We access the value. + _ => *local = new_local, + } } #[tracing::instrument(level = "trace", skip(self))] @@ -92,7 +143,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> { fn visit_statement(&mut self, stmt: &mut Statement<'tcx>, loc: Location) { // When removing storage statements, we need to remove both (#107511). if let StatementKind::StorageLive(l) | StatementKind::StorageDead(l) = stmt.kind - && self.unified.contains(l) + && self.storage_to_remove.contains(l) { stmt.make_nop(true); } @@ -108,3 +159,39 @@ 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, + storage_to_remove: DenseBitSet, +} + +impl<'a, 'tcx> Visitor<'tcx> for StorageChecker<'a, 'tcx> { + fn visit_local(&mut self, local: Local, context: PlaceContext, loc: Location) { + if !context.is_use() { + return; + } + + let head = self.copy_classes[local]; + + // If the local is the head, or if we already marked it for deletion, we do not need to check it. + if head == local || self.storage_to_remove.contains(head) { + return; + } + + self.maybe_uninit.seek_before_primary_effect(loc); + + if self.maybe_uninit.get().contains(head) { + debug!( + ?loc, + ?context, + ?local, + ?head, + "local's head is maybe uninit at this location, marking head for storage statement removal" + ); + self.storage_to_remove.insert(head); + } + } +} diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 820998eed1005..d80949fa48b5f 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -108,11 +108,12 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::layout::HasTypingEnv; use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_mir_dataflow::{Analysis, ResultsCursor}; use rustc_span::DUMMY_SP; use smallvec::SmallVec; use tracing::{debug, instrument, trace}; -use crate::ssa::SsaLocals; +use crate::ssa::{MaybeUninitializedLocals, SsaLocals}; pub(super) struct GVN; @@ -151,10 +152,34 @@ 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); + // When emitting storage statements, we want to retain the reused locals' storage statements, + // as this enables better optimizations. For each local use location, we mark it for storage removal + // only if it might be uninitialized at that point. + let storage_to_remove = if tcx.sess.emit_lifetime_markers() { + let maybe_uninit = MaybeUninitializedLocals + .iterate_to_fixpoint(tcx, body, Some("mir_opt::gvn")) + .into_results_cursor(body); + + let mut storage_checker = StorageChecker { + reused_locals: &state.reused_locals, + storage_to_remove: DenseBitSet::new_empty(body.local_decls.len()), + maybe_uninit, + }; + + for (bb, data) in traversal::reachable(body) { + storage_checker.visit_basic_block_data(bb, data); + } + + storage_checker.storage_to_remove + } else { + // Remove the storage statements of all the 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 { @@ -1944,6 +1969,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> { @@ -1964,7 +1990,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(true) } @@ -1972,3 +1998,42 @@ impl<'tcx> MutVisitor<'tcx> for StorageRemover<'tcx> { } } } + +struct StorageChecker<'a, 'tcx> { + reused_locals: &'a 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(_) => {} + } + + // We only need to check reused locals which we haven't already removed storage for. + if !self.reused_locals.contains(local) || self.storage_to_remove.contains(local) { + return; + } + + self.maybe_uninit.seek_before_primary_effect(location); + + if self.maybe_uninit.get().contains(local) { + debug!( + ?location, + ?local, + "local is reused and is maybe uninit at this location, marking it for storage statement removal" + ); + self.storage_to_remove.insert(local); + } + } +} diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs index a56f04cf48422..b1c53778db6ae 100644 --- a/compiler/rustc_mir_transform/src/ssa.rs +++ b/compiler/rustc_mir_transform/src/ssa.rs @@ -14,6 +14,7 @@ use rustc_middle::middle::resolve_bound_vars::Set1; use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::{self, TyCtxt}; +use rustc_mir_dataflow::Analysis; use tracing::{debug, instrument, trace}; pub(super) struct SsaLocals { @@ -391,3 +392,64 @@ impl StorageLiveLocals { matches!(self.storage_live[local], Set1::One(_)) } } + +/// 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(crate) struct MaybeUninitializedLocals; + +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( + &self, + state: &mut Self::Domain, + statement: &Statement<'tcx>, + _location: Location, + ) { + match statement.kind { + // An assignment makes a local initialized. + StatementKind::Assign(box (place, _)) => { + if let Some(local) = place.as_local() { + state.remove(local); + } + } + // Storage{Live,Dead} makes a local uninitialized. + StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => { + state.insert(local); + } + _ => {} + } + } + + fn apply_call_return_effect( + &self, + state: &mut Self::Domain, + _block: 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); + } + }); + } +} diff --git a/tests/assembly-llvm/issue-141649.rs b/tests/assembly-llvm/issue-141649.rs new file mode 100644 index 0000000000000..62bee1ebdceca --- /dev/null +++ b/tests/assembly-llvm/issue-141649.rs @@ -0,0 +1,70 @@ +//@ revisions: x86_64 aarch64 +//@ assembly-output: emit-asm +//@ compile-flags: -Copt-level=3 + +//@[aarch64] only-aarch64 +//@[x86_64] only-x86_64 + +#![crate_type = "lib"] + +// Non-overlapping scopes should reuse of the same stack allocation. + +pub struct WithOffset { + pub data: T, + pub offset: usize, +} + +#[inline(never)] +pub fn peak_w(w: &WithOffset<&[u8; 16]>) { + std::hint::black_box(w); +} + +#[inline(never)] +pub fn use_w(w: WithOffset<&[u8; 16]>) { + std::hint::black_box(w); +} + +// CHECK-LABEL: scoped_two_small_structs +#[no_mangle] +pub fn scoped_two_small_structs(buf: [u8; 16]) { + { + let w = WithOffset { data: &buf, offset: 0 }; + + peak_w(&w); + use_w(w); + } + { + let w2 = WithOffset { data: &buf, offset: 1 }; + + peak_w(&w2); + use_w(w2); + } + // x86_64: subq $24, %rsp + // aarch64: sub sp, sp, #48 +} + +// CHECK-LABEL: scoped_three_small_structs +#[no_mangle] +pub fn scoped_three_small_structs(buf: [u8; 16]) { + { + let w = WithOffset { data: &buf, offset: 0 }; + + peak_w(&w); + use_w(w); + } + { + let w2 = WithOffset { data: &buf, offset: 1 }; + + peak_w(&w2); + use_w(w2); + } + { + let w3 = WithOffset { data: &buf, offset: 1 }; + + peak_w(&w3); + use_w(w3); + } + // Should be the same stack usage as the two struct version. + // x86_64: subq $24, %rsp + // aarch64: sub sp, sp, #48 +} diff --git a/tests/codegen-llvm/issues/issue-141649.rs b/tests/codegen-llvm/issues/issue-141649.rs new file mode 100644 index 0000000000000..2fd7a9fd9faf6 --- /dev/null +++ b/tests/codegen-llvm/issues/issue-141649.rs @@ -0,0 +1,45 @@ +//@ compile-flags: -Copt-level=3 + +#![crate_type = "lib"] + +// Non-overlapping scopes should produce correct llvm.lifetimes, +// which allow reuse of the same stack allocation. + +pub struct WithOffset { + pub data: T, + pub offset: usize, +} + +#[inline(never)] +pub fn peak_w(w: &WithOffset<&[u8; 16]>) { + std::hint::black_box(w); +} + +#[inline(never)] +pub fn use_w(w: WithOffset<&[u8; 16]>) { + std::hint::black_box(w); +} + +// CHECK-LABEL: define void @scoped_small_structs( +// CHECK-NEXT: start: +// CHECK-NEXT: [[B:%.*]] = alloca +// CHECK-NEXT: [[A:%.*]] = alloca +// CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr nonnull [[A]]) +// CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr nonnull [[A]]) +// CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr nonnull [[B]]) +// CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr nonnull [[B]]) +#[no_mangle] +pub fn scoped_small_structs(buf: [u8; 16]) { + { + let w = WithOffset { data: &buf, offset: 0 }; + + peak_w(&w); + use_w(w); + } + { + let w2 = WithOffset { data: &buf, offset: 1 }; + + peak_w(&w2); + use_w(w2); + } +} diff --git a/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff b/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff index 9baf8439e59f5..03e077b1528c7 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 95eaf18b4703b..110536e20fddd 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 @@ -19,8 +19,7 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _4 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind unreachable]; } @@ -43,9 +42,8 @@ _10 = copy ((_3.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); _2 = copy (*_10); - _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 6d8d3a0dcfe29..16d33824344d6 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 @@ -19,8 +19,7 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); _4 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind continue]; } @@ -43,9 +42,8 @@ _10 = copy ((_3.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); _2 = copy (*_10); - _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/const_prop/union.main.GVN.diff b/tests/mir-opt/const_prop/union.main.GVN.diff index 4212a44d0a0de..4c3e0bb68fd43 100644 --- a/tests/mir-opt/const_prop/union.main.GVN.diff +++ b/tests/mir-opt/const_prop/union.main.GVN.diff @@ -17,13 +17,11 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); _2 = const 1_u32; - _1 = Un { us: move _2 }; -- StorageDead(_2); + _1 = const Un {{ us: 1_u32 }}; -+ nop; + StorageDead(_2); StorageLive(_3); StorageLive(_4); - _4 = copy (_1.0: u32); diff --git a/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-abort.diff index 8c5e6a9e827a0..3d76cd65e0385 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-abort.diff @@ -43,12 +43,12 @@ } bb1: { -- StorageLive(_6); + StorageLive(_6); StorageLive(_7); _7 = copy (*_2); _6 = Not(move _7); StorageDead(_7); -- StorageLive(_8); + StorageLive(_8); StorageLive(_9); _9 = copy (*_2); _8 = Not(move _9); @@ -80,8 +80,8 @@ - StorageDead(_14); _0 = const (); StorageDead(_13); -- StorageDead(_8); -- StorageDead(_6); + StorageDead(_8); + StorageDead(_6); - StorageDead(_4); StorageDead(_2); StorageDead(_1); @@ -93,8 +93,8 @@ - StorageDead(_14); - _5 = const (); StorageDead(_13); -- StorageDead(_8); -- StorageDead(_6); + StorageDead(_8); + StorageDead(_6); goto -> bb1; } } diff --git a/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-unwind.diff index 8c5e6a9e827a0..3d76cd65e0385 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-unwind.diff @@ -43,12 +43,12 @@ } bb1: { -- StorageLive(_6); + StorageLive(_6); StorageLive(_7); _7 = copy (*_2); _6 = Not(move _7); StorageDead(_7); -- StorageLive(_8); + StorageLive(_8); StorageLive(_9); _9 = copy (*_2); _8 = Not(move _9); @@ -80,8 +80,8 @@ - StorageDead(_14); _0 = const (); StorageDead(_13); -- StorageDead(_8); -- StorageDead(_6); + StorageDead(_8); + StorageDead(_6); - StorageDead(_4); StorageDead(_2); StorageDead(_1); @@ -93,8 +93,8 @@ - StorageDead(_14); - _5 = const (); StorageDead(_13); -- StorageDead(_8); -- StorageDead(_6); + StorageDead(_8); + StorageDead(_6); goto -> bb1; } } diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_preserve_head.f.CopyProp.diff b/tests/mir-opt/copy-prop/copy_prop_storage_preserve_head.f.CopyProp.diff new file mode 100644 index 0000000000000..3eebfdd6303a1 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_preserve_head.f.CopyProp.diff @@ -0,0 +1,20 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: &mut usize) -> () { + let mut _0: (); + let mut _2: usize; + let mut _3: usize; + + bb0: { + StorageLive(_2); + _2 = const 0_usize; +- _3 = copy _2; +- (*_1) = copy _3; ++ (*_1) = copy _2; + StorageDead(_2); + (*_1) = copy _2; + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_preserve_head.g.CopyProp.diff b/tests/mir-opt/copy-prop/copy_prop_storage_preserve_head.g.CopyProp.diff new file mode 100644 index 0000000000000..d90cc6e8b41e5 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_preserve_head.g.CopyProp.diff @@ -0,0 +1,23 @@ +- // MIR for `g` before CopyProp ++ // MIR for `g` after CopyProp + + fn g() -> usize { + let mut _0: usize; + let mut _1: usize; + let mut _2: usize; + let mut _3: usize; + + bb0: { +- StorageLive(_2); + StorageLive(_1); + _1 = const 0_usize; +- _2 = copy _1; +- _3 = copy _2; +- _0 = Add(copy _3, copy _3); ++ _0 = Add(copy _1, copy _1); + StorageDead(_1); +- StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_preserve_head.rs b/tests/mir-opt/copy-prop/copy_prop_storage_preserve_head.rs new file mode 100644 index 0000000000000..ec506c70327e4 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_preserve_head.rs @@ -0,0 +1,57 @@ +//@ test-mir-pass: CopyProp +//@ compile-flags: -Zlint-mir=false + +#![feature(custom_mir, core_intrinsics)] +use std::intrinsics::mir::*; + +// EMIT_MIR copy_prop_storage_preserve_head.f.CopyProp.diff +// EMIT_MIR copy_prop_storage_preserve_head.g.CopyProp.diff + +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +pub fn f(_1: &mut usize) { + // CHECK-LABEL: fn f( + mir! { + let _2: usize; + let _3: usize; + // CHECK: bb0: { + { + // CHECK: StorageLive(_2); + // CHECK: (*_1) = copy _2; + // CHECK: StorageDead(_2); + StorageLive(_2); + _2 = 0; + _3 = _2; + (*_1) = _3; + StorageDead(_2); + (*_1) = _2; + Return() + } + } +} + +#[custom_mir(dialect = "runtime")] +pub fn g() -> usize { + // CHECK-LABEL: fn g( + mir! { + let _1: usize; + let _2: usize; + let _3: usize; + // CHECK: bb0: { + { + // CHECK: StorageLive(_1); + // CHECK: _0 = Add(copy _1, copy _1); + // CHECK: StorageDead(_1); + StorageLive(_2); + StorageLive(_1); + _1 = 0; + _2 = _1; + _3 = _2; + RET = _3 + _3; + // Even though the storage statements are in reverse order, + // we should be able to keep the ones for _1. + StorageDead(_1); + StorageDead(_2); + Return() + } + } +} diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_removed_when_local_borrowed.f.CopyProp.diff b/tests/mir-opt/copy-prop/copy_prop_storage_removed_when_local_borrowed.f.CopyProp.diff new file mode 100644 index 0000000000000..109fa10cfde97 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_removed_when_local_borrowed.f.CopyProp.diff @@ -0,0 +1,20 @@ +- // 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); + _0 = copy (*_4); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_removed_when_local_borrowed.rs b/tests/mir-opt/copy-prop/copy_prop_storage_removed_when_local_borrowed.rs new file mode 100644 index 0000000000000..f7595e60078f9 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_removed_when_local_borrowed.rs @@ -0,0 +1,36 @@ +//! Check that we remove the storage statements if one of the locals is borrowed, +//! and the head isn't borrowed. +//@ test-mir-pass: CopyProp + +#![feature(custom_mir, core_intrinsics, freeze)] + +use std::intrinsics::mir::*; +use std::marker::Freeze; + +// EMIT_MIR copy_prop_storage_removed_when_local_borrowed.f.CopyProp.diff + +#[custom_mir(dialect = "runtime")] +pub fn f(_1: (T, T)) -> T { + // CHECK-LABEL: fn f( + mir! { + let _2: T; + let _3: T; + let _4: &T; + // CHECK: bb0: { + { + // FIXME: Currently, copy propagation will not unify borrowed locals. + // If it does, the storage statements for `_2` should be remove + // so these checks will need to be updated. + // CHECK: StorageLive(_2); + // CHECK: _4 = &_3; + // CHECK: StorageDead(_2); + 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..bf5766314a5c1 --- /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::(copy _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..5d10285ce440d --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_twice.rs @@ -0,0 +1,70 @@ +//@ 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 +#[custom_mir(dialect = "runtime")] +pub fn dead_twice(_1: T) -> T { + // CHECK-LABEL: fn dead_twice( + mir! { + let _2: T; + let _3: T; + { + // CHECK-NOT: StorageLive(_2); + StorageLive(_2); + Call(_2 = opaque(Move(_1)), ReturnTo(bb1), UnwindUnreachable()) + } + bb1 = { + // CHECK-NOT: StorageDead(_2); + // CHECK-NOT: StorageLive(_2); + // CHECK: _0 = opaque::(copy _2) -> [return: bb2, unwind unreachable]; + let _3 = Move(_2); + StorageDead(_2); + StorageLive(_2); + Call(RET = opaque(Move(_3)), ReturnTo(bb2), UnwindUnreachable()) + } + bb2 = { + // CHECK-NOT: StorageDead(_2); + StorageDead(_2); + Return() + } + } +} + +// EMIT_MIR copy_prop_storage_twice.live_twice.CopyProp.diff +#[custom_mir(dialect = "runtime")] +pub fn live_twice(_1: T) -> T { + // CHECK-LABEL: fn live_twice( + mir! { + let _2: T; + let _3: T; + { + // CHECK-NOT: StorageLive(_2); + StorageLive(_2); + Call(_2 = opaque(Move(_1)), ReturnTo(bb1), UnwindUnreachable()) + } + bb1 = { + // CHECK-NOT: StorageLive(_2); + // CHECK: _0 = opaque::(copy _2) -> [return: bb2, unwind unreachable]; + let _3 = Move(_2); + StorageLive(_2); + Call(RET = opaque(_3), ReturnTo(bb2), UnwindUnreachable()) + } + bb2 = { + // CHECK-NOT: StorageDead(_2); + StorageDead(_2); + Return() + } + } +} + +#[inline(never)] +fn opaque(a: T) -> T { + a +} diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_unreachable.f.CopyProp.diff b/tests/mir-opt/copy-prop/copy_prop_storage_unreachable.f.CopyProp.diff new file mode 100644 index 0000000000000..93c186846908e --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_unreachable.f.CopyProp.diff @@ -0,0 +1,27 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: &mut usize) -> () { + let mut _0: (); + let mut _2: usize; + let mut _3: usize; + + bb0: { + StorageLive(_2); + _2 = const 42_usize; +- _3 = copy _2; +- (*_1) = copy _3; ++ (*_1) = copy _2; + StorageDead(_2); + return; + } + + bb1: { + StorageLive(_2); +- (*_1) = copy _3; ++ (*_1) = copy _2; + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/copy-prop/copy_prop_storage_unreachable.rs b/tests/mir-opt/copy-prop/copy_prop_storage_unreachable.rs new file mode 100644 index 0000000000000..2d28913ff8476 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_prop_storage_unreachable.rs @@ -0,0 +1,37 @@ +//! Check that we do not remove the storage statements if the head +//! is uninitialized in an unreachable block. +//@ test-mir-pass: CopyProp + +#![feature(custom_mir, core_intrinsics)] + +use std::intrinsics::mir::*; + +// EMIT_MIR copy_prop_storage_unreachable.f.CopyProp.diff + +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +pub fn f(_1: &mut usize) { + // CHECK-LABEL: fn f( + mir! { + let _2: usize; + let _3: usize; + { + // CHECK: StorageLive(_2); + // CHECK: (*_1) = copy _2; + // CHECK: StorageDead(_2); + StorageLive(_2); + _2 = 42; + _3 = _2; + (*_1) = _3; + StorageDead(_2); + Return() + } + bb1 = { + // Ensure that _2 is considered uninitialized by `MaybeUninitializedLocals`. + StorageLive(_2); + // Use of _3 (in an unreachable block) when definition of _2 is unavailable. + (*_1) = _3; + StorageDead(_2); + Return() + } + } +} 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/cycle.rs b/tests/mir-opt/copy-prop/cycle.rs index 9f8312cc8fcd4..9bd175f9c42d0 100644 --- a/tests/mir-opt/copy-prop/cycle.rs +++ b/tests/mir-opt/copy-prop/cycle.rs @@ -11,7 +11,7 @@ fn main() { // CHECK: debug x => [[x:_.*]]; // CHECK: debug y => [[y:_.*]]; // CHECK: debug z => [[y]]; - // CHECK-NOT: StorageLive([[y]]); + // CHECK: StorageLive([[y]]); // CHECK: [[y]] = copy [[x]]; // CHECK-NOT: StorageLive(_3); // CHECK-NOT: _3 = copy [[y]]; @@ -19,6 +19,7 @@ fn main() { // CHECK-NOT: _4 = copy _3; // CHECK-NOT: _1 = move _4; // CHECK: [[x]] = copy [[y]]; + // CHECK: StorageDead([[y]]); let mut x = val(); let y = x; let z = y; 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/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_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs index d345d2db2b7d8..b3dcc775b63d6 100644 --- a/tests/mir-opt/copy-prop/issue_107511.rs +++ b/tests/mir-opt/copy-prop/issue_107511.rs @@ -5,8 +5,8 @@ fn main() { // CHECK-LABEL: fn main( // CHECK: debug i => [[i:_.*]]; - // CHECK-NOT: StorageLive([[i]]); - // CHECK-NOT: StorageDead([[i]]); + // CHECK: StorageLive([[i]]); + // CHECK: StorageDead([[i]]); let mut sum = 0; let a = [0, 10, 20, 30]; diff --git a/tests/mir-opt/copy-prop/issue_141649.f_head_borrowed.CopyProp.diff b/tests/mir-opt/copy-prop/issue_141649.f_head_borrowed.CopyProp.diff new file mode 100644 index 0000000000000..f8c23f28ff1a9 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649.f_head_borrowed.CopyProp.diff @@ -0,0 +1,32 @@ +- // MIR for `f_head_borrowed` before CopyProp ++ // MIR for `f_head_borrowed` after CopyProp + + fn f_head_borrowed() -> () { + let mut _0: (); + let mut _1: S; + let mut _2: S; + let mut _3: S; + let mut _4: &S; + let mut _5: &S; + + bb0: { + StorageLive(_1); + _1 = S(const 1_u32, const 2_u32); +- StorageLive(_2); + _4 = &_1; +- _2 = copy _1; +- _3 = opaque::(move _1) -> [return: bb1, unwind unreachable]; ++ _3 = opaque::(copy _1) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_2); + StorageDead(_1); + _5 = opaque::<&S>(move _4) -> [return: bb2, unwind unreachable]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/copy-prop/issue_141649.f_move.CopyProp.diff b/tests/mir-opt/copy-prop/issue_141649.f_move.CopyProp.diff new file mode 100644 index 0000000000000..89af99210124a --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649.f_move.CopyProp.diff @@ -0,0 +1,25 @@ +- // MIR for `f_move` before CopyProp ++ // MIR for `f_move` after CopyProp + + fn f_move() -> () { + let mut _0: (); + let mut _1: S; + let mut _2: S; + let mut _3: S; + + bb0: { + StorageLive(_1); + _1 = S(const 1_u32, const 2_u32); +- StorageLive(_2); +- _2 = copy _1; +- _3 = opaque::(move _1) -> [return: bb1, unwind unreachable]; ++ _3 = opaque::(copy _1) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_2); + StorageDead(_1); + 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..25884a9808db9 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649.rs @@ -0,0 +1,75 @@ +//! Check that we do not remove storage statements when the head is alive for all usages. +//@ test-mir-pass: CopyProp +// EMIT_MIR issue_141649.f_move.CopyProp.diff +// EMIT_MIR issue_141649.f_head_borrowed.CopyProp.diff + +#![feature(custom_mir, core_intrinsics)] + +use std::intrinsics::mir::*; + +struct S(u32, u32); + +#[custom_mir(dialect = "runtime")] +pub fn f_move() { + // CHECK-LABEL: fn f_move( + mir! { + let _1: S; + let _2: S; + let _3: S; + { + // CHECK: StorageLive(_1); + // CHECK-NOT: StorageLive(_2); + // CHECK: _3 = opaque::(copy _1) -> [return: bb1, unwind unreachable]; + StorageLive(_1); + _1 = S(1, 2); + StorageLive(_2); + _2 = _1; + Call(_3 = opaque(Move(_1)), ReturnTo(bb1), UnwindUnreachable()) + } + bb1 = { + // CHECK-NOT: StorageDead(_2); + // CHECK: StorageDead(_1); + StorageDead(_2); + StorageDead(_1); + Return() + } + } +} + +#[custom_mir(dialect = "runtime")] +fn f_head_borrowed() { + // CHECK-LABEL: fn f_head_borrowed( + mir! { + let _1: S; + let _2: S; + let _3: S; + let _4: &S; + let _5: &S; + { + // CHECK: StorageLive(_1); + // CHECK-NOT: StorageLive(_2); + // CHECK: _3 = opaque::(copy _1) -> [return: bb1, unwind unreachable]; + StorageLive(_1); + _1 = S(1, 2); + StorageLive(_2); + _4 = &_1; + _2 = _1; + Call(_3 = opaque(Move(_1)), ReturnTo(bb1), UnwindUnreachable()) + } + bb1 = { + // CHECK-NOT: StorageDead(_2); + // CHECK: StorageDead(_1); + StorageDead(_2); + StorageDead(_1); + Call(_5 = opaque(Move(_4)), ReturnTo(bb2), UnwindUnreachable()) + } + bb2 = { + Return() + } + } +} + +#[inline(never)] +fn opaque(a: T) -> T { + a +} diff --git a/tests/mir-opt/copy-prop/issue_141649_debug.f_move.CopyProp.diff b/tests/mir-opt/copy-prop/issue_141649_debug.f_move.CopyProp.diff new file mode 100644 index 0000000000000..5cb3753399d59 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649_debug.f_move.CopyProp.diff @@ -0,0 +1,25 @@ +- // MIR for `f_move` before CopyProp ++ // MIR for `f_move` after CopyProp + + fn f_move() -> () { + let mut _0: (); + let mut _1: S; + let mut _2: S; + let mut _3: S; + + bb0: { +- StorageLive(_1); + _1 = S(const 1_u32, const 2_u32); +- StorageLive(_2); +- _2 = copy _1; +- _3 = opaque::(move _1) -> [return: bb1, unwind unreachable]; ++ _3 = opaque::(copy _1) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_2); +- StorageDead(_1); + 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..554228000b670 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_141649_debug.rs @@ -0,0 +1,42 @@ +//! 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.f_move.CopyProp.diff + +#![feature(custom_mir, core_intrinsics)] + +use std::intrinsics::mir::*; + +struct S(u32, u32); + +#[custom_mir(dialect = "runtime")] +pub fn f_move() { + // CHECK-LABEL: fn f_move( + mir! { + let _1: S; + let _2: S; + let _3: S; + { + // CHECK-NOT: StorageLive(_1); + // CHECK-NOT: StorageLive(_2); + // CHECK: _3 = opaque::(copy _1) -> [return: bb1, unwind unreachable]; + StorageLive(_1); + _1 = S(1, 2); + StorageLive(_2); + _2 = _1; + Call(_3 = opaque(Move(_1)), ReturnTo(bb1), UnwindUnreachable()) + } + bb1 = { + // CHECK-NOT: StorageDead(_2); + // CHECK-NOT: StorageDead(_1); + StorageDead(_2); + StorageDead(_1); + Return() + } + } +} + +#[inline(never)] +fn opaque(a: T) -> T { + a +} 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 8ef61b5667dd5..7ada873b82f8e 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 2a7182af984d6..23943f474661e 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 8a2cdd8e5728e..4fd9f5af8ee12 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 614d23cf62457..8a428ef12cdde 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 bcf0ad7c165f7..6d6fe22b768e2 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 @@ -91,11 +91,10 @@ StorageLive(_17); - _17 = const <() as std::mem::SizedTypeProperties>::ALIGN; + _17 = const 1_usize; - StorageLive(_18); StorageLive(_20); - StorageLive(_21); StorageLive(_22); StorageLive(_23); + StorageLive(_18); switchInt(UbChecks) -> [0: bb6, otherwise: bb5]; } @@ -115,6 +114,7 @@ } bb4: { + StorageLive(_21); _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); - StorageLive(_25); + nop; @@ -122,12 +122,12 @@ _12 = copy _25 as *mut u8 (PtrToPtr); - StorageDead(_25); + nop; + StorageDead(_21); StorageDead(_19); + StorageDead(_18); StorageDead(_23); StorageDead(_22); - StorageDead(_21); StorageDead(_20); - StorageDead(_18); StorageDead(_17); StorageDead(_16); - _13 = copy _12 as *const () (PtrToPtr); @@ -145,15 +145,13 @@ _2 = &_3; _1 = &(*_2); - StorageDead(_2); -- StorageLive(_5); -- _10 = copy (*_1); -+ nop; + nop; + StorageLive(_5); +- _10 = copy (*_1); + _10 = copy (*_2); _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _5 = &raw const (*_11); -- StorageLive(_6); -+ nop; + StorageLive(_6); StorageLive(_7); _7 = copy _5; StorageLive(_26); @@ -174,10 +172,8 @@ StorageDead(_9); _0 = const (); StorageDead(_8); -- StorageDead(_6); -- StorageDead(_5); -+ nop; -+ nop; + StorageDead(_6); + StorageDead(_5); 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 82a14a8b6ec99..d61433b1efa77 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 @@ -52,15 +52,13 @@ _2 = &_3; _1 = &(*_2); - StorageDead(_2); -- StorageLive(_5); -- _10 = copy (*_1); -+ nop; + nop; + StorageLive(_5); +- _10 = copy (*_1); + _10 = copy (*_2); _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _5 = &raw const (*_11); -- StorageLive(_6); -+ nop; + StorageLive(_6); StorageLive(_7); _7 = copy _5; StorageLive(_12); @@ -81,10 +79,8 @@ StorageDead(_9); _0 = const (); StorageDead(_8); -- StorageDead(_6); -- StorageDead(_5); -+ nop; -+ nop; + StorageDead(_6); + StorageDead(_5); 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 408ff60712e11..6c71db9a7f692 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 @@ -26,12 +26,12 @@ scope 4 { debug _x => _8; } - scope 18 (inlined foo) { + scope 19 (inlined foo) { let mut _27: *const [()]; } } - scope 16 (inlined slice_from_raw_parts::<()>) { - scope 17 (inlined std::ptr::from_raw_parts::<[()], ()>) { + scope 17 (inlined slice_from_raw_parts::<()>) { + scope 18 (inlined std::ptr::from_raw_parts::<[()], ()>) { } } } @@ -49,19 +49,21 @@ scope 7 { let _21: std::ptr::NonNull<[u8]>; scope 8 { - scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) { - scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) { - scope 13 (inlined NonNull::<[u8]>::cast::) { + scope 12 (inlined NonNull::<[u8]>::as_mut_ptr) { + scope 13 (inlined NonNull::<[u8]>::as_non_null_ptr) { + scope 14 (inlined NonNull::<[u8]>::cast::) { let mut _25: *mut [u8]; - scope 14 (inlined NonNull::<[u8]>::as_ptr) { + scope 15 (inlined NonNull::<[u8]>::as_ptr) { } } } - scope 15 (inlined NonNull::::as_ptr) { + scope 16 (inlined NonNull::::as_ptr) { } } } scope 10 (inlined ::allocate) { + scope 11 (inlined std::alloc::Global::alloc_impl) { + } } } scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { @@ -89,11 +91,10 @@ StorageLive(_17); - _17 = const <() as std::mem::SizedTypeProperties>::ALIGN; + _17 = const 1_usize; - StorageLive(_18); StorageLive(_20); - StorageLive(_21); StorageLive(_22); StorageLive(_23); + StorageLive(_18); switchInt(UbChecks) -> [0: bb6, otherwise: bb5]; } @@ -113,6 +114,7 @@ } bb4: { + StorageLive(_21); _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); - StorageLive(_25); + nop; @@ -120,12 +122,12 @@ _12 = copy _25 as *mut u8 (PtrToPtr); - StorageDead(_25); + nop; + StorageDead(_21); StorageDead(_19); + StorageDead(_18); StorageDead(_23); StorageDead(_22); - StorageDead(_21); StorageDead(_20); - StorageDead(_18); StorageDead(_17); StorageDead(_16); - _13 = copy _12 as *const () (PtrToPtr); @@ -143,15 +145,13 @@ _2 = &_3; _1 = &(*_2); - StorageDead(_2); -- StorageLive(_5); -- _10 = copy (*_1); -+ nop; + nop; + StorageLive(_5); +- _10 = copy (*_1); + _10 = copy (*_2); _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _5 = &raw const (*_11); -- StorageLive(_6); -+ nop; + StorageLive(_6); StorageLive(_7); _7 = copy _5; StorageLive(_26); @@ -172,10 +172,8 @@ StorageDead(_9); _0 = const (); StorageDead(_8); -- StorageDead(_6); -- StorageDead(_5); -+ nop; -+ nop; + StorageDead(_6); + StorageDead(_5); drop(_3) -> [return: bb1, unwind unreachable]; } @@ -192,8 +190,8 @@ + _18 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; StorageDead(_24); StorageLive(_19); -- _19 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _18, const false) -> [return: bb7, unwind unreachable]; -+ _19 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; +- _19 = std::alloc::Global::alloc_impl_runtime(copy _18, const false) -> [return: bb7, unwind unreachable]; ++ _19 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; } bb7: { 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 82a14a8b6ec99..d61433b1efa77 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 @@ -52,15 +52,13 @@ _2 = &_3; _1 = &(*_2); - StorageDead(_2); -- StorageLive(_5); -- _10 = copy (*_1); -+ nop; + nop; + StorageLive(_5); +- _10 = copy (*_1); + _10 = copy (*_2); _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); _5 = &raw const (*_11); -- StorageLive(_6); -+ nop; + StorageLive(_6); StorageLive(_7); _7 = copy _5; StorageLive(_12); @@ -81,10 +79,8 @@ StorageDead(_9); _0 = const (); StorageDead(_8); -- StorageDead(_6); -- StorageDead(_5); -+ nop; -+ nop; + StorageDead(_6); + StorageDead(_5); 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.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 90920dd0be8fd..ba582f4a7fded 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(Safe), 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(Safe), AsCast)); StorageLive(_5); StorageLive(_6); @@ -61,12 +59,10 @@ bb2: { StorageDead(_6); StorageDead(_5); -- StorageLive(_7); + StorageLive(_7); - _7 = {closure@$DIR/gvn.rs:617:19: 617:21}; -- StorageLive(_8); -+ nop; + _7 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617: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 0aca8e508f5c3..3dd62108eba23 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(Safe), 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(Safe), AsCast)); StorageLive(_5); StorageLive(_6); @@ -61,12 +59,10 @@ bb2: { StorageDead(_6); StorageDead(_5); -- StorageLive(_7); + StorageLive(_7); - _7 = {closure@$DIR/gvn.rs:617:19: 617:21}; -- StorageLive(_8); -+ nop; + _7 = const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617: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 b7872fc9952ba..477b669d8156d 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); @@ -113,9 +112,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]; @@ -125,9 +123,8 @@ StorageDead(_11); _9 = &_10; - StorageLive(_12); -- StorageLive(_13); -+ nop; + nop; + StorageLive(_13); StorageLive(_14); - _14 = &(*_4); + _14 = &(*_1); @@ -168,14 +165,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); @@ -190,9 +184,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); @@ -221,9 +214,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]; @@ -233,9 +225,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]; @@ -275,27 +266,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 37817b48c1992..9b8655d01d45f 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); @@ -113,9 +112,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]; @@ -125,9 +123,8 @@ StorageDead(_11); _9 = &_10; - StorageLive(_12); -- StorageLive(_13); -+ nop; + nop; + StorageLive(_13); StorageLive(_14); - _14 = &(*_4); + _14 = &(*_1); @@ -168,14 +165,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); @@ -190,9 +184,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); @@ -221,9 +214,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]; @@ -233,9 +225,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]; @@ -275,27 +266,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 eed8cb7d62e70..fcbeeb234f95b 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,20 +24,17 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _8 = copy (*_1); _2 = copy ((*_8).0: i32); -- StorageLive(_3); + StorageLive(_3); - _9 = copy (*_1); - _3 = copy ((*_9).1: u64); -- StorageLive(_4); -- _10 = copy (*_1); -- _4 = copy ((*_10).2: [i8; 3]); -+ nop; + _9 = copy _8; + _3 = copy ((*_8).1: u64); -+ nop; + StorageLive(_4); +- _10 = copy (*_1); +- _4 = copy ((*_10).2: [i8; 3]); + _10 = copy _8; + _4 = copy ((*_8).2: [i8; 3]); StorageLive(_5); @@ -51,12 +48,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_loop.loop_deref_mut.GVN.diff b/tests/mir-opt/gvn_loop.loop_deref_mut.GVN.diff index e5d719cf3ca99..b008980074e81 100644 --- a/tests/mir-opt/gvn_loop.loop_deref_mut.GVN.diff +++ b/tests/mir-opt/gvn_loop.loop_deref_mut.GVN.diff @@ -58,9 +58,8 @@ } bb3: { -- StorageLive(_7); + StorageLive(_7); - _7 = copy (((*_2) as V0).0: i32); -+ nop; + _7 = copy (((*_3) as V0).0: i32); StorageLive(_9); goto -> bb4; @@ -85,8 +84,7 @@ StorageDead(_13); StorageDead(_11); StorageDead(_9); -- StorageDead(_7); -+ nop; + StorageDead(_7); StorageDead(_5); StorageDead(_2); 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_issue_141649.f.GVN.diff b/tests/mir-opt/gvn_storage_issue_141649.f.GVN.diff new file mode 100644 index 0000000000000..664839e792456 --- /dev/null +++ b/tests/mir-opt/gvn_storage_issue_141649.f.GVN.diff @@ -0,0 +1,20 @@ +- // MIR for `f` before GVN ++ // MIR for `f` after GVN + + fn f(_1: u32) -> () { + let mut _0: (); + let mut _2: S; + let mut _3: S; + + bb0: { + StorageLive(_2); + _2 = S(copy _1, const 2_u32); + StorageLive(_3); +- _3 = S(copy _1, const 2_u32); ++ _3 = copy _2; + StorageDead(_3); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/gvn_storage_issue_141649.f_borrowed.GVN.diff b/tests/mir-opt/gvn_storage_issue_141649.f_borrowed.GVN.diff new file mode 100644 index 0000000000000..4e9d355be6083 --- /dev/null +++ b/tests/mir-opt/gvn_storage_issue_141649.f_borrowed.GVN.diff @@ -0,0 +1,25 @@ +- // MIR for `f_borrowed` before GVN ++ // MIR for `f_borrowed` after GVN + + fn f_borrowed(_1: u32) -> () { + let mut _0: (); + let mut _2: S; + let mut _3: S; + let mut _4: &S; + let mut _5: S; + + bb0: { +- StorageLive(_2); ++ nop; + _2 = S(copy _1, const 2_u32); +- _3 = S(copy _1, const 2_u32); ++ _3 = copy _2; + _4 = &_3; +- StorageDead(_2); +- _5 = copy (*_4); ++ nop; ++ _5 = copy _2; + return; + } + } + diff --git a/tests/mir-opt/gvn_storage_issue_141649.f_dead.GVN.diff b/tests/mir-opt/gvn_storage_issue_141649.f_dead.GVN.diff new file mode 100644 index 0000000000000..0a20c56d549e8 --- /dev/null +++ b/tests/mir-opt/gvn_storage_issue_141649.f_dead.GVN.diff @@ -0,0 +1,22 @@ +- // MIR for `f_dead` before GVN ++ // MIR for `f_dead` after GVN + + fn f_dead(_1: u32) -> () { + let mut _0: (); + let mut _2: S; + let mut _3: S; + + bb0: { +- StorageLive(_2); ++ nop; + _2 = S(copy _1, const 2_u32); +- StorageDead(_2); ++ nop; + StorageLive(_3); +- _3 = S(copy _1, const 2_u32); ++ _3 = copy _2; + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/gvn_storage_issue_141649.rs b/tests/mir-opt/gvn_storage_issue_141649.rs new file mode 100644 index 0000000000000..f87d9aa426160 --- /dev/null +++ b/tests/mir-opt/gvn_storage_issue_141649.rs @@ -0,0 +1,83 @@ +//! Check that we do not remove storage statements when possible. +//@ test-mir-pass: GVN +// EMIT_MIR gvn_storage_issue_141649.f.GVN.diff +// EMIT_MIR gvn_storage_issue_141649.f_borrowed.GVN.diff +// EMIT_MIR gvn_storage_issue_141649.f_dead.GVN.diff + +#![feature(custom_mir, core_intrinsics)] + +use std::intrinsics::mir::*; + +struct S(u32, u32); + +#[custom_mir(dialect = "runtime")] +pub fn f(_1: u32) { + // CHECK-LABEL: fn f( + mir! { + let _2: S; + let _3: S; + { + // CHECK: StorageLive(_2); + // CHECK: StorageLive(_3); + // CHECK: _3 = copy _2; + // CHECK: StorageDead(_3); + // CHECK: StorageDead(_2); + StorageLive(_2); + _2 = S(_1, 2); + StorageLive(_3); + _3 = S(_1, 2); + StorageDead(_3); + StorageDead(_2); + Return() + } + } +} + +#[custom_mir(dialect = "runtime")] +pub fn f_borrowed(_1: u32) { + // CHECK-LABEL: fn f_borrowed( + mir! { + let _2: S; + let _3: S; + let _4: &S; + let _5: S; + { + // CHECK-NOT: StorageLive(_2); + // CHECK: _3 = copy _2; + // CHECK-NOT: StorageDead(_2); + // CHECK: _5 = copy _2; + StorageLive(_2); + _2 = S(_1, 2); + _3 = S(_1, 2); + _4 = &_3; + StorageDead(_2); + // Because `*_4` will be replaced with `_2`, + // we have to remove the storage statements of `_2`. + _5 = *_4; + Return() + } + } +} + +#[custom_mir(dialect = "runtime")] +pub fn f_dead(_1: u32) { + // CHECK-LABEL: fn f_dead( + mir! { + let _2: S; + let _3: S; + { + // CHECK-NOT: StorageLive(_2); + // CHECK: StorageLive(_3); + // CHECK: _3 = copy _2; + // CHECK: StorageDead(_3); + // CHECK-NOT: StorageDead(_2); + StorageLive(_2); + _2 = S(_1, 2); + StorageDead(_2); + StorageLive(_3); + _3 = S(_1, 2); + StorageDead(_3); + Return() + } + } +} diff --git a/tests/mir-opt/gvn_storage_issue_141649_debug.f.GVN.diff b/tests/mir-opt/gvn_storage_issue_141649_debug.f.GVN.diff new file mode 100644 index 0000000000000..ee43324b2fe89 --- /dev/null +++ b/tests/mir-opt/gvn_storage_issue_141649_debug.f.GVN.diff @@ -0,0 +1,22 @@ +- // MIR for `f` before GVN ++ // MIR for `f` after GVN + + fn f(_1: u32) -> () { + let mut _0: (); + let mut _2: S; + let mut _3: S; + + bb0: { +- StorageLive(_2); ++ nop; + _2 = S(copy _1, const 2_u32); + StorageLive(_3); +- _3 = S(copy _1, const 2_u32); ++ _3 = copy _2; + StorageDead(_3); +- StorageDead(_2); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn_storage_issue_141649_debug.rs b/tests/mir-opt/gvn_storage_issue_141649_debug.rs new file mode 100644 index 0000000000000..2c397f58fe934 --- /dev/null +++ b/tests/mir-opt/gvn_storage_issue_141649_debug.rs @@ -0,0 +1,31 @@ +//! In lower opt levels, we remove any storage statements of reused locals. +//@ test-mir-pass: GVN +//@ compile-flags: -Copt-level=0 +// EMIT_MIR gvn_storage_issue_141649_debug.f.GVN.diff + +#![feature(custom_mir, core_intrinsics)] + +use std::intrinsics::mir::*; + +struct S(u32, u32); + +#[custom_mir(dialect = "runtime")] +pub fn f(_1: u32) { + // CHECK-LABEL: fn f( + mir! { + let _2: S; + let _3: S; + { + // CHECK-NOT: StorageLive(_2); + // CHECK: _3 = copy _2; + // CHECK-NOT: StorageDead(_2); + StorageLive(_2); + _2 = S(_1, 2); + StorageLive(_3); + _3 = S(_1, 2); + StorageDead(_3); + StorageDead(_2); + 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..ca040f7efd5d7 --- /dev/null +++ b/tests/mir-opt/gvn_storage_twice.rs @@ -0,0 +1,73 @@ +//@ 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 { + // CHECK-LABEL: fn repeat_local( + mir! { + { + let _4 = [_3; 5]; + let _5 = &_4[_1]; + // CHECK: _0 = copy _3; + 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 { + // CHECK-LABEL: fn repeat_local_dead( + mir! { + { + let _4 = [_3; 5]; + let _5 = &_4[_1]; + // CHECK-NOT: StorageDead(_3); + StorageDead(_3); + // CHECK: _0 = copy _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 { + // CHECK-LABEL: fn repeat_local_dead_live( + mir! { + { + let _4 = [_3; 5]; + let _5 = &_4[_1]; + // CHECK-NOT: StorageLive(_3); + // CHECK-NOT: StorageDead(_3); + StorageDead(_3); + StorageLive(_3); + // CHECK: _0 = copy _3; + RET = *_5; + Return() + } + } +} + +#[inline(never)] +fn opaque(a: T) -> T { + a +} diff --git a/tests/mir-opt/gvn_storage_unreachable.f.GVN.diff b/tests/mir-opt/gvn_storage_unreachable.f.GVN.diff new file mode 100644 index 0000000000000..e29cbe0e2b00d --- /dev/null +++ b/tests/mir-opt/gvn_storage_unreachable.f.GVN.diff @@ -0,0 +1,28 @@ +- // MIR for `f` before GVN ++ // MIR for `f` after GVN + + fn f(_1: u32) -> () { + let mut _0: (); + let mut _2: S; + let mut _3: S; + let mut _4: S; + + bb0: { + StorageLive(_2); + _2 = S(copy _1, const 2_u32); + StorageLive(_3); +- _3 = S(copy _1, const 2_u32); ++ _3 = copy _2; + StorageDead(_3); + StorageDead(_2); + return; + } + + bb1: { + StorageLive(_2); + _4 = copy _2; + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/gvn_storage_unreachable.rs b/tests/mir-opt/gvn_storage_unreachable.rs new file mode 100644 index 0000000000000..20e362d1a71de --- /dev/null +++ b/tests/mir-opt/gvn_storage_unreachable.rs @@ -0,0 +1,41 @@ +//! Check that we do not remove the storage statements if a reused local +//! is uninitialized in an unreachable block. +//@ test-mir-pass: GVN +// EMIT_MIR gvn_storage_unreachable.f.GVN.diff + +#![feature(custom_mir, core_intrinsics)] + +use std::intrinsics::mir::*; + +struct S(u32, u32); + +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +pub fn f(_1: u32) { + // CHECK-LABEL: fn f( + mir! { + let _2: S; + let _3: S; + let _4: S; + { + // CHECK: StorageLive(_2); + // CHECK: StorageLive(_3); + // CHECK: _3 = copy _2; + // CHECK: StorageDead(_3); + // CHECK: StorageDead(_2); + StorageLive(_2); + _2 = S(_1, 2); + StorageLive(_3); + _3 = S(_1, 2); + StorageDead(_3); + StorageDead(_2); + Return() + } + bb1 = { + StorageLive(_2); + // CHECK: _4 = copy _2; + _4 = _2; + StorageDead(_2); + Return() + } + } +} 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_76432.test.SimplifyComparisonIntegral.panic-abort.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff index 614d9ad440d20..95f9b5997d4f6 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff @@ -21,10 +21,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); 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 57a88cf898412..87449b043fd5e 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff @@ -21,10 +21,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); 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.chained_conditions.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff index 8777ac426d788..2d4ed6e784107 100644 --- a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff @@ -430,7 +430,6 @@ StorageLive(_41); _39 = copy _29 as &[u8] (Transmute); _41 = copy _28 as &[u8] (Transmute); - StorageLive(_45); StorageLive(_50); StorageLive(_51); StorageLive(_42); @@ -445,7 +444,6 @@ bb22: { StorageDead(_51); StorageDead(_50); - StorageDead(_45); StorageDead(_41); StorageDead(_39); StorageDead(_35); @@ -468,6 +466,7 @@ StorageDead(_44); StorageDead(_43); StorageDead(_42); + StorageLive(_45); StorageLive(_49); _49 = &raw const (*_39); _45 = std::intrinsics::size_of_val::<[u8]>(move _49) -> [return: bb26, unwind unreachable]; @@ -478,6 +477,7 @@ StorageDead(_47); _7 = Eq(move _46, const 0_i32); StorageDead(_46); + StorageDead(_45); goto -> bb22; } @@ -518,7 +518,6 @@ StorageLive(_66); _64 = copy _54 as &[u8] (Transmute); _66 = copy _53 as &[u8] (Transmute); - StorageLive(_70); StorageLive(_75); StorageLive(_76); StorageLive(_67); @@ -533,7 +532,6 @@ bb30: { StorageDead(_76); StorageDead(_75); - StorageDead(_70); StorageDead(_66); StorageDead(_64); StorageDead(_60); @@ -556,6 +554,7 @@ StorageDead(_69); StorageDead(_68); StorageDead(_67); + StorageLive(_70); StorageLive(_74); _74 = &raw const (*_64); _70 = std::intrinsics::size_of_val::<[u8]>(move _74) -> [return: bb34, unwind unreachable]; @@ -566,6 +565,7 @@ StorageDead(_72); _14 = Eq(move _71, const 0_i32); StorageDead(_71); + StorageDead(_70); goto -> bb30; } @@ -584,7 +584,6 @@ + bb35: { + StorageDead(_51); + StorageDead(_50); -+ StorageDead(_45); + StorageDead(_41); + StorageDead(_39); + StorageDead(_35); @@ -597,7 +596,6 @@ + bb36: { + StorageDead(_76); + StorageDead(_75); -+ StorageDead(_70); + StorageDead(_66); + StorageDead(_64); + StorageDead(_60); diff --git a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff index 822d33c89391b..498c6efd0ade9 100644 --- a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff @@ -447,7 +447,6 @@ StorageLive(_41); _39 = copy _29 as &[u8] (Transmute); _41 = copy _28 as &[u8] (Transmute); - StorageLive(_45); StorageLive(_50); StorageLive(_51); StorageLive(_42); @@ -462,7 +461,6 @@ bb26: { StorageDead(_51); StorageDead(_50); - StorageDead(_45); StorageDead(_41); StorageDead(_39); StorageDead(_35); @@ -485,6 +483,7 @@ StorageDead(_44); StorageDead(_43); StorageDead(_42); + StorageLive(_45); StorageLive(_49); _49 = &raw const (*_39); _45 = std::intrinsics::size_of_val::<[u8]>(move _49) -> [return: bb30, unwind unreachable]; @@ -495,6 +494,7 @@ StorageDead(_47); _7 = Eq(move _46, const 0_i32); StorageDead(_46); + StorageDead(_45); goto -> bb26; } @@ -535,7 +535,6 @@ StorageLive(_66); _64 = copy _54 as &[u8] (Transmute); _66 = copy _53 as &[u8] (Transmute); - StorageLive(_70); StorageLive(_75); StorageLive(_76); StorageLive(_67); @@ -550,7 +549,6 @@ bb34: { StorageDead(_76); StorageDead(_75); - StorageDead(_70); StorageDead(_66); StorageDead(_64); StorageDead(_60); @@ -573,6 +571,7 @@ StorageDead(_69); StorageDead(_68); StorageDead(_67); + StorageLive(_70); StorageLive(_74); _74 = &raw const (*_64); _70 = std::intrinsics::size_of_val::<[u8]>(move _74) -> [return: bb38, unwind unreachable]; @@ -583,6 +582,7 @@ StorageDead(_72); _14 = Eq(move _71, const 0_i32); StorageDead(_71); + StorageDead(_70); goto -> bb34; } @@ -601,7 +601,6 @@ + bb39: { + StorageDead(_51); + StorageDead(_50); -+ StorageDead(_45); + StorageDead(_41); + StorageDead(_39); + StorageDead(_35); @@ -614,7 +613,6 @@ + bb40: { + StorageDead(_76); + StorageDead(_75); -+ StorageDead(_70); + StorageDead(_66); + StorageDead(_64); + StorageDead(_60); 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 97b8d484194f5..e72ee28bf10b7 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); @@ -101,25 +97,27 @@ } 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; + goto -> bb9; + } + + bb8: { -+ StorageDead(_12); -+ StorageDead(_11); + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); @@ -127,8 +125,6 @@ + } + + bb9: { -+ 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 97b8d484194f5..e72ee28bf10b7 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); @@ -101,25 +97,27 @@ } 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; + goto -> bb9; + } + + bb8: { -+ StorageDead(_12); -+ StorageDead(_11); + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); @@ -127,8 +125,6 @@ + } + + bb9: { -+ 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/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 269af438e37ef..f0b3a373d50ac 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,8 +15,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _6 = copy (*_1); _2 = copy (*_6); _3 = unknown() -> [return: bb1, unwind unreachable]; @@ -32,8 +31,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 9ce17342a445c..8676208dbf71a 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,8 +15,7 @@ } bb0: { -- StorageLive(_2); -+ nop; + StorageLive(_2); _6 = copy (*_1); _2 = copy (*_6); _3 = unknown() -> [return: bb1, unwind continue]; @@ -32,8 +31,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 578aff4f7129d..257b43050c3c0 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 @@ -36,7 +36,6 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool { } bb0: { - StorageLive(_11); StorageLive(_6); StorageLive(_5); StorageLive(_7); @@ -69,13 +68,14 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool { bb2: { StorageDead(_7); StorageDead(_5); + StorageLive(_11); _11 = move ((_6 as Some).0: std::cmp::Ordering); StorageLive(_12); _12 = discriminant(_11); _0 = Le(move _12, const 0_i8); StorageDead(_12); - StorageDead(_6); StorageDead(_11); + StorageDead(_6); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir index 013361d1d2fb8..516cc145635cb 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir @@ -67,8 +67,11 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); + StorageLive(_5); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); + StorageLive(_8); StorageLive(_4); _3 = copy _2 as *mut [T] (Transmute); _4 = copy _2 as *const [T] (Transmute); @@ -102,7 +105,10 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb4: { + StorageDead(_8); StorageDead(_2); + StorageDead(_5); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir index 013361d1d2fb8..516cc145635cb 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir @@ -67,8 +67,11 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); + StorageLive(_5); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); + StorageLive(_8); StorageLive(_4); _3 = copy _2 as *mut [T] (Transmute); _4 = copy _2 as *const [T] (Transmute); @@ -102,7 +105,10 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb4: { + StorageDead(_8); StorageDead(_2); + StorageDead(_5); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir index 791d6b71a6f78..516cc145635cb 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir @@ -25,17 +25,21 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } } scope 18 (inlined ::deallocate) { - let mut _9: *mut u8; - scope 19 (inlined Layout::size) { - } - scope 20 (inlined NonNull::::as_ptr) { - } - scope 21 (inlined std::alloc::dealloc) { - let mut _10: usize; - scope 22 (inlined Layout::size) { - } - scope 23 (inlined Layout::align) { - scope 24 (inlined std::ptr::Alignment::as_usize) { + scope 19 (inlined std::alloc::Global::deallocate_impl) { + scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) { + let mut _9: *mut u8; + scope 21 (inlined Layout::size) { + } + scope 22 (inlined NonNull::::as_ptr) { + } + scope 23 (inlined std::alloc::dealloc) { + let mut _10: usize; + scope 24 (inlined Layout::size) { + } + scope 25 (inlined Layout::align) { + scope 26 (inlined std::ptr::Alignment::as_usize) { + } + } } } } @@ -63,8 +67,11 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); + StorageLive(_5); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); + StorageLive(_8); StorageLive(_4); _3 = copy _2 as *mut [T] (Transmute); _4 = copy _2 as *const [T] (Transmute); @@ -98,7 +105,10 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb4: { + StorageDead(_8); StorageDead(_2); + StorageDead(_5); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir index 013361d1d2fb8..516cc145635cb 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir @@ -67,8 +67,11 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); + StorageLive(_5); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); + StorageLive(_8); StorageLive(_4); _3 = copy _2 as *mut [T] (Transmute); _4 = copy _2 as *const [T] (Transmute); @@ -102,7 +105,10 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb4: { + StorageDead(_8); StorageDead(_2); + StorageDead(_5); + StorageDead(_3); 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 d0fda06c115ce..92a4ddec66829 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; @@ -80,13 +79,13 @@ bb4: { StorageDead(_7); StorageLive(_10); - StorageLive(_14); _10 = discriminant(_6); switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { StorageLive(_13); + StorageLive(_14); _14 = &_11; _13 = copy _14 as &dyn std::fmt::Debug (PointerCoercion(Unsize, Implicit)); _12 = result::unwrap_failed(const "called `Result::unwrap()` on an `Err` value", move _13) -> unwind unreachable; @@ -94,7 +93,6 @@ bb6: { _5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>); - StorageDead(_14); StorageDead(_10); StorageDead(_6); _4 = copy _5 as *mut [u8] (Transmute); @@ -102,8 +100,7 @@ _3 = copy _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 485ff902a7b9d..d8f5a6e9b8924 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 = copy _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 1dbe9394e7094..c703f7223aac1 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 @@ -9,47 +9,46 @@ let mut _4: *mut [u8]; let mut _5: std::ptr::NonNull<[u8]>; let mut _6: std::result::Result, std::alloc::AllocError>; - let mut _7: &std::alloc::Global; - let mut _8: std::alloc::Layout; + let mut _7: std::alloc::Layout; scope 1 { debug layout => _1; - let mut _9: &std::alloc::Global; scope 2 { debug ptr => _3; } scope 5 (inlined ::allocate) { - } - scope 6 (inlined #[track_caller] Result::, std::alloc::AllocError>::unwrap) { - let mut _12: isize; - let _13: std::alloc::AllocError; - let mut _14: !; - let mut _15: &dyn std::fmt::Debug; - let _16: &std::alloc::AllocError; - scope 7 { + scope 6 (inlined std::alloc::Global::alloc_impl) { } + } + scope 7 (inlined #[track_caller] Result::, std::alloc::AllocError>::unwrap) { + let mut _10: isize; + let _11: std::alloc::AllocError; + let mut _12: !; + let mut _13: &dyn std::fmt::Debug; + let _14: &std::alloc::AllocError; scope 8 { } + scope 9 { + } } - scope 9 (inlined NonNull::<[u8]>::as_ptr) { + scope 10 (inlined NonNull::<[u8]>::as_ptr) { } } scope 3 (inlined #[track_caller] Option::::unwrap) { - let mut _10: isize; - let mut _11: !; + let mut _8: isize; + let mut _9: !; scope 4 { } } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); - _2 = Option::::None; + _2 = const Option::::None; - StorageLive(_10); -- _10 = discriminant(_2); -- switchInt(move _10) -> [0: bb2, 1: bb3, otherwise: bb1]; -+ _10 = const 0_isize; + StorageLive(_8); +- _8 = discriminant(_2); +- switchInt(move _8) -> [0: bb2, 1: bb3, otherwise: bb1]; ++ _8 = const 0_isize; + switchInt(const 0_isize) -> [0: bb2, 1: bb3, otherwise: bb1]; } @@ -58,56 +57,50 @@ } bb2: { - _11 = option::unwrap_failed() -> unwind unreachable; + _9 = option::unwrap_failed() -> unwind unreachable; } bb3: { - _1 = move ((_2 as Some).0: std::alloc::Layout); + _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; - StorageDead(_10); + StorageDead(_8); StorageDead(_2); StorageLive(_3); StorageLive(_4); StorageLive(_5); StorageLive(_6); StorageLive(_7); - _9 = const main::promoted[0]; - _7 = copy _9; - StorageLive(_8); -- _8 = copy _1; -- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb4, unwind unreachable]; -+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; -+ _6 = std::alloc::Global::alloc_impl(copy _9, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable]; +- _7 = copy _1; +- _6 = std::alloc::Global::alloc_impl_runtime(move _7, const false) -> [return: bb4, unwind unreachable]; ++ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; ++ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable]; } bb4: { - StorageDead(_8); StorageDead(_7); - StorageLive(_12); - StorageLive(_16); - _12 = discriminant(_6); - switchInt(move _12) -> [0: bb6, 1: bb5, otherwise: bb1]; + StorageLive(_10); + _10 = discriminant(_6); + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { - StorageLive(_15); - _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; + StorageLive(_13); + StorageLive(_14); + _14 = &_11; + _13 = copy _14 as &dyn std::fmt::Debug (PointerCoercion(Unsize, Implicit)); + _12 = result::unwrap_failed(const "called `Result::unwrap()` on an `Err` value", move _13) -> unwind unreachable; } bb6: { _5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>); - StorageDead(_16); - StorageDead(_12); + StorageDead(_10); StorageDead(_6); _4 = copy _5 as *mut [u8] (Transmute); StorageDead(_5); _3 = copy _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 beee899dafe6e..fe4946f5e7467 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 = copy _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 8f30ad30fccdf..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 @@ -6,20 +6,20 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () let mut _0: (); let mut _3: std::iter::FilterMap, impl Fn(T) -> Option>; let mut _4: std::iter::FilterMap, impl Fn(T) -> Option>; - let mut _7: std::option::Option; - let mut _8: isize; - let _10: (); - let mut _11: &mut std::iter::FilterMap, impl Fn(T) -> Option>; + let mut _5: &mut std::iter::FilterMap, impl Fn(T) -> Option>; + let mut _8: std::option::Option; + let mut _9: isize; + let _11: (); scope 1 { debug iter => _4; - let _9: U; + let _10: U; scope 2 { - debug x => _9; + debug x => _10; } scope 4 (inlined , impl Fn(T) -> Option> as Iterator>::next) { - debug self => _11; - let mut _5: &mut impl Iterator; - let mut _6: &mut impl Fn(T) -> Option; + debug self => _5; + let mut _6: &mut impl Iterator; + let mut _7: &mut impl Fn(T) -> Option; } } scope 3 (inlined , impl Fn(T) -> Option> as IntoIterator>::into_iter) { @@ -37,24 +37,24 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () } bb2: { - StorageLive(_7); - // DBG: _11 = &_4; - StorageLive(_5); - _5 = &mut (_4.0: impl Iterator); + StorageLive(_8); + _5 = &mut _4; StorageLive(_6); - _6 = &mut (_4.1: impl Fn(T) -> Option); - _7 = as Iterator>::find_map:: Option>(move _5, move _6) -> [return: bb3, unwind: bb9]; + _6 = &mut (_4.0: impl Iterator); + StorageLive(_7); + _7 = &mut (_4.1: impl Fn(T) -> Option); + _8 = as Iterator>::find_map:: Option>(move _6, move _7) -> [return: bb3, unwind: bb9]; } bb3: { + StorageDead(_7); StorageDead(_6); - StorageDead(_5); - _8 = discriminant(_7); - switchInt(move _8) -> [0: bb4, 1: bb6, otherwise: bb8]; + _9 = discriminant(_8); + switchInt(move _9) -> [0: bb4, 1: bb6, otherwise: bb8]; } bb4: { - StorageDead(_7); + StorageDead(_8); drop(_4) -> [return: bb5, unwind continue]; } @@ -64,12 +64,14 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () } bb6: { - _9 = move ((_7 as Some).0: U); - _10 = opaque::(move _9) -> [return: bb7, unwind: bb9]; + StorageLive(_10); + _10 = move ((_8 as Some).0: U); + _11 = opaque::(move _10) -> [return: bb7, unwind: bb9]; } bb7: { - StorageDead(_7); + 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 beb7b936ccf74..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 @@ -5,31 +5,32 @@ fn int_range(_1: usize, _2: usize) -> () { debug end => _2; let mut _0: (); let mut _3: std::ops::Range; - let mut _9: std::option::Option; - let _11: (); - let mut _12: &mut std::ops::Range; + let mut _4: std::ops::Range; + let mut _5: &mut std::ops::Range; + let mut _13: std::option::Option; + let _15: (); scope 1 { - debug iter => _3; - let _10: usize; + debug iter => _4; + let _14: usize; scope 2 { - debug i => _10; + debug i => _14; } scope 4 (inlined iter::range::>::next) { - debug self => _12; + debug self => _5; scope 5 (inlined as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _12; - let mut _6: bool; - let _7: usize; - let mut _8: usize; - let mut _13: &usize; - let mut _14: &usize; + debug self => _5; + let mut _6: &usize; + let mut _7: &usize; + let mut _10: bool; + let _11: usize; + let mut _12: usize; scope 6 { - debug old => _7; + debug old => _11; scope 8 (inlined ::forward_unchecked) { - debug start => _7; + debug start => _11; debug n => const 1_usize; scope 9 (inlined #[track_caller] core::num::::unchecked_add) { - debug self => _7; + debug self => _11; debug rhs => const 1_usize; scope 10 (inlined core::ub_checks::check_language_ub) { scope 11 (inlined core::ub_checks::check_language_ub::runtime) { @@ -39,10 +40,10 @@ fn int_range(_1: usize, _2: usize) -> () { } } scope 7 (inlined std::cmp::impls::::lt) { - debug self => _13; - debug other => _14; - let mut _4: usize; - let mut _5: usize; + debug self => _6; + debug other => _7; + let mut _8: usize; + let mut _9: usize; } } } @@ -53,45 +54,58 @@ fn int_range(_1: usize, _2: usize) -> () { bb0: { _3 = std::ops::Range:: { start: copy _1, end: copy _2 }; + StorageLive(_4); + _4 = copy _3; goto -> bb1; } bb1: { - StorageLive(_9); - // DBG: _12 = &_3; + StorageLive(_13); + _5 = &mut _4; + StorageLive(_10); StorageLive(_6); - // DBG: _13 = &(_3.0: usize); - // DBG: _14 = &(_3.1: usize); - StorageLive(_4); - _4 = copy (_3.0: usize); - StorageLive(_5); - _5 = copy (_3.1: usize); - _6 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); - switchInt(move _6) -> [0: bb2, otherwise: bb3]; + _6 = &(_4.0: usize); + StorageLive(_7); + _7 = &(_4.1: usize); + StorageLive(_8); + _8 = copy (_4.0: usize); + StorageLive(_9); + _9 = copy (_4.1: usize); + _10 = Lt(move _8, move _9); + StorageDead(_9); + StorageDead(_8); + switchInt(move _10) -> [0: bb2, otherwise: bb3]; } bb2: { + StorageDead(_7); StorageDead(_6); - StorageDead(_9); + StorageDead(_10); + StorageDead(_13); + StorageDead(_4); return; } bb3: { - _7 = copy (_3.0: usize); - StorageLive(_8); - _8 = AddUnchecked(copy _7, const 1_usize); - (_3.0: usize) = move _8; - StorageDead(_8); - _9 = Option::::Some(copy _7); + StorageDead(_7); StorageDead(_6); - _10 = copy ((_9 as Some).0: usize); - _11 = opaque::(move _10) -> [return: bb4, unwind continue]; + 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(_9); + 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 406c96fc32f48..f04111485125a 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -6,32 +6,32 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { let mut _0: (); let mut _3: std::iter::Map, impl Fn(T) -> U>; let mut _4: std::iter::Map, impl Fn(T) -> U>; - let mut _12: std::option::Option; - let _14: (); - let mut _15: &mut std::iter::Map, impl Fn(T) -> U>; + let mut _5: &mut std::iter::Map, impl Fn(T) -> U>; + let mut _13: std::option::Option; + let _15: (); scope 1 { debug iter => _4; - let _13: U; + let _14: U; scope 2 { - debug x => _13; + debug x => _14; } scope 4 (inlined , impl Fn(T) -> U> as Iterator>::next) { - debug self => _15; - let mut _5: &mut impl Iterator; - let mut _6: std::option::Option; - let mut _7: &mut impl Fn(T) -> U; + debug self => _5; + let mut _6: &mut impl Iterator; + let mut _7: std::option::Option; + let mut _8: &mut impl Fn(T) -> U; scope 5 (inlined Option::::map:: U>) { - debug self => _6; - debug f => _7; - let mut _8: isize; - let _9: T; - let mut _10: (T,); - let mut _11: U; + debug self => _7; + debug f => _8; + let mut _9: isize; + let _10: T; + let mut _11: (T,); + let mut _12: U; scope 6 { - debug x => _9; + debug x => _10; scope 7 (inlined ops::function::impls:: for &mut impl Fn(T) -> U>::call_once) { - debug self => _7; - debug args => _10; + debug self => _8; + debug args => _11; } } } @@ -52,30 +52,28 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { } bb2: { - StorageLive(_12); - // DBG: _15 = &_4; + StorageLive(_13); + _5 = &mut _4; StorageLive(_7); StorageLive(_6); - StorageLive(_5); - _5 = &mut (_4.0: impl Iterator); - _6 = as Iterator>::next(move _5) -> [return: bb3, unwind: bb10]; + _6 = &mut (_4.0: impl Iterator); + _7 = as Iterator>::next(move _6) -> [return: bb3, unwind: bb10]; } bb3: { - StorageDead(_5); - _7 = &mut (_4.1: impl Fn(T) -> U); + StorageDead(_6); StorageLive(_8); + _8 = &mut (_4.1: impl Fn(T) -> U); StorageLive(_9); - _8 = discriminant(_6); - switchInt(move _8) -> [0: bb4, 1: bb6, otherwise: bb9]; + _9 = discriminant(_7); + switchInt(move _9) -> [0: bb4, 1: bb6, otherwise: bb9]; } bb4: { StorageDead(_9); StorageDead(_8); - StorageDead(_6); StorageDead(_7); - StorageDead(_12); + StorageDead(_13); drop(_4) -> [return: bb5, unwind continue]; } @@ -85,27 +83,30 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { } bb6: { - _9 = move ((_6 as Some).0: T); - StorageLive(_11); StorageLive(_10); - _10 = (copy _9,); - _11 = U as FnMut<(T,)>>::call_mut(move _7, move _10) -> [return: bb7, unwind: bb10]; + _10 = move ((_7 as Some).0: T); + StorageLive(_12); + StorageLive(_11); + _11 = (copy _10,); + _12 = U as FnMut<(T,)>>::call_mut(move _8, move _11) -> [return: bb7, unwind: bb10]; } bb7: { - StorageDead(_10); - _12 = Option::::Some(move _11); StorageDead(_11); + _13 = Option::::Some(move _12); + StorageDead(_12); + StorageDead(_10); StorageDead(_9); StorageDead(_8); - StorageDead(_6); StorageDead(_7); - _13 = move ((_12 as Some).0: U); - _14 = opaque::(move _13) -> [return: bb8, unwind: bb10]; + StorageLive(_14); + _14 = move ((_13 as Some).0: U); + _15 = opaque::(move _14) -> [return: bb8, unwind: bb10]; } bb8: { - StorageDead(_12); + StorageDead(_14); + StorageDead(_13); 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 03a52b82b49b1..d107a37da0fe0 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 @@ -64,10 +64,13 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb4: { + StorageLive(_6); _6 = copy _1; _1 = AddUnchecked(copy _6, const 1_u32); _7 = Option::::Some(copy _6); + StorageDead(_6); StorageDead(_5); + StorageLive(_8); _8 = copy ((_7 as Some).0: u32); StorageLive(_9); _9 = &_3; @@ -79,6 +82,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb5: { StorageDead(_10); StorageDead(_9); + StorageDead(_8); StorageDead(_7); 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 3b09f33e73338..207dde62f7d61 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 @@ -64,10 +64,13 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb4: { + StorageLive(_6); _6 = copy _1; _1 = AddUnchecked(copy _6, const 1_u32); _7 = Option::::Some(copy _6); + StorageDead(_6); StorageDead(_5); + StorageLive(_8); _8 = copy ((_7 as Some).0: u32); StorageLive(_9); _9 = &_3; @@ -79,6 +82,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb5: { StorageDead(_10); StorageDead(_9); + StorageDead(_8); StorageDead(_7); 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_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_index_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir index 2df2c4b85b8fa..3d50d9dfcc9d6 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir @@ -30,6 +30,8 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { } bb0: { + StorageLive(_3); + StorageLive(_4); _3 = move (_2.0: usize); _4 = move (_2.1: usize); StorageLive(_5); @@ -58,8 +60,8 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { StorageLive(_9); _9 = &raw const (*_1); StorageLive(_10); - StorageLive(_11); _10 = copy _9 as *const u32 (PtrToPtr); + StorageLive(_11); _11 = Offset(copy _10, copy _3); _12 = *const [u32] from (copy _11, copy _6); StorageDead(_11); @@ -68,6 +70,8 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { _0 = &(*_12); StorageDead(_12); StorageDead(_8); + StorageDead(_3); + StorageDead(_4); return; } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir index d4b86b9633acd..08441c43d9b2a 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir @@ -30,6 +30,8 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { } bb0: { + StorageLive(_3); + StorageLive(_4); _3 = move (_2.0: usize); _4 = move (_2.1: usize); StorageLive(_5); @@ -58,8 +60,8 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { StorageLive(_9); _9 = &raw const (*_1); StorageLive(_10); - StorageLive(_11); _10 = copy _9 as *const u32 (PtrToPtr); + StorageLive(_11); _11 = Offset(copy _10, copy _3); _12 = *const [u32] from (copy _11, copy _6); StorageDead(_11); @@ -68,6 +70,8 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { _0 = &(*_12); StorageDead(_12); StorageDead(_8); + 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/pre-codegen/two_unwrap_unchecked.two_unwrap_unchecked.GVN.diff b/tests/mir-opt/pre-codegen/two_unwrap_unchecked.two_unwrap_unchecked.GVN.diff index 5b063e6762e07..78d58c6f60fae 100644 --- a/tests/mir-opt/pre-codegen/two_unwrap_unchecked.two_unwrap_unchecked.GVN.diff +++ b/tests/mir-opt/pre-codegen/two_unwrap_unchecked.two_unwrap_unchecked.GVN.diff @@ -40,9 +40,8 @@ } bb0: { -- StorageLive(_2); + StorageLive(_2); - StorageLive(_3); -+ nop; + nop; _3 = copy (*_1); - StorageLive(_8); @@ -97,8 +96,7 @@ StorageDead(_7); StorageDead(_6); StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/pre-codegen/two_unwrap_unchecked.two_unwrap_unchecked.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/two_unwrap_unchecked.two_unwrap_unchecked.PreCodegen.after.mir index b2b7f88d8534b..0b41ce991eab8 100644 --- a/tests/mir-opt/pre-codegen/two_unwrap_unchecked.two_unwrap_unchecked.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/two_unwrap_unchecked.two_unwrap_unchecked.PreCodegen.after.mir @@ -34,6 +34,7 @@ fn two_unwrap_unchecked(_1: &Option) -> i32 { } bb0: { + StorageLive(_4); _2 = copy (*_1); _3 = discriminant(_2); switchInt(copy _3) -> [0: bb2, 1: bb1, otherwise: bb2]; @@ -42,6 +43,7 @@ fn two_unwrap_unchecked(_1: &Option) -> i32 { bb1: { _4 = copy ((_2 as Some).0: i32); _0 = Add(copy _4, copy _4); + StorageDead(_4); return; } diff --git a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff index 34f451fc698c7..66d5c867b5fec 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,49 +55,51 @@ } 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]; } 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; + goto -> bb8; + } + + bb7: { -+ StorageDead(_8); -+ StorageDead(_7); + StorageDead(_6); + _3 = discriminant(_2); + goto -> bb3; + } + + bb8: { -+ StorageDead(_8); -+ StorageDead(_7); + StorageDead(_6); + _3 = discriminant(_2); + goto -> bb2; 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 794c28ab46da0..ce76cf395abfa 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; + goto -> bb9; } @@ -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]; }