From d2afd2551de8a09ae2a2bf93d7cc898b0f292ac6 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sat, 4 Oct 2025 17:49:24 +0000 Subject: [PATCH] Perform DestinationPropagation on places. --- compiler/rustc_mir_transform/src/dest_prop.rs | 240 +++++++++++++----- tests/codegen-llvm/scalar-pair-bool.rs | 7 +- ...buginfo_locals.DestinationPropagation.diff | 8 +- ...oo.DestinationPropagation.panic-abort.diff | 18 +- ...o.DestinationPropagation.panic-unwind.diff | 18 +- .../mir-opt/dest-prop/copy_propagation_arg.rs | 5 +- ...in.DestinationPropagation.panic-abort.diff | 12 +- ...n.DestinationPropagation.panic-unwind.diff | 12 +- ...stinationPropagation.after.panic-abort.mir | 6 +- ...tinationPropagation.after.panic-unwind.mir | 6 +- tests/mir-opt/dest-prop/dead_stores_79191.rs | 2 +- ...stinationPropagation.after.panic-abort.mir | 6 +- ...tinationPropagation.after.panic-unwind.mir | 6 +- tests/mir-opt/dest-prop/dead_stores_better.rs | 2 +- ...ng_operand.test.GVN.32bit.panic-abort.diff | 70 +++-- ...ng_operand.test.GVN.64bit.panic-abort.diff | 70 +++-- tests/mir-opt/gvn_copy_constant_projection.rs | 7 +- ...y.run2-{closure#0}.Inline.panic-abort.diff | 64 +++-- ....run2-{closure#0}.Inline.panic-unwind.diff | 64 +++-- ...ng.identity.JumpThreading.panic-abort.diff | 40 ++- ...g.identity.JumpThreading.panic-unwind.diff | 40 ++- tests/mir-opt/jump_threading.rs | 7 +- tests/mir-opt/pre-codegen/checked_ops.rs | 3 +- ...p_forward.PreCodegen.after.panic-abort.mir | 21 +- ..._forward.PreCodegen.after.panic-unwind.mir | 21 +- ...ecked_sub.PreCodegen.after.panic-abort.mir | 10 +- ...cked_sub.PreCodegen.after.panic-unwind.mir | 10 +- .../derived_ord.demo_le.PreCodegen.after.mir | 14 +- ...ace.PreCodegen.after.32bit.panic-abort.mir | 20 +- ...ce.PreCodegen.after.32bit.panic-unwind.mir | 20 +- ...ace.PreCodegen.after.64bit.panic-abort.mir | 20 +- ...ce.PreCodegen.after.64bit.panic-unwind.mir | 20 +- tests/mir-opt/pre-codegen/drop_boxed_slice.rs | 3 +- .../loops.filter_mapped.PreCodegen.after.mir | 17 +- .../loops.int_range.PreCodegen.after.mir | 29 +-- .../loops.mapped.PreCodegen.after.mir | 42 ++- .../loops.vec_move.PreCodegen.after.mir | 77 +++--- ...ward_loop.PreCodegen.after.panic-abort.mir | 23 +- ...ard_loop.PreCodegen.after.panic-unwind.mir | 23 +- ...sive_loop.PreCodegen.after.panic-abort.mir | 23 +- ...ive_loop.PreCodegen.after.panic-unwind.mir | 23 +- ...mple_option_map.ezmap.PreCodegen.after.mir | 14 +- ...map_via_question_mark.PreCodegen.after.mir | 22 +- .../mir-opt/pre-codegen/simple_option_map.rs | 9 +- tests/mir-opt/pre-codegen/slice_index.rs | 6 +- ...mut_range.PreCodegen.after.panic-abort.mir | 48 ++-- ...ut_range.PreCodegen.after.panic-unwind.mir | 48 ++-- ...dex_range.PreCodegen.after.panic-abort.mir | 72 +++--- ...ex_range.PreCodegen.after.panic-unwind.mir | 72 +++--- ...ked_range.PreCodegen.after.panic-abort.mir | 34 ++- ...ed_range.PreCodegen.after.panic-unwind.mir | 34 ++- ...ated_loop.PreCodegen.after.panic-abort.mir | 32 ++- ...ted_loop.PreCodegen.after.panic-unwind.mir | 8 +- ...ward_loop.PreCodegen.after.panic-abort.mir | 23 +- ...ard_loop.PreCodegen.after.panic-unwind.mir | 23 +- ...erse_loop.PreCodegen.after.panic-abort.mir | 23 +- ...rse_loop.PreCodegen.after.panic-unwind.mir | 23 +- .../try_identity.new.PreCodegen.after.mir | 29 +-- ...e_const_switch.identity.JumpThreading.diff | 28 +- 59 files changed, 803 insertions(+), 874 deletions(-) diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs index a10e0b82467cc..414ae24708e5f 100644 --- a/compiler/rustc_mir_transform/src/dest_prop.rs +++ b/compiler/rustc_mir_transform/src/dest_prop.rs @@ -149,6 +149,8 @@ use rustc_mir_dataflow::points::DenseLocationMap; use rustc_mir_dataflow::{Analysis, Results}; use tracing::{debug, trace}; +use crate::util::is_within_packed; + pub(super) struct DestinationPropagation; impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation { @@ -163,7 +165,7 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation { let borrowed = rustc_mir_dataflow::impls::borrowed_locals(body); - let candidates = Candidates::find(body, &borrowed); + let candidates = Candidates::find(tcx, body, &borrowed); trace!(?candidates); if candidates.c.is_empty() { return; @@ -177,60 +179,115 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation { dest_prop_mir_dump(tcx, body, &points, &live, &relevant); - let mut merged_locals = DenseBitSet::new_empty(body.local_decls.len()); + let mut storage_to_remove = DenseBitSet::new_empty(body.local_decls.len()); + + // Maps locals to the place with which they are unified. When a local maps to another + // local, this behaves as a union-find set, to be queried by `find_targets`. + let mut merged_targets: IndexVec> = + body.local_decls.indices().map(|l| l.into()).collect(); + let find_targets = |merged_targets: &mut IndexVec<_, _>, local| { + let mut place: Place<'tcx> = merged_targets[local]; + while let Some(head) = place.as_local() { + if place == merged_targets[head] { + break; + } + place = merged_targets[head]; + } + merged_targets[local] = place; + trace!("find_targets({local:?}) = {place:?}"); + place + }; - for (src, dst) in candidates.c.into_iter() { - trace!(?src, ?dst); + for (orig_src, orig_dst) in candidates.c.into_iter() { + // We want to replace `src` by `dst`. + trace!(?orig_src, ?orig_dst); - let Some(mut src) = relevant.find(src) else { continue }; - let Some(mut dst) = relevant.find(dst) else { continue }; + let mut src_place = find_targets(&mut merged_targets, orig_src); + let mut dst_place = find_targets(&mut merged_targets, orig_dst.local) + .project_deeper(orig_dst.projection, tcx); + trace!(?src_place, ?dst_place); + if src_place == dst_place { + continue; + } + + let Some(mut src) = relevant.find(orig_src) else { continue }; + let Some(mut dst) = relevant.find(orig_dst.local) else { continue }; if src == dst { continue; } + // We cannot unify a local that appears in an index with a place that has projections. + let src_in_index = relevant.appears_in_index.contains(src); + let dst_in_index = relevant.appears_in_index.contains(dst); + trace!(?src_in_index, ?dst_in_index); + + if (src_in_index || dst_in_index) + && (!src_place.projection.is_empty() || !dst_place.projection.is_empty()) + { + debug!("projection in index"); + continue; + } + let Some(src_live_ranges) = live.row(src) else { continue }; let Some(dst_live_ranges) = live.row(dst) else { continue }; trace!(?src, ?src_live_ranges); trace!(?dst, ?dst_live_ranges); if src_live_ranges.disjoint(dst_live_ranges) { - // We want to replace `src` by `dst`. - let mut orig_src = relevant.original[src]; - let mut orig_dst = relevant.original[dst]; + let is_required = |place: Place<'_>| { + is_local_required(place.local, body) || !place.projection.is_empty() + }; // The return place and function arguments are required and cannot be renamed. // This check cannot be made during candidate collection, as we may want to // unify the same non-required local with several required locals. - match (is_local_required(orig_src, body), is_local_required(orig_dst, body)) { + match (is_required(src_place), is_required(dst_place)) { // Renaming `src` is ok. (false, _) => {} // Renaming `src` is wrong, but renaming `dst` is ok. (true, false) => { std::mem::swap(&mut src, &mut dst); - std::mem::swap(&mut orig_src, &mut orig_dst); + std::mem::swap(&mut src_place, &mut dst_place); } // Neither local can be renamed, so skip this case. - (true, true) => continue, + (true, true) => { + debug!(?src_place, ?dst_place, "both required"); + continue; + } } + trace!(?src_place, ?dst_place); + + debug_assert!(src_place.projection.is_empty()); + let src_place = src_place.as_local().unwrap(); - trace!(?src, ?dst, "merge"); - merged_locals.insert(orig_src); - merged_locals.insert(orig_dst); + trace!(?src, ?dst, ?src_place, ?dst_place, "merge"); + storage_to_remove.insert(src_place); + storage_to_remove.insert(dst_place.local); // Replace `src` by `dst`. - let head = relevant.union(src, dst); + merged_targets[src_place] = dst_place; + let head = relevant.renames.unify(src, dst); live.union_rows(/* read */ src, /* write */ head); live.union_rows(/* read */ dst, /* write */ head); + if src_in_index || dst_in_index { + relevant.appears_in_index.insert(head); + } } } - trace!(?merged_locals); + trace!(?storage_to_remove); trace!(?relevant.renames); + trace!(?merged_targets); + + for local in merged_targets.indices() { + let _ = find_targets(&mut merged_targets, local); + } - if merged_locals.is_empty() { + trace!(?merged_targets); + if storage_to_remove.is_empty() { return; } - apply_merges(body, tcx, relevant, merged_locals); + apply_merges(body, tcx, storage_to_remove, merged_targets); } fn is_required(&self) -> bool { @@ -246,17 +303,17 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation { fn apply_merges<'tcx>( body: &mut Body<'tcx>, tcx: TyCtxt<'tcx>, - relevant: RelevantLocals, - merged_locals: DenseBitSet, + storage_to_remove: DenseBitSet, + merged_targets: IndexVec>, ) { - let mut merger = Merger { tcx, relevant, merged_locals }; + let mut merger = Merger { tcx, storage_to_remove, merged_targets }; merger.visit_body_preserves_cfg(body); } struct Merger<'tcx> { tcx: TyCtxt<'tcx>, - relevant: RelevantLocals, - merged_locals: DenseBitSet, + storage_to_remove: DenseBitSet, + merged_targets: IndexVec>, } impl<'tcx> MutVisitor<'tcx> for Merger<'tcx> { @@ -265,16 +322,26 @@ impl<'tcx> MutVisitor<'tcx> for Merger<'tcx> { } fn visit_local(&mut self, local: &mut Local, _: PlaceContext, _location: Location) { - if let Some(relevant) = self.relevant.find(*local) { - *local = self.relevant.original[relevant]; + let dest = self.merged_targets[*local]; + let Some(dest) = dest.as_local() else { + panic!("{local:?} merged with {dest:?} but used in indexing") + }; + *local = dest; + } + + fn visit_place(&mut self, place: &mut Place<'tcx>, _: PlaceContext, location: Location) { + if let Some(new_projection) = self.process_projection(&place.projection, location) { + place.projection = self.tcx.mk_place_elems(&new_projection); } + let dest = self.merged_targets[place.local]; + *place = dest.project_deeper(place.projection, self.tcx); } fn visit_statement(&mut self, statement: &mut Statement<'tcx>, location: Location) { match &statement.kind { // FIXME: Don't delete storage statements, but "merge" the storage ranges instead. StatementKind::StorageDead(local) | StatementKind::StorageLive(local) - if self.merged_locals.contains(*local) => + if self.storage_to_remove.contains(*local) => { statement.make_nop(true); } @@ -317,11 +384,12 @@ struct RelevantLocals { original: IndexVec, shrink: IndexVec>, renames: UnionFind, + appears_in_index: DenseBitSet, } impl RelevantLocals { #[tracing::instrument(level = "trace", skip(candidates, num_locals), ret)] - fn compute(candidates: &Candidates, num_locals: usize) -> RelevantLocals { + fn compute(candidates: &Candidates<'_>, num_locals: usize) -> RelevantLocals { let mut original = IndexVec::with_capacity(candidates.c.len()); let mut shrink = IndexVec::from_elem_n(None, num_locals); @@ -332,11 +400,18 @@ impl RelevantLocals { for &(src, dest) in candidates.c.iter() { declare(src); - declare(dest) + declare(dest.local) + } + + let mut appears_in_index = DenseBitSet::new_empty(original.len()); + for local in candidates.appears_in_index.iter() { + if let Some(relevant) = shrink[local] { + appears_in_index.insert(relevant); + } } let renames = UnionFind::new(original.len()); - RelevantLocals { original, shrink, renames } + RelevantLocals { original, shrink, renames, appears_in_index } } fn find(&mut self, src: Local) -> Option { @@ -344,20 +419,13 @@ impl RelevantLocals { let src = self.renames.find(src); Some(src) } - - fn union(&mut self, lhs: RelevantLocal, rhs: RelevantLocal) -> RelevantLocal { - let head = self.renames.unify(lhs, rhs); - // We need to ensure we keep the original local of the RHS, as it may be a required local. - self.original[head] = self.original[rhs]; - head - } } ///////////////////////////////////////////////////// // Candidate accumulation -#[derive(Debug, Default)] -struct Candidates { +#[derive(Debug)] +struct Candidates<'tcx> { /// The set of candidates we are considering in this optimization. /// /// Whether a place ends up in the key or the value does not correspond to whether it appears as @@ -370,49 +438,104 @@ struct Candidates { /// /// We will still report that we would like to merge `_1` and `_2` in an attempt to allow us to /// remove that assignment. - c: Vec<(Local, Local)>, + c: Vec<(Local, Place<'tcx>)>, + /// Whether this local appears in `PlaceElem::Index`. If that happens, we cannot unify it with + /// a place that has projections. + appears_in_index: DenseBitSet, } // We first implement some utility functions which we will expose removing candidates according to // different needs. Throughout the liveness filtering, the `candidates` are only ever accessed // through these methods, and not directly. -impl Candidates { +impl<'tcx> Candidates<'tcx> { /// Collects the candidates for merging. /// /// This is responsible for enforcing the first and third bullet point. - fn find(body: &Body<'_>, borrowed: &DenseBitSet) -> Candidates { - let mut visitor = FindAssignments { body, candidates: Default::default(), borrowed }; + fn find( + tcx: TyCtxt<'tcx>, + body: &Body<'tcx>, + borrowed: &DenseBitSet, + ) -> Candidates<'tcx> { + let mut visitor = FindAssignments { + tcx, + body, + candidates: Default::default(), + borrowed, + appears_in_index: DenseBitSet::new_empty(body.local_decls.len()), + }; visitor.visit_body(body); - Candidates { c: visitor.candidates } + visitor.candidates.sort_by_key(|&(s, d)| (s, d.local, d.projection.len())); + + Candidates { c: visitor.candidates, appears_in_index: visitor.appears_in_index } } } struct FindAssignments<'a, 'tcx> { + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - candidates: Vec<(Local, Local)>, + candidates: Vec<(Local, Place<'tcx>)>, borrowed: &'a DenseBitSet, + /// Whether this local appears in `PlaceElem::Index`. If that happens, we cannot unify it with + /// a place that has projections. + appears_in_index: DenseBitSet, } impl<'tcx> Visitor<'tcx> for FindAssignments<'_, 'tcx> { - fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) { - if let StatementKind::Assign(box ( - lhs, - Rvalue::Use(Operand::Copy(rhs) | Operand::Move(rhs)), - )) = &statement.kind - && let Some(src) = lhs.as_local() - && let Some(dest) = rhs.as_local() - { + fn visit_projection_elem( + &mut self, + place_ref: PlaceRef<'tcx>, + elem: PlaceElem<'tcx>, + context: PlaceContext, + location: Location, + ) { + match elem { + PlaceElem::Deref => { + self.appears_in_index.insert(place_ref.local); + } + PlaceElem::Index(local) => { + self.appears_in_index.insert(local); + } + _ => {} + } + self.super_projection_elem(place_ref, elem, context, location); + } + + fn visit_assign(&mut self, lhs: &Place<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) { + self.super_assign(lhs, rvalue, location); + + if let Rvalue::Use(Operand::Copy(rhs) | Operand::Move(rhs)) = rvalue { + let (src, dest) = + if lhs.is_indirect_first_projection() || rhs.is_indirect_first_projection() { + return; + } else if lhs.projection == rhs.projection { + (lhs.local, Place::from(rhs.local)) + } else if let Some(lhs) = lhs.as_local() { + (lhs, *rhs) + } else if let Some(rhs) = rhs.as_local() { + (rhs, *lhs) + } else { + return; + }; + + if !dest.projection.iter().all(|p| p.is_stable_offset() && p.can_use_in_debuginfo()) { + return; + } + // As described at the top of the file, we do not go near things that have // their address taken. - if self.borrowed.contains(src) || self.borrowed.contains(dest) { + if self.borrowed.contains(src) || self.borrowed.contains(dest.local) { + return; + } + + if is_within_packed(self.tcx, &self.body.local_decls, dest).is_some() { return; } // As described at the top of this file, we do not touch locals which have // different types. let src_ty = self.body.local_decls()[src].ty; - let dest_ty = self.body.local_decls()[dest].ty; + let dest_ty = dest.ty(self.body, self.tcx).ty; if src_ty != dest_ty { // FIXME(#112651): This can be removed afterwards. Also update the module description. trace!("skipped `{src:?} = {dest:?}` due to subtyping: {src_ty} != {dest_ty}"); @@ -572,10 +695,9 @@ fn save_as_intervals<'tcx>( // as marking `_b` live here would prevent unification. let is_simple_assignment = match stmt.kind { StatementKind::Assign(box ( - lhs, - Rvalue::CopyForDeref(rhs) - | Rvalue::Use(Operand::Copy(rhs) | Operand::Move(rhs)), - )) => lhs.projection == rhs.projection, + _, + Rvalue::CopyForDeref(_) | Rvalue::Use(Operand::Copy(_) | Operand::Move(_)), + )) => true, _ => false, }; VisitPlacesWith(|place: Place<'tcx>, ctxt| { diff --git a/tests/codegen-llvm/scalar-pair-bool.rs b/tests/codegen-llvm/scalar-pair-bool.rs index def3b32f71aa4..71937fc5ace67 100644 --- a/tests/codegen-llvm/scalar-pair-bool.rs +++ b/tests/codegen-llvm/scalar-pair-bool.rs @@ -20,13 +20,12 @@ pub fn pair_i32_bool(pair: (i32, bool)) -> (i32, bool) { pair } -// CHECK: define{{.*}}{ i1, i1 } @pair_and_or(i1 noundef zeroext %_1.0, i1 noundef zeroext %_1.1) +// CHECK: define{{.*}}{ i1, i1 } @pair_and_or(i1 noundef zeroext %0, i1 noundef zeroext %1) #[no_mangle] pub fn pair_and_or((a, b): (bool, bool)) -> (bool, bool) { // Make sure it can operate directly on the unpacked args - // (but it might not be using simple and/or instructions) - // CHECK-DAG: %_1.0 - // CHECK-DAG: %_1.1 + // CHECK: or i1 %0, %1 + // CHECK: and i1 %0, %1 (a && b, a || b) } diff --git a/tests/mir-opt/debuginfo/dest_prop.remap_debuginfo_locals.DestinationPropagation.diff b/tests/mir-opt/debuginfo/dest_prop.remap_debuginfo_locals.DestinationPropagation.diff index fe00da67e8bb0..a5c10b69454e3 100644 --- a/tests/mir-opt/debuginfo/dest_prop.remap_debuginfo_locals.DestinationPropagation.diff +++ b/tests/mir-opt/debuginfo/dest_prop.remap_debuginfo_locals.DestinationPropagation.diff @@ -3,7 +3,7 @@ fn remap_debuginfo_locals(_1: bool, _2: &bool) -> &bool { - debug c => _3; -+ debug c => _2; ++ debug c => _0; let mut _0: &bool; let mut _3: &bool; let mut _4: bool; @@ -14,10 +14,10 @@ - _4 = copy _1; - _3 = copy _2; - switchInt(copy _4) -> [1: bb1, otherwise: bb2]; -+ // DBG: _2 = &_1; -+ nop; ++ // DBG: _0 = &_1; + nop; + nop; ++ _0 = copy _2; + switchInt(copy _1) -> [1: bb1, otherwise: bb2]; } @@ -29,7 +29,7 @@ - StorageDead(_4); - _0 = copy _3; + nop; -+ _0 = copy _2; ++ nop; return; } } diff --git a/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-abort.diff index 0328fc6b745b2..072205208c1d6 100644 --- a/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-abort.diff @@ -8,20 +8,20 @@ let mut _3: u8; bb0: { - StorageLive(_2); -- StorageLive(_3); -- _3 = copy _1; -- _2 = dummy(move _3) -> [return: bb1, unwind unreachable]; -+ nop; +- StorageLive(_2); + nop; -+ _2 = dummy(move _1) -> [return: bb1, unwind unreachable]; + StorageLive(_3); + _3 = copy _1; +- _2 = dummy(move _3) -> [return: bb1, unwind unreachable]; ++ _1 = dummy(move _3) -> [return: bb1, unwind unreachable]; } bb1: { -- StorageDead(_3); + StorageDead(_3); +- _1 = move _2; +- StorageDead(_2); ++ nop; + nop; - _1 = move _2; - StorageDead(_2); _0 = const (); return; } diff --git a/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff index 30e2248db8205..2525593afbfb0 100644 --- a/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff @@ -8,20 +8,20 @@ let mut _3: u8; bb0: { - StorageLive(_2); -- StorageLive(_3); -- _3 = copy _1; -- _2 = dummy(move _3) -> [return: bb1, unwind continue]; -+ nop; +- StorageLive(_2); + nop; -+ _2 = dummy(move _1) -> [return: bb1, unwind continue]; + StorageLive(_3); + _3 = copy _1; +- _2 = dummy(move _3) -> [return: bb1, unwind continue]; ++ _1 = dummy(move _3) -> [return: bb1, unwind continue]; } bb1: { -- StorageDead(_3); + StorageDead(_3); +- _1 = move _2; +- StorageDead(_2); ++ nop; + nop; - _1 = move _2; - StorageDead(_2); _0 = const (); return; } diff --git a/tests/mir-opt/dest-prop/copy_propagation_arg.rs b/tests/mir-opt/dest-prop/copy_propagation_arg.rs index ef531f4afa2b7..9f1181adf1a3f 100644 --- a/tests/mir-opt/dest-prop/copy_propagation_arg.rs +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.rs @@ -10,8 +10,9 @@ fn dummy(x: u8) -> u8 { fn foo(mut x: u8) { // CHECK-LABEL: fn foo( // CHECK: debug x => [[x:_.*]]; - // CHECK: dummy(move [[x]]) - // CHECK: [[x]] = move {{_.*}}; + // CHECK: [[tmp:_.*]] = copy [[x]]; + // CHECK: [[x]] = dummy(move [[tmp]]) + // calling `dummy` to make a use of `x` that copyprop cannot eliminate x = dummy(x); // this will assign a local to `x` } diff --git a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-abort.diff index a2f10be31a9e8..eea479d89bbec 100644 --- a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-abort.diff @@ -8,23 +8,25 @@ let _5: (); let mut _6: i32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => _4; let _2: i32; scope 2 { - debug y => _2; -+ debug y => _1; ++ debug y => _4; let _3: i32; scope 3 { - debug z => _3; -+ debug z => _1; ++ debug z => _4; } } } bb0: { - StorageLive(_1); +- _1 = val() -> [return: bb1, unwind unreachable]; + nop; - _1 = val() -> [return: bb1, unwind unreachable]; ++ _4 = val() -> [return: bb1, unwind unreachable]; } bb1: { @@ -50,7 +52,7 @@ - _5 = std::mem::drop::(move _6) -> [return: bb2, unwind unreachable]; + nop; + nop; -+ _5 = std::mem::drop::(move _1) -> [return: bb2, unwind unreachable]; ++ _5 = std::mem::drop::(move _4) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff index a08488615b15a..755abee4f19fa 100644 --- a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff @@ -8,23 +8,25 @@ let _5: (); let mut _6: i32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => _4; let _2: i32; scope 2 { - debug y => _2; -+ debug y => _1; ++ debug y => _4; let _3: i32; scope 3 { - debug z => _3; -+ debug z => _1; ++ debug z => _4; } } } bb0: { - StorageLive(_1); +- _1 = val() -> [return: bb1, unwind continue]; + nop; - _1 = val() -> [return: bb1, unwind continue]; ++ _4 = val() -> [return: bb1, unwind continue]; } bb1: { @@ -50,7 +52,7 @@ - _5 = std::mem::drop::(move _6) -> [return: bb2, unwind continue]; + nop; + nop; -+ _5 = std::mem::drop::(move _1) -> [return: bb2, unwind continue]; ++ _5 = std::mem::drop::(move _4) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-abort.mir b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-abort.mir index 15061da812063..28cb868d7388e 100644 --- a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-abort.mir +++ b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-abort.mir @@ -11,12 +11,12 @@ fn f(_1: usize) -> usize { } bb0: { - nop; + StorageLive(_2); _2 = copy _1; _1 = const 5_usize; nop; + _1 = copy _2; nop; - _1 = move _2; nop; nop; nop; @@ -25,7 +25,7 @@ fn f(_1: usize) -> usize { bb1: { nop; - nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir index ddfe4dc5b3ebf..b589a198b7835 100644 --- a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir +++ b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir @@ -11,12 +11,12 @@ fn f(_1: usize) -> usize { } bb0: { - nop; + StorageLive(_2); _2 = copy _1; _1 = const 5_usize; nop; + _1 = copy _2; nop; - _1 = move _2; nop; nop; nop; @@ -25,7 +25,7 @@ fn f(_1: usize) -> usize { bb1: { nop; - nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/dest-prop/dead_stores_79191.rs b/tests/mir-opt/dest-prop/dead_stores_79191.rs index d035de5ce0765..4c5a067a244d6 100644 --- a/tests/mir-opt/dest-prop/dead_stores_79191.rs +++ b/tests/mir-opt/dest-prop/dead_stores_79191.rs @@ -12,7 +12,7 @@ fn f(mut a: usize) -> usize { // CHECK: debug b => [[b:_.*]]; // CHECK: [[b]] = copy [[a]]; // CHECK: [[a]] = const 5_usize; - // CHECK: [[a]] = move [[b]]; + // CHECK: [[a]] = copy [[b]]; // CHECK: id::(move [[a]]) let b = a; a = 5; diff --git a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-abort.mir b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-abort.mir index 15061da812063..28cb868d7388e 100644 --- a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-abort.mir +++ b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-abort.mir @@ -11,12 +11,12 @@ fn f(_1: usize) -> usize { } bb0: { - nop; + StorageLive(_2); _2 = copy _1; _1 = const 5_usize; nop; + _1 = copy _2; nop; - _1 = move _2; nop; nop; nop; @@ -25,7 +25,7 @@ fn f(_1: usize) -> usize { bb1: { nop; - nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir index ddfe4dc5b3ebf..b589a198b7835 100644 --- a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir +++ b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir @@ -11,12 +11,12 @@ fn f(_1: usize) -> usize { } bb0: { - nop; + StorageLive(_2); _2 = copy _1; _1 = const 5_usize; nop; + _1 = copy _2; nop; - _1 = move _2; nop; nop; nop; @@ -25,7 +25,7 @@ fn f(_1: usize) -> usize { bb1: { nop; - nop; + StorageDead(_2); return; } } diff --git a/tests/mir-opt/dest-prop/dead_stores_better.rs b/tests/mir-opt/dest-prop/dead_stores_better.rs index d4c297fd97a38..6c7d88e6836af 100644 --- a/tests/mir-opt/dest-prop/dead_stores_better.rs +++ b/tests/mir-opt/dest-prop/dead_stores_better.rs @@ -16,7 +16,7 @@ pub fn f(mut a: usize) -> usize { // CHECK: debug b => [[b:_.*]]; // CHECK: [[b]] = copy [[a]]; // CHECK: [[a]] = const 5_usize; - // CHECK: [[a]] = move [[b]]; + // CHECK: [[a]] = copy [[b]]; // CHECK: id::(move [[a]]) let b = a; a = 5; 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 bb10fc8ac642d..97afdfbb5e718 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 @@ -9,8 +9,8 @@ let mut _6: *const (); let mut _8: *const [()]; let mut _9: *const (); - let mut _22: usize; - let mut _23: std::ptr::NonNull<()>; + let mut _21: usize; + let mut _22: std::ptr::NonNull<()>; scope 1 { debug vp_ctx => _1; let _4: *const (); @@ -40,14 +40,13 @@ let _13: std::alloc::Layout; let mut _14: std::result::Result, std::alloc::AllocError>; let mut _15: isize; - let mut _17: !; + let mut _16: !; scope 7 { - let _16: 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::) { - let mut _21: *mut [u8]; + let mut _20: *mut [u8]; scope 14 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -60,9 +59,9 @@ } } scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let mut _18: bool; - let _19: (); - let mut _20: std::ptr::Alignment; + let mut _17: bool; + let _18: (); + let mut _19: std::ptr::Alignment; } } } @@ -79,11 +78,11 @@ + _10 = const 0_usize; + _11 = const 1_usize; StorageLive(_13); + StorageLive(_14); StorageLive(_15); - StorageLive(_16); - StorageLive(_18); - _18 = const false; -- switchInt(move _18) -> [0: bb6, otherwise: bb5]; + StorageLive(_17); + _17 = const false; +- switchInt(move _17) -> [0: bb6, otherwise: bb5]; + switchInt(const false) -> [0: bb6, otherwise: bb5]; } @@ -98,19 +97,17 @@ } bb3: { -- _17 = handle_alloc_error(move _13) -> unwind unreachable; -+ _17 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable; +- _16 = handle_alloc_error(move _13) -> unwind unreachable; ++ _16 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable; } bb4: { - _16 = copy ((_14 as Ok).0: std::ptr::NonNull<[u8]>); - StorageLive(_21); - _21 = copy _16 as *mut [u8] (Transmute); - _12 = copy _21 as *mut u8 (PtrToPtr); - StorageDead(_21); - StorageDead(_14); - StorageDead(_16); + StorageLive(_20); + _20 = copy ((_14 as Ok).0: std::ptr::NonNull<[u8]>) as *mut [u8] (Transmute); + _12 = copy _20 as *mut u8 (PtrToPtr); + StorageDead(_20); StorageDead(_15); + StorageDead(_14); StorageDead(_13); _3 = ShallowInitBox(copy _12, ()); StorageDead(_12); @@ -120,25 +117,25 @@ _1 = copy _2; StorageDead(_2); StorageLive(_4); - _23 = copy ((_3.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>); - _9 = copy _23 as *const () (Transmute); + _22 = copy ((_3.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>); + _9 = copy _22 as *const () (Transmute); _4 = copy _9; - StorageLive(_5); + nop; StorageLive(_6); - _6 = copy _4; + _6 = copy _9; - StorageLive(_22); - _22 = const 1_usize; -- _5 = *const [()] from (copy _6, copy _22); + StorageLive(_21); + _21 = const 1_usize; +- _5 = *const [()] from (copy _6, copy _21); + _5 = *const [()] from (copy _9, const 1_usize); - StorageDead(_22); + StorageDead(_21); StorageDead(_6); StorageLive(_7); StorageLive(_8); _8 = copy _5; - _7 = copy _8 as *mut () (PtrToPtr); -+ _7 = copy _23 as *mut () (Transmute); ++ _7 = copy _22 as *mut () (Transmute); StorageDead(_8); StorageDead(_7); - StorageDead(_5); @@ -148,19 +145,18 @@ } bb5: { -- _19 = Layout::from_size_align_unchecked::precondition_check(copy _10, copy _11) -> [return: bb6, unwind unreachable]; -+ _19 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _18 = Layout::from_size_align_unchecked::precondition_check(copy _10, copy _11) -> [return: bb6, unwind unreachable]; ++ _18 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_18); - StorageLive(_20); -- _20 = copy _11 as std::ptr::Alignment (Transmute); -- _13 = Layout { size: copy _10, align: move _20 }; -+ _20 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + StorageDead(_17); + StorageLive(_19); +- _19 = copy _11 as std::ptr::Alignment (Transmute); +- _13 = Layout { size: copy _10, align: move _19 }; ++ _19 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + _13 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; - StorageDead(_20); - StorageLive(_14); + StorageDead(_19); - _14 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _13, const false) -> [return: bb7, unwind unreachable]; + _14 = 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]; } 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 97b7c9a1d5584..05da14f72e941 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 @@ -9,8 +9,8 @@ let mut _6: *const (); let mut _8: *const [()]; let mut _9: *const (); - let mut _22: usize; - let mut _23: std::ptr::NonNull<()>; + let mut _21: usize; + let mut _22: std::ptr::NonNull<()>; scope 1 { debug vp_ctx => _1; let _4: *const (); @@ -40,14 +40,13 @@ let _13: std::alloc::Layout; let mut _14: std::result::Result, std::alloc::AllocError>; let mut _15: isize; - let mut _17: !; + let mut _16: !; scope 7 { - let _16: 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::) { - let mut _21: *mut [u8]; + let mut _20: *mut [u8]; scope 14 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -60,9 +59,9 @@ } } scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let mut _18: bool; - let _19: (); - let mut _20: std::ptr::Alignment; + let mut _17: bool; + let _18: (); + let mut _19: std::ptr::Alignment; } } } @@ -79,11 +78,11 @@ + _10 = const 0_usize; + _11 = const 1_usize; StorageLive(_13); + StorageLive(_14); StorageLive(_15); - StorageLive(_16); - StorageLive(_18); - _18 = const false; -- switchInt(move _18) -> [0: bb6, otherwise: bb5]; + StorageLive(_17); + _17 = const false; +- switchInt(move _17) -> [0: bb6, otherwise: bb5]; + switchInt(const false) -> [0: bb6, otherwise: bb5]; } @@ -98,19 +97,17 @@ } bb3: { -- _17 = handle_alloc_error(move _13) -> unwind unreachable; -+ _17 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable; +- _16 = handle_alloc_error(move _13) -> unwind unreachable; ++ _16 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable; } bb4: { - _16 = copy ((_14 as Ok).0: std::ptr::NonNull<[u8]>); - StorageLive(_21); - _21 = copy _16 as *mut [u8] (Transmute); - _12 = copy _21 as *mut u8 (PtrToPtr); - StorageDead(_21); - StorageDead(_14); - StorageDead(_16); + StorageLive(_20); + _20 = copy ((_14 as Ok).0: std::ptr::NonNull<[u8]>) as *mut [u8] (Transmute); + _12 = copy _20 as *mut u8 (PtrToPtr); + StorageDead(_20); StorageDead(_15); + StorageDead(_14); StorageDead(_13); _3 = ShallowInitBox(copy _12, ()); StorageDead(_12); @@ -120,25 +117,25 @@ _1 = copy _2; StorageDead(_2); StorageLive(_4); - _23 = copy ((_3.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>); - _9 = copy _23 as *const () (Transmute); + _22 = copy ((_3.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>); + _9 = copy _22 as *const () (Transmute); _4 = copy _9; - StorageLive(_5); + nop; StorageLive(_6); - _6 = copy _4; + _6 = copy _9; - StorageLive(_22); - _22 = const 1_usize; -- _5 = *const [()] from (copy _6, copy _22); + StorageLive(_21); + _21 = const 1_usize; +- _5 = *const [()] from (copy _6, copy _21); + _5 = *const [()] from (copy _9, const 1_usize); - StorageDead(_22); + StorageDead(_21); StorageDead(_6); StorageLive(_7); StorageLive(_8); _8 = copy _5; - _7 = copy _8 as *mut () (PtrToPtr); -+ _7 = copy _23 as *mut () (Transmute); ++ _7 = copy _22 as *mut () (Transmute); StorageDead(_8); StorageDead(_7); - StorageDead(_5); @@ -148,19 +145,18 @@ } bb5: { -- _19 = Layout::from_size_align_unchecked::precondition_check(copy _10, copy _11) -> [return: bb6, unwind unreachable]; -+ _19 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _18 = Layout::from_size_align_unchecked::precondition_check(copy _10, copy _11) -> [return: bb6, unwind unreachable]; ++ _18 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_18); - StorageLive(_20); -- _20 = copy _11 as std::ptr::Alignment (Transmute); -- _13 = Layout { size: copy _10, align: move _20 }; -+ _20 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + StorageDead(_17); + StorageLive(_19); +- _19 = copy _11 as std::ptr::Alignment (Transmute); +- _13 = Layout { size: copy _10, align: move _19 }; ++ _19 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + _13 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; - StorageDead(_20); - StorageLive(_14); + StorageDead(_19); - _14 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _13, const false) -> [return: bb7, unwind unreachable]; + _14 = 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]; } diff --git a/tests/mir-opt/gvn_copy_constant_projection.rs b/tests/mir-opt/gvn_copy_constant_projection.rs index a08ae0ac7c976..bb05961b2db37 100644 --- a/tests/mir-opt/gvn_copy_constant_projection.rs +++ b/tests/mir-opt/gvn_copy_constant_projection.rs @@ -3,11 +3,8 @@ use std::cmp::Ordering; fn compare_constant_index(x: [i32; 1], y: [i32; 1]) -> Ordering { // CHECK-LABEL: fn compare_constant_index( - // CHECK-NOT: (*{{_.*}}); - // CHECK: [[lhs:_.*]] = copy _1[0 of 1]; - // CHECK-NOT: (*{{_.*}}); - // CHECK: [[rhs:_.*]] = copy _2[0 of 1]; - // CHECK: _0 = Cmp(move [[lhs]], move [[rhs]]); + // CHECK: bb0: { + // CHECK-NEXT: _0 = Cmp(move _1[0 of 1], move _2[0 of 1]); Ord::cmp(&x[0], &y[0]) } diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff index 4ca8dbbc76f07..dd70d8178a647 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff @@ -57,30 +57,29 @@ + scope 12 (inlined Pin::<&mut std::future::Ready<()>>::new_unchecked) { + } + scope 13 (inlined as Future>::poll) { -+ let mut _41: (); -+ let mut _42: std::option::Option<()>; -+ let mut _43: &mut std::option::Option<()>; -+ let mut _44: &mut std::future::Ready<()>; -+ let mut _45: &mut std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _41: std::option::Option<()>; ++ let mut _42: &mut std::option::Option<()>; ++ let mut _43: &mut std::future::Ready<()>; ++ let mut _44: &mut std::pin::Pin<&mut std::future::Ready<()>>; + scope 14 (inlined > as DerefMut>::deref_mut) { -+ let mut _46: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>; -+ let mut _47: *mut std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _45: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>; ++ let mut _46: *mut std::pin::Pin<&mut std::future::Ready<()>>; + scope 15 (inlined > as pin::helper::PinDerefMutHelper>::deref_mut) { -+ let mut _48: &mut &mut std::future::Ready<()>; ++ let mut _47: &mut &mut std::future::Ready<()>; + scope 16 (inlined <&mut std::future::Ready<()> as DerefMut>::deref_mut) { + } + } + } + scope 17 (inlined Option::<()>::take) { -+ let mut _49: std::option::Option<()>; ++ let mut _48: std::option::Option<()>; + scope 18 (inlined std::mem::replace::>) { + scope 19 { + } + } + } + scope 20 (inlined #[track_caller] Option::<()>::expect) { -+ let mut _50: isize; -+ let mut _51: !; ++ let mut _49: isize; ++ let mut _50: !; + scope 21 { + } + } @@ -214,24 +213,23 @@ + _23 = move _24; + _22 = &mut (*_23); + StorageDead(_24); -+ StorageLive(_44); -+ StorageLive(_46); -+ StorageLive(_51); + StorageLive(_41); -+ StorageLive(_42); -+ StorageLive(_47); -+ _47 = &raw mut _19; -+ _46 = copy _47 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); -+ StorageDead(_47); -+ _44 = copy ((*_46).0: &mut std::future::Ready<()>); -+ StorageLive(_49); -+ _49 = Option::<()>::None; -+ _42 = copy ((*_44).0: std::option::Option<()>); -+ ((*_44).0: std::option::Option<()>) = copy _49; -+ StorageDead(_49); ++ StorageLive(_43); ++ StorageLive(_45); + StorageLive(_50); -+ _50 = discriminant(_42); -+ switchInt(move _50) -> [0: bb11, 1: bb12, otherwise: bb5]; ++ StorageLive(_46); ++ _46 = &raw mut _19; ++ _45 = copy _46 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); ++ StorageDead(_46); ++ _43 = copy ((*_45).0: &mut std::future::Ready<()>); ++ StorageLive(_48); ++ _48 = Option::<()>::None; ++ _41 = copy ((*_43).0: std::option::Option<()>); ++ ((*_43).0: std::option::Option<()>) = copy _48; ++ StorageDead(_48); ++ StorageLive(_49); ++ _49 = discriminant(_41); ++ switchInt(move _49) -> [0: bb11, 1: bb12, otherwise: bb5]; } + + bb5: { @@ -294,18 +292,16 @@ + } + + bb11: { -+ _51 = option::expect_failed(const "`Ready` polled after completion") -> unwind unreachable; ++ _50 = option::expect_failed(const "`Ready` polled after completion") -> unwind unreachable; + } + + bb12: { -+ _41 = move ((_42 as Some).0: ()); ++ StorageDead(_49); ++ _18 = Poll::<()>::Ready(move ((_41 as Some).0: ())); + StorageDead(_50); -+ StorageDead(_42); -+ _18 = Poll::<()>::Ready(move _41); ++ StorageDead(_45); ++ StorageDead(_43); + StorageDead(_41); -+ StorageDead(_51); -+ StorageDead(_46); -+ StorageDead(_44); + StorageDead(_22); + StorageDead(_19); + _25 = discriminant(_18); diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff index 6ce8693007b92..634e014fb5be7 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff @@ -59,30 +59,29 @@ + scope 12 (inlined Pin::<&mut std::future::Ready<()>>::new_unchecked) { + } + scope 13 (inlined as Future>::poll) { -+ let mut _43: (); -+ let mut _44: std::option::Option<()>; -+ let mut _45: &mut std::option::Option<()>; -+ let mut _46: &mut std::future::Ready<()>; -+ let mut _47: &mut std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _43: std::option::Option<()>; ++ let mut _44: &mut std::option::Option<()>; ++ let mut _45: &mut std::future::Ready<()>; ++ let mut _46: &mut std::pin::Pin<&mut std::future::Ready<()>>; + scope 14 (inlined > as DerefMut>::deref_mut) { -+ let mut _48: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>; -+ let mut _49: *mut std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _47: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>; ++ let mut _48: *mut std::pin::Pin<&mut std::future::Ready<()>>; + scope 15 (inlined > as pin::helper::PinDerefMutHelper>::deref_mut) { -+ let mut _50: &mut &mut std::future::Ready<()>; ++ let mut _49: &mut &mut std::future::Ready<()>; + scope 16 (inlined <&mut std::future::Ready<()> as DerefMut>::deref_mut) { + } + } + } + scope 17 (inlined Option::<()>::take) { -+ let mut _51: std::option::Option<()>; ++ let mut _50: std::option::Option<()>; + scope 18 (inlined std::mem::replace::>) { + scope 19 { + } + } + } + scope 20 (inlined #[track_caller] Option::<()>::expect) { -+ let mut _52: isize; -+ let mut _53: !; ++ let mut _51: isize; ++ let mut _52: !; + scope 21 { + } + } @@ -231,24 +230,23 @@ + _23 = move _24; + _22 = &mut (*_23); + StorageDead(_24); -+ StorageLive(_46); -+ StorageLive(_48); -+ StorageLive(_53); + StorageLive(_43); -+ StorageLive(_44); -+ StorageLive(_49); -+ _49 = &raw mut _19; -+ _48 = copy _49 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); -+ StorageDead(_49); -+ _46 = copy ((*_48).0: &mut std::future::Ready<()>); -+ StorageLive(_51); -+ _51 = Option::<()>::None; -+ _44 = copy ((*_46).0: std::option::Option<()>); -+ ((*_46).0: std::option::Option<()>) = copy _51; -+ StorageDead(_51); ++ StorageLive(_45); ++ StorageLive(_47); + StorageLive(_52); -+ _52 = discriminant(_44); -+ switchInt(move _52) -> [0: bb16, 1: bb17, otherwise: bb7]; ++ StorageLive(_48); ++ _48 = &raw mut _19; ++ _47 = copy _48 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); ++ StorageDead(_48); ++ _45 = copy ((*_47).0: &mut std::future::Ready<()>); ++ StorageLive(_50); ++ _50 = Option::<()>::None; ++ _43 = copy ((*_45).0: std::option::Option<()>); ++ ((*_45).0: std::option::Option<()>) = copy _50; ++ StorageDead(_50); ++ StorageLive(_51); ++ _51 = discriminant(_43); ++ switchInt(move _51) -> [0: bb16, 1: bb17, otherwise: bb7]; } - bb6 (cleanup): { @@ -335,18 +333,16 @@ + } + + bb16: { -+ _53 = option::expect_failed(const "`Ready` polled after completion") -> bb11; ++ _52 = option::expect_failed(const "`Ready` polled after completion") -> bb11; + } + + bb17: { -+ _43 = move ((_44 as Some).0: ()); ++ StorageDead(_51); ++ _18 = Poll::<()>::Ready(move ((_43 as Some).0: ())); + StorageDead(_52); -+ StorageDead(_44); -+ _18 = Poll::<()>::Ready(move _43); ++ StorageDead(_47); ++ StorageDead(_45); + StorageDead(_43); -+ StorageDead(_53); -+ StorageDead(_48); -+ StorageDead(_46); + StorageDead(_22); + StorageDead(_19); + _25 = discriminant(_18); diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff index 79599f856115d..4e1dd31a4287c 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff @@ -12,12 +12,12 @@ let mut _7: !; let mut _8: std::result::Result; let _9: i32; + let mut _13: i32; scope 1 { debug residual => _6; scope 2 { scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { - let _14: i32; - let mut _15: i32; + let mut _12: i32; scope 9 { scope 10 (inlined >::from) { } @@ -32,9 +32,7 @@ } scope 5 (inlined as Try>::branch) { let mut _10: isize; - let _11: i32; - let _12: i32; - let mut _13: std::result::Result; + let mut _11: std::result::Result; scope 6 { } scope 7 { @@ -47,8 +45,6 @@ StorageLive(_4); _4 = copy _1; StorageLive(_10); - StorageLive(_11); - StorageLive(_12); _10 = discriminant(_4); switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb1]; } @@ -73,13 +69,13 @@ _6 = copy ((_3 as Break).0: std::result::Result); StorageLive(_8); _8 = copy _6; - StorageLive(_14); - _14 = move ((_8 as Err).0: i32); - StorageLive(_15); - _15 = move _14; - _0 = Result::::Err(move _15); - StorageDead(_15); - StorageDead(_14); + StorageLive(_12); + StorageLive(_13); + _13 = move ((_8 as Err).0: i32); + _12 = move _13; + StorageDead(_13); + _0 = Result::::Err(move _12); + StorageDead(_12); StorageDead(_8); StorageDead(_6); StorageDead(_2); @@ -92,8 +88,6 @@ } bb5: { - StorageDead(_12); - StorageDead(_11); StorageDead(_10); StorageDead(_4); _5 = discriminant(_3); @@ -102,24 +96,20 @@ } bb6: { - _12 = move ((_4 as Err).0: i32); - StorageLive(_13); - _13 = Result::::Err(copy _12); - _3 = ControlFlow::, i32>::Break(move _13); - StorageDead(_13); + StorageLive(_11); + _11 = Result::::Err(copy ((_4 as Err).0: i32)); + _3 = ControlFlow::, i32>::Break(move _11); + StorageDead(_11); - goto -> bb5; + goto -> bb8; } bb7: { - _11 = move ((_4 as Ok).0: i32); - _3 = ControlFlow::, i32>::Continue(copy _11); + _3 = ControlFlow::, i32>::Continue(copy ((_4 as Ok).0: i32)); goto -> bb5; + } + + bb8: { -+ StorageDead(_12); -+ StorageDead(_11); + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff index 79599f856115d..4e1dd31a4287c 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff @@ -12,12 +12,12 @@ let mut _7: !; let mut _8: std::result::Result; let _9: i32; + let mut _13: i32; scope 1 { debug residual => _6; scope 2 { scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { - let _14: i32; - let mut _15: i32; + let mut _12: i32; scope 9 { scope 10 (inlined >::from) { } @@ -32,9 +32,7 @@ } scope 5 (inlined as Try>::branch) { let mut _10: isize; - let _11: i32; - let _12: i32; - let mut _13: std::result::Result; + let mut _11: std::result::Result; scope 6 { } scope 7 { @@ -47,8 +45,6 @@ StorageLive(_4); _4 = copy _1; StorageLive(_10); - StorageLive(_11); - StorageLive(_12); _10 = discriminant(_4); switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb1]; } @@ -73,13 +69,13 @@ _6 = copy ((_3 as Break).0: std::result::Result); StorageLive(_8); _8 = copy _6; - StorageLive(_14); - _14 = move ((_8 as Err).0: i32); - StorageLive(_15); - _15 = move _14; - _0 = Result::::Err(move _15); - StorageDead(_15); - StorageDead(_14); + StorageLive(_12); + StorageLive(_13); + _13 = move ((_8 as Err).0: i32); + _12 = move _13; + StorageDead(_13); + _0 = Result::::Err(move _12); + StorageDead(_12); StorageDead(_8); StorageDead(_6); StorageDead(_2); @@ -92,8 +88,6 @@ } bb5: { - StorageDead(_12); - StorageDead(_11); StorageDead(_10); StorageDead(_4); _5 = discriminant(_3); @@ -102,24 +96,20 @@ } bb6: { - _12 = move ((_4 as Err).0: i32); - StorageLive(_13); - _13 = Result::::Err(copy _12); - _3 = ControlFlow::, i32>::Break(move _13); - StorageDead(_13); + StorageLive(_11); + _11 = Result::::Err(copy ((_4 as Err).0: i32)); + _3 = ControlFlow::, i32>::Break(move _11); + StorageDead(_11); - goto -> bb5; + goto -> bb8; } bb7: { - _11 = move ((_4 as Ok).0: i32); - _3 = ControlFlow::, i32>::Continue(copy _11); + _3 = ControlFlow::, i32>::Continue(copy ((_4 as Ok).0: i32)); goto -> bb5; + } + + bb8: { -+ StorageDead(_12); -+ StorageDead(_11); + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs index 009e1060700c1..fc0f2d92805cb 100644 --- a/tests/mir-opt/jump_threading.rs +++ b/tests/mir-opt/jump_threading.rs @@ -65,12 +65,11 @@ fn identity(x: Result) -> Result { // CHECK: bb5: { // CHECK: goto -> bb2; // CHECK: bb6: { - // CHECK: {{_.*}} = move (([[x]] as Err).0: i32); - // CHECK: [[controlflow]] = ControlFlow::, i32>::Break( + // CHECK: [[tmperr:_.*]] = Result::::Err(copy (([[x]] as Err).0: i32)); + // CHECK: [[controlflow]] = ControlFlow::, i32>::Break(move [[tmperr]]); // CHECK: goto -> bb8; // CHECK: bb7: { - // CHECK: {{_.*}} = move (([[x]] as Ok).0: i32); - // CHECK: [[controlflow]] = ControlFlow::, i32>::Continue( + // CHECK: [[controlflow]] = ControlFlow::, i32>::Continue(copy (([[x]] as Ok).0: i32)); // CHECK: goto -> bb5; // CHECK: bb8: { // CHECK: goto -> bb3; diff --git a/tests/mir-opt/pre-codegen/checked_ops.rs b/tests/mir-opt/pre-codegen/checked_ops.rs index dfbc0f4a1108d..ea5111f471718 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.rs +++ b/tests/mir-opt/pre-codegen/checked_ops.rs @@ -30,8 +30,7 @@ pub fn use_checked_sub(x: u32, rhs: u32) { // CHECK: inlined{{.+}}u32{{.+}}checked_sub // CHECK: [[DELTA:_[0-9]+]] = SubUnchecked(copy _1, copy _2) // CHECK: [[TEMP1:_.+]] = Option::::Some(move [[DELTA]]); - // CHECK: [[TEMP2:_.+]] = {{move|copy}} (([[TEMP1]] as Some).0: u32); - // CHECK: do_something({{move|copy}} [[TEMP2]]) + // CHECK: do_something(move (([[TEMP1]] as Some).0: u32)) if let Some(delta) = x.checked_sub(rhs) { do_something(delta); } diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir index 83478e60b5d4e..f2d1af8499310 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir @@ -5,16 +5,15 @@ fn step_forward(_1: u16, _2: usize) -> u16 { debug n => _2; let mut _0: u16; scope 1 (inlined ::forward) { - let mut _8: u16; + let mut _7: u16; scope 2 { } scope 3 (inlined ::forward_checked) { scope 4 { scope 6 (inlined core::num::::checked_add) { let mut _5: (u16, bool); - let mut _6: bool; scope 7 (inlined std::intrinsics::unlikely) { - let _7: (); + let _6: (); } } } @@ -43,26 +42,22 @@ fn step_forward(_1: u16, _2: usize) -> u16 { bb1: { _4 = copy _2 as u16 (IntToInt); StorageDead(_3); - StorageLive(_6); StorageLive(_5); _5 = AddWithOverflow(copy _1, copy _4); - _6 = copy (_5.1: bool); - switchInt(copy _6) -> [0: bb2, otherwise: bb3]; + switchInt(copy (_5.1: bool)) -> [0: bb2, otherwise: bb3]; } bb2: { StorageDead(_5); - StorageDead(_6); goto -> bb7; } bb3: { - _7 = std::intrinsics::cold_path() -> [return: bb4, unwind unreachable]; + _6 = std::intrinsics::cold_path() -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_5); - StorageDead(_6); goto -> bb6; } @@ -76,10 +71,10 @@ fn step_forward(_1: u16, _2: usize) -> u16 { } bb7: { - StorageLive(_8); - _8 = copy _2 as u16 (IntToInt); - _0 = Add(copy _1, copy _8); - StorageDead(_8); + StorageLive(_7); + _7 = copy _2 as u16 (IntToInt); + _0 = Add(copy _1, copy _7); + StorageDead(_7); StorageDead(_4); return; } diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir index ac7a6e0445191..4dd097a56a32d 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir @@ -5,16 +5,15 @@ fn step_forward(_1: u16, _2: usize) -> u16 { debug n => _2; let mut _0: u16; scope 1 (inlined ::forward) { - let mut _8: u16; + let mut _7: u16; scope 2 { } scope 3 (inlined ::forward_checked) { scope 4 { scope 6 (inlined core::num::::checked_add) { let mut _5: (u16, bool); - let mut _6: bool; scope 7 (inlined std::intrinsics::unlikely) { - let _7: (); + let _6: (); } } } @@ -43,26 +42,22 @@ fn step_forward(_1: u16, _2: usize) -> u16 { bb1: { _4 = copy _2 as u16 (IntToInt); StorageDead(_3); - StorageLive(_6); StorageLive(_5); _5 = AddWithOverflow(copy _1, copy _4); - _6 = copy (_5.1: bool); - switchInt(copy _6) -> [0: bb2, otherwise: bb3]; + switchInt(copy (_5.1: bool)) -> [0: bb2, otherwise: bb3]; } bb2: { StorageDead(_5); - StorageDead(_6); goto -> bb7; } bb3: { - _7 = std::intrinsics::cold_path() -> [return: bb4, unwind unreachable]; + _6 = std::intrinsics::cold_path() -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_5); - StorageDead(_6); goto -> bb6; } @@ -76,10 +71,10 @@ fn step_forward(_1: u16, _2: usize) -> u16 { } bb7: { - StorageLive(_8); - _8 = copy _2 as u16 (IntToInt); - _0 = Add(copy _1, copy _8); - StorageDead(_8); + StorageLive(_7); + _7 = copy _2 as u16 (IntToInt); + _0 = Add(copy _1, copy _7); + StorageDead(_7); StorageDead(_4); 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..df97042ea4e89 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 @@ -5,10 +5,9 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { debug rhs => _2; let mut _0: (); let mut _5: std::option::Option; - let _7: (); + let _6: (); scope 1 { - debug delta => _6; - let _6: u32; + debug delta => ((_5 as Some).0: u32); scope 2 (inlined core::num::::checked_sub) { let mut _3: bool; let mut _4: u32; @@ -16,7 +15,6 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { } bb0: { - StorageLive(_5); StorageLive(_3); _3 = Lt(copy _1, copy _2); switchInt(move _3) -> [0: bb1, otherwise: bb2]; @@ -28,8 +26,7 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { _5 = Option::::Some(move _4); StorageDead(_4); StorageDead(_3); - _6 = copy ((_5 as Some).0: u32); - _7 = do_something(move _6) -> [return: bb3, unwind unreachable]; + _6 = do_something(move ((_5 as Some).0: u32)) -> [return: bb3, unwind unreachable]; } bb2: { @@ -38,7 +35,6 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { } bb3: { - 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..85e2d6e18684d 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 @@ -5,10 +5,9 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { debug rhs => _2; let mut _0: (); let mut _5: std::option::Option; - let _7: (); + let _6: (); scope 1 { - debug delta => _6; - let _6: u32; + debug delta => ((_5 as Some).0: u32); scope 2 (inlined core::num::::checked_sub) { let mut _3: bool; let mut _4: u32; @@ -16,7 +15,6 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { } bb0: { - StorageLive(_5); StorageLive(_3); _3 = Lt(copy _1, copy _2); switchInt(move _3) -> [0: bb1, otherwise: bb2]; @@ -28,8 +26,7 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { _5 = Option::::Some(move _4); StorageDead(_4); StorageDead(_3); - _6 = copy ((_5 as Some).0: u32); - _7 = do_something(move _6) -> [return: bb3, unwind continue]; + _6 = do_something(move ((_5 as Some).0: u32)) -> [return: bb3, unwind continue]; } bb2: { @@ -38,7 +35,6 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { } bb3: { - StorageDead(_5); 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 e235fa35c0238..612ceb07de35a 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 @@ -8,11 +8,10 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool { let mut _6: std::option::Option; scope 2 (inlined Option::::is_some_and:: bool {std::cmp::Ordering::is_le}>) { let mut _11: isize; - let _12: std::cmp::Ordering; scope 3 { scope 4 (inlined bool {std::cmp::Ordering::is_le} as FnOnce<(std::cmp::Ordering,)>>::call_once - shim(fn(std::cmp::Ordering) -> bool {std::cmp::Ordering::is_le})) { scope 5 (inlined std::cmp::Ordering::is_le) { - let mut _13: i8; + let mut _12: i8; scope 6 (inlined std::cmp::Ordering::as_raw) { } } @@ -37,7 +36,6 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool { } bb0: { - StorageLive(_12); StorageLive(_6); StorageLive(_5); StorageLive(_7); @@ -84,18 +82,16 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool { } bb4: { - _12 = move ((_6 as Some).0: std::cmp::Ordering); - StorageLive(_13); - _13 = discriminant(_12); - _0 = Le(move _13, const 0_i8); - StorageDead(_13); + StorageLive(_12); + _12 = discriminant(((_6 as Some).0: std::cmp::Ordering)); + _0 = Le(move _12, const 0_i8); + StorageDead(_12); goto -> bb5; } bb5: { StorageDead(_11); StorageDead(_6); - StorageDead(_12); 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 ba6ce0ee5286f..50efbb26b10fd 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 @@ -8,9 +8,8 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _11: (); + let _10: (); scope 3 { - let _8: std::ptr::alignment::AlignmentEnum; scope 4 { scope 12 (inlined Layout::size) { } @@ -25,13 +24,13 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } } scope 18 (inlined ::deallocate) { - let mut _9: *mut u8; + let mut _8: *mut u8; scope 19 (inlined Layout::size) { } scope 20 (inlined NonNull::::as_ptr) { } scope 21 (inlined std::alloc::dealloc) { - let mut _10: usize; + let mut _9: usize; scope 22 (inlined Layout::size) { } scope 23 (inlined Layout::align) { @@ -74,26 +73,23 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb1: { _6 = AlignOf(T); - StorageLive(_7); _7 = copy _6 as std::ptr::Alignment (Transmute); - _8 = move (_7.0: std::ptr::alignment::AlignmentEnum); - StorageDead(_7); StorageDead(_6); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageLive(_8); + _8 = copy _3 as *mut u8 (PtrToPtr); StorageLive(_9); - _9 = copy _3 as *mut u8 (PtrToPtr); - StorageLive(_10); - _10 = discriminant(_8); - _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable]; + _9 = discriminant((_7.0: std::ptr::alignment::AlignmentEnum)); + _10 = alloc::alloc::__rust_dealloc(move _8, move _5, move _9) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_10); StorageDead(_9); + StorageDead(_8); goto -> bb4; } 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 ba6ce0ee5286f..50efbb26b10fd 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 @@ -8,9 +8,8 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _11: (); + let _10: (); scope 3 { - let _8: std::ptr::alignment::AlignmentEnum; scope 4 { scope 12 (inlined Layout::size) { } @@ -25,13 +24,13 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } } scope 18 (inlined ::deallocate) { - let mut _9: *mut u8; + let mut _8: *mut u8; scope 19 (inlined Layout::size) { } scope 20 (inlined NonNull::::as_ptr) { } scope 21 (inlined std::alloc::dealloc) { - let mut _10: usize; + let mut _9: usize; scope 22 (inlined Layout::size) { } scope 23 (inlined Layout::align) { @@ -74,26 +73,23 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb1: { _6 = AlignOf(T); - StorageLive(_7); _7 = copy _6 as std::ptr::Alignment (Transmute); - _8 = move (_7.0: std::ptr::alignment::AlignmentEnum); - StorageDead(_7); StorageDead(_6); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageLive(_8); + _8 = copy _3 as *mut u8 (PtrToPtr); StorageLive(_9); - _9 = copy _3 as *mut u8 (PtrToPtr); - StorageLive(_10); - _10 = discriminant(_8); - _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable]; + _9 = discriminant((_7.0: std::ptr::alignment::AlignmentEnum)); + _10 = alloc::alloc::__rust_dealloc(move _8, move _5, move _9) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_10); StorageDead(_9); + StorageDead(_8); goto -> bb4; } 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 ba6ce0ee5286f..50efbb26b10fd 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 @@ -8,9 +8,8 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _11: (); + let _10: (); scope 3 { - let _8: std::ptr::alignment::AlignmentEnum; scope 4 { scope 12 (inlined Layout::size) { } @@ -25,13 +24,13 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } } scope 18 (inlined ::deallocate) { - let mut _9: *mut u8; + let mut _8: *mut u8; scope 19 (inlined Layout::size) { } scope 20 (inlined NonNull::::as_ptr) { } scope 21 (inlined std::alloc::dealloc) { - let mut _10: usize; + let mut _9: usize; scope 22 (inlined Layout::size) { } scope 23 (inlined Layout::align) { @@ -74,26 +73,23 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb1: { _6 = AlignOf(T); - StorageLive(_7); _7 = copy _6 as std::ptr::Alignment (Transmute); - _8 = move (_7.0: std::ptr::alignment::AlignmentEnum); - StorageDead(_7); StorageDead(_6); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageLive(_8); + _8 = copy _3 as *mut u8 (PtrToPtr); StorageLive(_9); - _9 = copy _3 as *mut u8 (PtrToPtr); - StorageLive(_10); - _10 = discriminant(_8); - _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable]; + _9 = discriminant((_7.0: std::ptr::alignment::AlignmentEnum)); + _10 = alloc::alloc::__rust_dealloc(move _8, move _5, move _9) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_10); StorageDead(_9); + StorageDead(_8); goto -> bb4; } 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 ba6ce0ee5286f..50efbb26b10fd 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 @@ -8,9 +8,8 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _11: (); + let _10: (); scope 3 { - let _8: std::ptr::alignment::AlignmentEnum; scope 4 { scope 12 (inlined Layout::size) { } @@ -25,13 +24,13 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } } scope 18 (inlined ::deallocate) { - let mut _9: *mut u8; + let mut _8: *mut u8; scope 19 (inlined Layout::size) { } scope 20 (inlined NonNull::::as_ptr) { } scope 21 (inlined std::alloc::dealloc) { - let mut _10: usize; + let mut _9: usize; scope 22 (inlined Layout::size) { } scope 23 (inlined Layout::align) { @@ -74,26 +73,23 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb1: { _6 = AlignOf(T); - StorageLive(_7); _7 = copy _6 as std::ptr::Alignment (Transmute); - _8 = move (_7.0: std::ptr::alignment::AlignmentEnum); - StorageDead(_7); StorageDead(_6); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageLive(_8); + _8 = copy _3 as *mut u8 (PtrToPtr); StorageLive(_9); - _9 = copy _3 as *mut u8 (PtrToPtr); - StorageLive(_10); - _10 = discriminant(_8); - _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable]; + _9 = discriminant((_7.0: std::ptr::alignment::AlignmentEnum)); + _10 = alloc::alloc::__rust_dealloc(move _8, move _5, move _9) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_10); StorageDead(_9); + StorageDead(_8); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs index 9ceba9444b8da..f2bed65cd1c68 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs @@ -11,8 +11,7 @@ pub unsafe fn generic_in_place(ptr: *mut Box<[T]>) { // CHECK: [[SIZE:_.+]] = std::intrinsics::size_of_val::<[T]> // CHECK: [[ALIGN:_.+]] = AlignOf(T); // CHECK: [[B:_.+]] = copy [[ALIGN]] as std::ptr::Alignment (Transmute); - // CHECK: [[C:_.+]] = move ([[B]].0: std::ptr::alignment::AlignmentEnum); - // CHECK: [[D:_.+]] = discriminant([[C]]); + // CHECK: [[D:_.+]] = discriminant(([[B]].0: std::ptr::alignment::AlignmentEnum)); // CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[D]]) -> std::ptr::drop_in_place(ptr) } 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..ac043300d9c0b 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 @@ -8,16 +8,15 @@ fn filter_mapped(_1: impl Iterator, _2: 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 _9: (); + let mut _10: &mut std::iter::FilterMap, impl Fn(T) -> Option>; scope 1 { debug iter => _4; - let _9: U; scope 2 { - debug x => _9; + debug x => ((_7 as Some).0: U); } scope 4 (inlined , impl Fn(T) -> Option> as Iterator>::next) { - debug self => _11; + debug self => _10; let mut _5: &mut impl Iterator; let mut _6: &mut impl Fn(T) -> Option; } @@ -37,8 +36,7 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () } bb2: { - StorageLive(_7); - // DBG: _11 = &_4; + // DBG: _10 = &_4; StorageLive(_5); _5 = &mut (_4.0: impl Iterator); StorageLive(_6); @@ -54,7 +52,6 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () } bb4: { - StorageDead(_7); drop(_4) -> [return: bb5, unwind continue]; } @@ -64,12 +61,10 @@ 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]; + _9 = opaque::(move ((_7 as Some).0: U)) -> [return: bb7, unwind: bb9]; } bb7: { - StorageDead(_7); 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..cd01528e0f60e 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 @@ -6,23 +6,22 @@ fn int_range(_1: usize, _2: usize) -> () { 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 _10: (); + let mut _11: &mut std::ops::Range; scope 1 { debug iter => _3; - let _10: usize; scope 2 { - debug i => _10; + debug i => ((_9 as Some).0: usize); } scope 4 (inlined iter::range::>::next) { - debug self => _12; + debug self => _11; scope 5 (inlined as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _12; + debug self => _11; let mut _6: bool; let _7: usize; let mut _8: usize; + let mut _12: &usize; let mut _13: &usize; - let mut _14: &usize; scope 6 { debug old => _7; scope 8 (inlined ::forward_unchecked) { @@ -39,8 +38,8 @@ fn int_range(_1: usize, _2: usize) -> () { } } scope 7 (inlined std::cmp::impls::::lt) { - debug self => _13; - debug other => _14; + debug self => _12; + debug other => _13; let mut _4: usize; let mut _5: usize; } @@ -57,11 +56,10 @@ fn int_range(_1: usize, _2: usize) -> () { } bb1: { - StorageLive(_9); - // DBG: _12 = &_3; + // DBG: _11 = &_3; StorageLive(_6); - // DBG: _13 = &(_3.0: usize); - // DBG: _14 = &(_3.1: usize); + // DBG: _12 = &(_3.0: usize); + // DBG: _13 = &(_3.1: usize); StorageLive(_4); _4 = copy (_3.0: usize); StorageLive(_5); @@ -74,7 +72,6 @@ fn int_range(_1: usize, _2: usize) -> () { bb2: { StorageDead(_6); - StorageDead(_9); return; } @@ -86,12 +83,10 @@ fn int_range(_1: usize, _2: usize) -> () { StorageDead(_8); _9 = Option::::Some(copy _7); StorageDead(_6); - _10 = copy ((_9 as Some).0: usize); - _11 = opaque::(move _10) -> [return: bb4, unwind continue]; + _10 = opaque::(move ((_9 as Some).0: usize)) -> [return: bb4, unwind continue]; } bb4: { - StorageDead(_9); 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..5481fa70aa01e 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -6,17 +6,16 @@ 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 _11: std::option::Option; + let _12: (); + let mut _13: &mut std::iter::Map, impl Fn(T) -> U>; scope 1 { debug iter => _4; - let _13: U; scope 2 { - debug x => _13; + debug x => ((_11 as Some).0: U); } scope 4 (inlined , impl Fn(T) -> U> as Iterator>::next) { - debug self => _15; + debug self => _13; let mut _5: &mut impl Iterator; let mut _6: std::option::Option; let mut _7: &mut impl Fn(T) -> U; @@ -24,14 +23,13 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { debug self => _6; debug f => _7; let mut _8: isize; - let _9: T; - let mut _10: (T,); - let mut _11: U; + let mut _9: (T,); + let mut _10: U; scope 6 { - debug x => _9; + debug x => ((_6 as Some).0: T); scope 7 (inlined ops::function::impls:: for &mut impl Fn(T) -> U>::call_once) { debug self => _7; - debug args => _10; + debug args => _9; } } } @@ -52,8 +50,7 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { } bb2: { - StorageLive(_12); - // DBG: _15 = &_4; + // DBG: _13 = &_4; StorageLive(_7); StorageLive(_6); StorageLive(_5); @@ -65,17 +62,14 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { StorageDead(_5); _7 = &mut (_4.1: impl Fn(T) -> U); StorageLive(_8); - StorageLive(_9); _8 = discriminant(_6); switchInt(move _8) -> [0: bb4, 1: bb6, otherwise: bb9]; } bb4: { - StorageDead(_9); StorageDead(_8); StorageDead(_6); StorageDead(_7); - StorageDead(_12); drop(_4) -> [return: bb5, unwind continue]; } @@ -85,27 +79,23 @@ 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]; + StorageLive(_9); + _9 = (copy ((_6 as Some).0: T),); + _10 = U as FnMut<(T,)>>::call_mut(move _7, move _9) -> [return: bb7, unwind: bb10]; } bb7: { - StorageDead(_10); - _12 = Option::::Some(move _11); - StorageDead(_11); StorageDead(_9); + _11 = Option::::Some(move _10); + StorageDead(_10); StorageDead(_8); StorageDead(_6); StorageDead(_7); - _13 = move ((_12 as Some).0: U); - _14 = opaque::(move _13) -> [return: bb8, unwind: bb10]; + _12 = opaque::(move ((_11 as Some).0: U)) -> [return: bb8, unwind: bb10]; } bb8: { - StorageDead(_12); goto -> bb2; } diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir index 66eb1bcfaa665..4adfa470e49f3 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -8,12 +8,11 @@ fn vec_move(_1: Vec) -> () { let mut _24: &mut std::vec::IntoIter; let mut _25: std::option::Option; let mut _26: isize; - let _28: (); + let _27: (); scope 1 { debug iter => _23; - let _27: impl Sized; scope 2 { - debug x => _27; + debug x => ((_25 as Some).0: impl Sized); } } scope 3 (inlined as IntoIterator>::into_iter) { @@ -24,16 +23,16 @@ fn vec_move(_1: Vec) -> () { let mut _10: *mut impl Sized; let mut _11: *const impl Sized; let mut _12: usize; - let _29: &std::vec::Vec; - let mut _30: &std::mem::ManuallyDrop>; - let mut _31: &alloc::raw_vec::RawVec; - let mut _32: &std::mem::ManuallyDrop>; - let _33: &std::vec::Vec; - let mut _34: &std::mem::ManuallyDrop>; - let _35: &std::vec::Vec; - let mut _36: &std::mem::ManuallyDrop>; - let mut _37: &alloc::raw_vec::RawVec; - let mut _38: &std::mem::ManuallyDrop>; + let _28: &std::vec::Vec; + let mut _29: &std::mem::ManuallyDrop>; + let mut _30: &alloc::raw_vec::RawVec; + let mut _31: &std::mem::ManuallyDrop>; + let _32: &std::vec::Vec; + let mut _33: &std::mem::ManuallyDrop>; + let _34: &std::vec::Vec; + let mut _35: &std::mem::ManuallyDrop>; + let mut _36: &alloc::raw_vec::RawVec; + let mut _37: &std::mem::ManuallyDrop>; scope 4 { debug me => _2; scope 5 { @@ -51,16 +50,16 @@ fn vec_move(_1: Vec) -> () { debug cap => _20; } scope 39 (inlined > as Deref>::deref) { - debug self => _38; + debug self => _37; } scope 40 (inlined alloc::raw_vec::RawVec::::capacity) { - debug self => _37; + debug self => _36; let mut _19: usize; - let mut _39: &alloc::raw_vec::RawVecInner; + let mut _38: &alloc::raw_vec::RawVecInner; scope 41 (inlined std::mem::size_of::) { } scope 42 (inlined alloc::raw_vec::RawVecInner::capacity) { - debug self => _39; + debug self => _38; debug elem_size => _19; let mut _21: core::num::niche_types::UsizeNoHighBit; scope 43 (inlined core::num::niche_types::UsizeNoHighBit::as_inner) { @@ -70,10 +69,10 @@ fn vec_move(_1: Vec) -> () { } } scope 25 (inlined > as Deref>::deref) { - debug self => _34; + debug self => _33; } scope 26 (inlined Vec::::len) { - debug self => _33; + debug self => _32; let mut _13: bool; scope 27 { } @@ -108,10 +107,10 @@ fn vec_move(_1: Vec) -> () { } } scope 35 (inlined > as Deref>::deref) { - debug self => _36; + debug self => _35; } scope 36 (inlined Vec::::len) { - debug self => _35; + debug self => _34; let mut _9: bool; scope 37 { } @@ -126,10 +125,10 @@ fn vec_move(_1: Vec) -> () { } } scope 17 (inlined > as Deref>::deref) { - debug self => _32; + debug self => _31; } scope 18 (inlined alloc::raw_vec::RawVec::::non_null) { - debug self => _31; + debug self => _30; scope 19 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _4: std::ptr::NonNull; scope 20 (inlined Unique::::cast::) { @@ -145,10 +144,10 @@ fn vec_move(_1: Vec) -> () { } } scope 11 (inlined > as Deref>::deref) { - debug self => _30; + debug self => _29; } scope 12 (inlined Vec::::allocator) { - debug self => _29; + debug self => _28; scope 13 (inlined alloc::raw_vec::RawVec::::allocator) { scope 14 (inlined alloc::raw_vec::RawVecInner::allocator) { } @@ -178,12 +177,12 @@ fn vec_move(_1: Vec) -> () { StorageLive(_2); _2 = ManuallyDrop::> { value: copy _1 }; StorageLive(_3); - // DBG: _30 = &_2; - // DBG: _29 = &(_2.0: std::vec::Vec); + // DBG: _29 = &_2; + // DBG: _28 = &(_2.0: std::vec::Vec); _3 = &raw const ((((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).2: std::alloc::Global); StorageDead(_3); - // DBG: _32 = &_2; - // DBG: _31 = &((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec); + // DBG: _31 = &_2; + // DBG: _30 = &((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec); _4 = copy (((((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); _5 = copy _4 as *const impl Sized (Transmute); _6 = NonNull:: { pointer: copy _5 }; @@ -194,8 +193,8 @@ fn vec_move(_1: Vec) -> () { bb1: { StorageLive(_10); StorageLive(_8); - // DBG: _36 = &_2; - // DBG: _35 = &(_2.0: std::vec::Vec); + // DBG: _35 = &_2; + // DBG: _34 = &(_2.0: std::vec::Vec); _8 = copy ((_2.0: std::vec::Vec).1: usize); StorageLive(_9); _9 = Le(copy _8, const ::MAX_SLICE_LEN); @@ -210,8 +209,8 @@ fn vec_move(_1: Vec) -> () { bb2: { StorageLive(_12); - // DBG: _34 = &_2; - // DBG: _33 = &(_2.0: std::vec::Vec); + // DBG: _33 = &_2; + // DBG: _32 = &(_2.0: std::vec::Vec); _12 = copy ((_2.0: std::vec::Vec).1: usize); StorageLive(_13); _13 = Le(copy _12, const ::MAX_SLICE_LEN); @@ -239,9 +238,9 @@ fn vec_move(_1: Vec) -> () { } bb4: { - // DBG: _38 = &_2; - // DBG: _37 = &((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec); - // DBG: _39 = &(((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner); + // DBG: _37 = &_2; + // DBG: _36 = &((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec); + // DBG: _38 = &(((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner); StorageLive(_19); _19 = SizeOf(impl Sized); switchInt(move _19) -> [0: bb5, otherwise: bb6]; @@ -277,7 +276,6 @@ fn vec_move(_1: Vec) -> () { } bb8: { - StorageLive(_25); _24 = &mut _23; _25 = as Iterator>::next(move _24) -> [return: bb9, unwind: bb15]; } @@ -288,7 +286,6 @@ fn vec_move(_1: Vec) -> () { } bb10: { - StorageDead(_25); drop(_23) -> [return: bb11, unwind continue]; } @@ -299,12 +296,10 @@ fn vec_move(_1: Vec) -> () { } bb12: { - _27 = move ((_25 as Some).0: impl Sized); - _28 = opaque::(move _27) -> [return: bb13, unwind: bb15]; + _27 = opaque::(move ((_25 as Some).0: impl Sized)) -> [return: bb13, unwind: bb15]; } bb13: { - StorageDead(_25); goto -> bb8; } 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..ff6784ed5d424 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -6,15 +6,14 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { debug f => _3; let mut _0: (); let mut _7: std::option::Option; - let mut _9: &impl Fn(u32); - let mut _10: (u32,); - let _11: (); + let mut _8: &impl Fn(u32); + let mut _9: (u32,); + let _10: (); scope 1 { debug ((iter: std::ops::Range).0: u32) => _1; debug ((iter: std::ops::Range).1: u32) => _2; - let _8: u32; scope 2 { - debug x => _8; + debug x => ((_7 as Some).0: u32); } scope 4 (inlined iter::range::>::next) { scope 5 (inlined as iter::range::RangeIteratorImpl>::spec_next) { @@ -44,7 +43,6 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { - StorageLive(_7); StorageLive(_5); StorageLive(_4); _4 = copy _1; @@ -55,7 +53,6 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb2: { StorageDead(_5); - StorageDead(_7); drop(_3) -> [return: bb3, unwind unreachable]; } @@ -68,18 +65,16 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { _1 = AddUnchecked(copy _6, const 1_u32); _7 = Option::::Some(copy _6); StorageDead(_5); - _8 = copy ((_7 as Some).0: u32); + StorageLive(_8); + _8 = &_3; StorageLive(_9); - _9 = &_3; - StorageLive(_10); - _10 = (copy _8,); - _11 = >::call(move _9, move _10) -> [return: bb5, unwind unreachable]; + _9 = (copy ((_7 as Some).0: u32),); + _10 = >::call(move _8, move _9) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_10); StorageDead(_9); - StorageDead(_7); + StorageDead(_8); 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..feb592cb3e19a 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -6,15 +6,14 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { debug f => _3; let mut _0: (); let mut _7: std::option::Option; - let mut _9: &impl Fn(u32); - let mut _10: (u32,); - let _11: (); + let mut _8: &impl Fn(u32); + let mut _9: (u32,); + let _10: (); scope 1 { debug ((iter: std::ops::Range).0: u32) => _1; debug ((iter: std::ops::Range).1: u32) => _2; - let _8: u32; scope 2 { - debug x => _8; + debug x => ((_7 as Some).0: u32); } scope 4 (inlined iter::range::>::next) { scope 5 (inlined as iter::range::RangeIteratorImpl>::spec_next) { @@ -44,7 +43,6 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { - StorageLive(_7); StorageLive(_5); StorageLive(_4); _4 = copy _1; @@ -55,7 +53,6 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb2: { StorageDead(_5); - StorageDead(_7); drop(_3) -> [return: bb3, unwind continue]; } @@ -68,18 +65,16 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { _1 = AddUnchecked(copy _6, const 1_u32); _7 = Option::::Some(copy _6); StorageDead(_5); - _8 = copy ((_7 as Some).0: u32); + StorageLive(_8); + _8 = &_3; StorageLive(_9); - _9 = &_3; - StorageLive(_10); - _10 = (copy _8,); - _11 = >::call(move _9, move _10) -> [return: bb5, unwind: bb6]; + _9 = (copy ((_7 as Some).0: u32),); + _10 = >::call(move _8, move _9) -> [return: bb5, unwind: bb6]; } bb5: { - StorageDead(_10); StorageDead(_9); - StorageDead(_7); + StorageDead(_8); 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..f6e5f6765f3ea 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir @@ -10,14 +10,13 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _6: &mut std::ops::RangeInclusive; let mut _7: std::option::Option; let mut _8: isize; - let mut _10: &impl Fn(u32); - let mut _11: (u32,); - let _12: (); + let mut _9: &impl Fn(u32); + let mut _10: (u32,); + let _11: (); scope 1 { debug iter => _5; - let _9: u32; scope 2 { - debug x => _9; + debug x => ((_7 as Some).0: u32); } scope 5 (inlined iter::range::>::next) { } @@ -35,7 +34,6 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { - StorageLive(_7); _6 = &mut _5; _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind unreachable]; } @@ -46,7 +44,6 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb3: { - StorageDead(_7); StorageDead(_5); drop(_3) -> [return: bb4, unwind unreachable]; } @@ -56,18 +53,16 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb5: { - _9 = copy ((_7 as Some).0: u32); + StorageLive(_9); + _9 = &_3; StorageLive(_10); - _10 = &_3; - StorageLive(_11); - _11 = (copy _9,); - _12 = >::call(move _10, move _11) -> [return: bb6, unwind unreachable]; + _10 = (copy ((_7 as Some).0: u32),); + _11 = >::call(move _9, move _10) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_11); StorageDead(_10); - StorageDead(_7); + StorageDead(_9); 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..0c3b825f22203 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir @@ -10,14 +10,13 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _6: &mut std::ops::RangeInclusive; let mut _7: std::option::Option; let mut _8: isize; - let mut _10: &impl Fn(u32); - let mut _11: (u32,); - let _12: (); + let mut _9: &impl Fn(u32); + let mut _10: (u32,); + let _11: (); scope 1 { debug iter => _5; - let _9: u32; scope 2 { - debug x => _9; + debug x => ((_7 as Some).0: u32); } scope 5 (inlined iter::range::>::next) { } @@ -35,7 +34,6 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { - StorageLive(_7); _6 = &mut _5; _7 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind: bb8]; } @@ -46,7 +44,6 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb3: { - StorageDead(_7); StorageDead(_5); drop(_3) -> [return: bb4, unwind continue]; } @@ -56,18 +53,16 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb5: { - _9 = copy ((_7 as Some).0: u32); + StorageLive(_9); + _9 = &_3; StorageLive(_10); - _10 = &_3; - StorageLive(_11); - _11 = (copy _9,); - _12 = >::call(move _10, move _11) -> [return: bb6, unwind: bb8]; + _10 = (copy ((_7 as Some).0: u32),); + _11 = >::call(move _9, move _10) -> [return: bb6, unwind: bb8]; } bb6: { - StorageDead(_11); StorageDead(_10); - StorageDead(_7); + StorageDead(_9); goto -> bb1; } 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..4c809e8d5c4dc 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 @@ -3,10 +3,9 @@ fn ezmap(_1: Option) -> Option { debug x => _1; let mut _0: std::option::Option; - scope 1 (inlined map::) { + scope 1 (inlined map::) { let mut _2: isize; - let _3: i32; - let mut _4: i32; + let mut _3: i32; scope 2 { scope 3 (inlined ezmap::{closure#0}) { } @@ -25,11 +24,10 @@ fn ezmap(_1: Option) -> Option { } bb2: { - _3 = copy ((_1 as Some).0: i32); - StorageLive(_4); - _4 = Add(copy _3, const 1_i32); - _0 = Option::::Some(move _4); - StorageDead(_4); + StorageLive(_3); + _3 = Add(copy ((_1 as Some).0: i32), const 1_i32); + _0 = Option::::Some(move _3); + 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..4101ee5d566da 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 @@ -3,9 +3,8 @@ fn map_via_question_mark(_1: Option) -> Option { debug x => _1; let mut _0: std::option::Option; - let mut _4: std::ops::ControlFlow, i32>; - let _5: i32; - let mut _6: i32; + let mut _3: std::ops::ControlFlow, i32>; + let mut _4: i32; scope 1 { debug residual => const Option::::None; scope 2 { @@ -14,44 +13,35 @@ fn map_via_question_mark(_1: Option) -> Option { } } scope 3 { - debug val => _5; + debug val => ((_3 as Continue).0: i32); scope 4 { } } scope 5 (inlined as Try>::branch) { let mut _2: isize; - let _3: i32; scope 6 { } } bb0: { - 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); StorageDead(_4); goto -> bb3; } bb2: { - _3 = copy ((_1 as Some).0: i32); - _4 = ControlFlow::, i32>::Continue(copy _3); - StorageDead(_3); + _3 = ControlFlow::, i32>::Continue(copy ((_1 as Some).0: i32)); StorageDead(_2); - _5 = copy ((_4 as Continue).0: i32); - _6 = Add(copy _5, const 1_i32); - _0 = Option::::Some(move _6); - StorageDead(_6); + _4 = Add(copy ((_3 as Continue).0: i32), const 1_i32); + _0 = Option::::Some(move _4); StorageDead(_4); goto -> bb3; } diff --git a/tests/mir-opt/pre-codegen/simple_option_map.rs b/tests/mir-opt/pre-codegen/simple_option_map.rs index f0d7b51a64397..a940be5b81294 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.rs +++ b/tests/mir-opt/pre-codegen/simple_option_map.rs @@ -17,8 +17,7 @@ pub fn ezmap(x: Option) -> Option { // combinator and without the closure, using just a plain match. // CHECK-LABEL: fn ezmap - // CHECK: [[INNER:_.+]] = copy ((_1 as Some).0: i32); - // CHECK: [[SUCC:_.+]] = Add({{copy|move}} [[INNER]], const 1_i32); + // CHECK: [[SUCC:_.+]] = Add(copy ((_1 as Some).0: i32), const 1_i32); // CHECK: _0 = Option::::Some({{copy|move}} [[SUCC]]); map(x, |n| n + 1) } @@ -28,10 +27,8 @@ pub fn map_via_question_mark(x: Option) -> Option { // FIXME(#138544): Ideally this would optimize out the `ControlFlow` local. // CHECK-LABEL: fn map_via_question_mark - // CHECK: [[INNER:_.+]] = copy ((_1 as Some).0: i32); - // CHECK: [[TEMP1:_.+]] = ControlFlow::, i32>::Continue(copy [[INNER]]); - // CHECK: [[TEMP2:_.+]] = copy (([[TEMP1]] as Continue).0: i32); - // CHECK: [[SUCC:_.+]] = Add({{copy|move}} [[TEMP2]], const 1_i32); + // CHECK: [[TEMP1:_.+]] = ControlFlow::, i32>::Continue(copy ((_1 as Some).0: i32)); + // CHECK: [[SUCC:_.+]] = Add(copy (([[TEMP1]] as Continue).0: i32), const 1_i32); // CHECK: _0 = Option::::Some({{copy|move}} [[SUCC]]); Some(x? + 1) } diff --git a/tests/mir-opt/pre-codegen/slice_index.rs b/tests/mir-opt/pre-codegen/slice_index.rs index 5dac535d195ad..c397642d281c9 100644 --- a/tests/mir-opt/pre-codegen/slice_index.rs +++ b/tests/mir-opt/pre-codegen/slice_index.rs @@ -35,9 +35,8 @@ pub fn slice_index_range(slice: &[u32], index: Range) -> &[u32] { pub unsafe fn slice_get_unchecked_mut_range(slice: &mut [u32], index: Range) -> &mut [u32] { // CHECK-LABEL: slice_get_unchecked_mut_range // CHECK: [[START:_[0-9]+]] = move (_2.0: usize); - // CHECK: [[END:_[0-9]+]] = move (_2.1: usize); // CHECK: precondition_check - // CHECK: [[LEN:_[0-9]+]] = SubUnchecked(copy [[END]], copy [[START]]); + // CHECK: [[LEN:_[0-9]+]] = SubUnchecked(copy (_2.1: usize), copy [[START]]); // CHECK: [[PTR:_[0-9]+]] = Offset(copy {{_[0-9]+}}, copy [[START]]); // CHECK: [[SLICE:_[0-9]+]] = *mut [u32] from (copy [[PTR]], copy [[LEN]]) // CHECK: _0 = &mut (*[[SLICE]]); @@ -51,9 +50,8 @@ pub unsafe fn slice_ptr_get_unchecked_range( ) -> *const [u32] { // CHECK-LABEL: slice_ptr_get_unchecked_range // CHECK: [[START:_[0-9]+]] = move (_2.0: usize); - // CHECK: [[END:_[0-9]+]] = move (_2.1: usize); // CHECK: precondition_check - // CHECK: [[LEN:_[0-9]+]] = SubUnchecked(copy [[END]], copy [[START]]); + // CHECK: [[LEN:_[0-9]+]] = SubUnchecked(copy (_2.1: usize), copy [[START]]); // CHECK: [[PTR:_[0-9]+]] = Offset(copy {{_[0-9]+}}, copy [[START]]); // CHECK: _0 = *const [u32] from (copy [[PTR]], copy [[LEN]]) slice.get_unchecked(index) 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..459006d38945b 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 @@ -5,19 +5,18 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> debug index => _2; let mut _0: &mut [u32]; let mut _3: usize; - let mut _4: usize; scope 1 (inlined #[track_caller] core::slice::::get_unchecked_mut::>) { - let mut _5: *mut [u32]; - let mut _11: *mut [u32]; + let mut _4: *mut [u32]; + let mut _10: *mut [u32]; scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::get_unchecked_mut) { - let mut _6: usize; - let _7: (); - let _8: usize; + let mut _5: usize; + let _6: (); + let _7: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_mut_noubcheck::) { - let _9: *mut u32; + let _8: *mut u32; scope 7 { - let _10: *mut u32; + let _9: *mut u32; scope 8 { } } @@ -32,30 +31,29 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> bb0: { _3 = move (_2.0: usize); - _4 = move (_2.1: usize); - StorageLive(_11); + StorageLive(_10); + StorageLive(_4); + _4 = &raw mut (*_1); + StorageLive(_7); 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]; + _5 = PtrMetadata(copy _1); + _6 = as SliceIndex<[T]>>::get_unchecked_mut::precondition_check(copy _3, copy (_2.1: usize), move _5) -> [return: bb1, unwind unreachable]; } bb1: { - StorageDead(_6); - _8 = SubUnchecked(copy _4, copy _3); + StorageDead(_5); + _7 = SubUnchecked(copy (_2.1: usize), copy _3); + StorageLive(_8); StorageLive(_9); - StorageLive(_10); - _9 = copy _5 as *mut u32 (PtrToPtr); - _10 = Offset(copy _9, copy _3); - _11 = *mut [u32] from (copy _10, copy _8); - StorageDead(_10); + _8 = copy _4 as *mut u32 (PtrToPtr); + _9 = Offset(copy _8, copy _3); + _10 = *mut [u32] from (copy _9, copy _7); StorageDead(_9); StorageDead(_8); - StorageDead(_5); - _0 = &mut (*_11); - StorageDead(_11); + StorageDead(_7); + StorageDead(_4); + _0 = &mut (*_10); + StorageDead(_10); 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..459006d38945b 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 @@ -5,19 +5,18 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> debug index => _2; let mut _0: &mut [u32]; let mut _3: usize; - let mut _4: usize; scope 1 (inlined #[track_caller] core::slice::::get_unchecked_mut::>) { - let mut _5: *mut [u32]; - let mut _11: *mut [u32]; + let mut _4: *mut [u32]; + let mut _10: *mut [u32]; scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::get_unchecked_mut) { - let mut _6: usize; - let _7: (); - let _8: usize; + let mut _5: usize; + let _6: (); + let _7: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_mut_noubcheck::) { - let _9: *mut u32; + let _8: *mut u32; scope 7 { - let _10: *mut u32; + let _9: *mut u32; scope 8 { } } @@ -32,30 +31,29 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> bb0: { _3 = move (_2.0: usize); - _4 = move (_2.1: usize); - StorageLive(_11); + StorageLive(_10); + StorageLive(_4); + _4 = &raw mut (*_1); + StorageLive(_7); 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]; + _5 = PtrMetadata(copy _1); + _6 = as SliceIndex<[T]>>::get_unchecked_mut::precondition_check(copy _3, copy (_2.1: usize), move _5) -> [return: bb1, unwind unreachable]; } bb1: { - StorageDead(_6); - _8 = SubUnchecked(copy _4, copy _3); + StorageDead(_5); + _7 = SubUnchecked(copy (_2.1: usize), copy _3); + StorageLive(_8); StorageLive(_9); - StorageLive(_10); - _9 = copy _5 as *mut u32 (PtrToPtr); - _10 = Offset(copy _9, copy _3); - _11 = *mut [u32] from (copy _10, copy _8); - StorageDead(_10); + _8 = copy _4 as *mut u32 (PtrToPtr); + _9 = Offset(copy _8, copy _3); + _10 = *mut [u32] from (copy _9, copy _7); StorageDead(_9); StorageDead(_8); - StorageDead(_5); - _0 = &mut (*_11); - StorageDead(_11); + StorageDead(_7); + StorageDead(_4); + _0 = &mut (*_10); + StorageDead(_10); 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..f882a8a737703 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 @@ -5,23 +5,22 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { debug index => _2; let mut _0: &[u32]; let mut _3: usize; - let mut _4: usize; scope 1 (inlined #[track_caller] core::slice::index::> for [u32]>::index) { scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::index) { - let mut _7: usize; - let mut _8: bool; - let mut _9: *const [u32]; - let _12: *const [u32]; - let mut _13: usize; - let mut _14: !; + let mut _6: usize; + let mut _7: bool; + let mut _8: *const [u32]; + let _11: *const [u32]; + let mut _12: usize; + let mut _13: !; scope 3 (inlined core::num::::checked_sub) { - let mut _5: bool; - let mut _6: usize; + let mut _4: bool; + let mut _5: usize; } scope 4 (inlined core::slice::index::get_offset_len_noubcheck::) { - let _10: *const u32; + let _9: *const u32; scope 5 { - let _11: *const u32; + let _10: *const u32; scope 6 { } } @@ -30,55 +29,56 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { } bb0: { + StorageLive(_3); _3 = move (_2.0: usize); - _4 = move (_2.1: usize); - StorageLive(_5); - _5 = Lt(copy _4, copy _3); - switchInt(move _5) -> [0: bb1, otherwise: bb4]; + StorageLive(_4); + _4 = Lt(copy (_2.1: usize), copy _3); + switchInt(move _4) -> [0: bb1, otherwise: bb4]; } bb1: { - _6 = SubUnchecked(copy _4, copy _3); - StorageDead(_5); - StorageLive(_8); + _5 = SubUnchecked(copy (_2.1: usize), copy _3); + StorageDead(_4); StorageLive(_7); - _7 = PtrMetadata(copy _1); - _8 = Le(copy _4, move _7); - switchInt(move _8) -> [0: bb2, otherwise: bb3]; + StorageLive(_6); + _6 = PtrMetadata(copy _1); + _7 = Le(copy (_2.1: usize), move _6); + switchInt(move _7) -> [0: bb2, otherwise: bb3]; } bb2: { - StorageDead(_7); + StorageDead(_6); goto -> bb5; } bb3: { - StorageDead(_7); - StorageLive(_12); + StorageDead(_6); + StorageLive(_11); + StorageLive(_8); + _8 = &raw const (*_1); StorageLive(_9); - _9 = &raw const (*_1); StorageLive(_10); - StorageLive(_11); - _10 = copy _9 as *const u32 (PtrToPtr); - _11 = Offset(copy _10, copy _3); - _12 = *const [u32] from (copy _11, copy _6); - StorageDead(_11); + _9 = copy _8 as *const u32 (PtrToPtr); + _10 = Offset(copy _9, copy _3); + _11 = *const [u32] from (copy _10, copy _5); StorageDead(_10); StorageDead(_9); - _0 = &(*_12); - StorageDead(_12); StorageDead(_8); + _0 = &(*_11); + StorageDead(_11); + StorageDead(_7); + StorageDead(_3); return; } bb4: { - StorageDead(_5); + StorageDead(_4); goto -> bb5; } bb5: { - StorageLive(_13); - _13 = PtrMetadata(copy _1); - _14 = core::slice::index::slice_index_fail(move _3, move _4, move _13) -> unwind unreachable; + StorageLive(_12); + _12 = PtrMetadata(copy _1); + _13 = core::slice::index::slice_index_fail(move _3, move (_2.1: usize), move _12) -> unwind unreachable; } } 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..d999db0cc3f85 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 @@ -5,23 +5,22 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { debug index => _2; let mut _0: &[u32]; let mut _3: usize; - let mut _4: usize; scope 1 (inlined #[track_caller] core::slice::index::> for [u32]>::index) { scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::index) { - let mut _7: usize; - let mut _8: bool; - let mut _9: *const [u32]; - let _12: *const [u32]; - let mut _13: usize; - let mut _14: !; + let mut _6: usize; + let mut _7: bool; + let mut _8: *const [u32]; + let _11: *const [u32]; + let mut _12: usize; + let mut _13: !; scope 3 (inlined core::num::::checked_sub) { - let mut _5: bool; - let mut _6: usize; + let mut _4: bool; + let mut _5: usize; } scope 4 (inlined core::slice::index::get_offset_len_noubcheck::) { - let _10: *const u32; + let _9: *const u32; scope 5 { - let _11: *const u32; + let _10: *const u32; scope 6 { } } @@ -30,55 +29,56 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { } bb0: { + StorageLive(_3); _3 = move (_2.0: usize); - _4 = move (_2.1: usize); - StorageLive(_5); - _5 = Lt(copy _4, copy _3); - switchInt(move _5) -> [0: bb1, otherwise: bb4]; + StorageLive(_4); + _4 = Lt(copy (_2.1: usize), copy _3); + switchInt(move _4) -> [0: bb1, otherwise: bb4]; } bb1: { - _6 = SubUnchecked(copy _4, copy _3); - StorageDead(_5); - StorageLive(_8); + _5 = SubUnchecked(copy (_2.1: usize), copy _3); + StorageDead(_4); StorageLive(_7); - _7 = PtrMetadata(copy _1); - _8 = Le(copy _4, move _7); - switchInt(move _8) -> [0: bb2, otherwise: bb3]; + StorageLive(_6); + _6 = PtrMetadata(copy _1); + _7 = Le(copy (_2.1: usize), move _6); + switchInt(move _7) -> [0: bb2, otherwise: bb3]; } bb2: { - StorageDead(_7); + StorageDead(_6); goto -> bb5; } bb3: { - StorageDead(_7); - StorageLive(_12); + StorageDead(_6); + StorageLive(_11); + StorageLive(_8); + _8 = &raw const (*_1); StorageLive(_9); - _9 = &raw const (*_1); StorageLive(_10); - StorageLive(_11); - _10 = copy _9 as *const u32 (PtrToPtr); - _11 = Offset(copy _10, copy _3); - _12 = *const [u32] from (copy _11, copy _6); - StorageDead(_11); + _9 = copy _8 as *const u32 (PtrToPtr); + _10 = Offset(copy _9, copy _3); + _11 = *const [u32] from (copy _10, copy _5); StorageDead(_10); StorageDead(_9); - _0 = &(*_12); - StorageDead(_12); StorageDead(_8); + _0 = &(*_11); + StorageDead(_11); + StorageDead(_7); + StorageDead(_3); return; } bb4: { - StorageDead(_5); + StorageDead(_4); goto -> bb5; } bb5: { - StorageLive(_13); - _13 = PtrMetadata(copy _1); - _14 = core::slice::index::slice_index_fail(move _3, move _4, move _13) -> unwind continue; + StorageLive(_12); + _12 = PtrMetadata(copy _1); + _13 = core::slice::index::slice_index_fail(move _3, move (_2.1: usize), move _12) -> unwind continue; } } 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..713caa627b6e8 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 @@ -5,17 +5,16 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - debug index => _2; let mut _0: *const [u32]; let mut _3: usize; - let mut _4: usize; scope 1 (inlined std::ptr::const_ptr::::get_unchecked::>) { scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::get_unchecked) { - let mut _5: usize; - let _6: (); - let _7: usize; + let mut _4: usize; + let _5: (); + let _6: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_noubcheck::) { - let _8: *const u32; + let _7: *const u32; scope 7 { - let _9: *const u32; + let _8: *const u32; scope 8 { } } @@ -30,24 +29,23 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - bb0: { _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]; + StorageLive(_6); + StorageLive(_4); + _4 = PtrMetadata(copy _1); + _5 = as SliceIndex<[T]>>::get_unchecked::precondition_check(copy _3, copy (_2.1: usize), move _4) -> [return: bb1, unwind unreachable]; } bb1: { - StorageDead(_5); - _7 = SubUnchecked(copy _4, copy _3); + StorageDead(_4); + _6 = SubUnchecked(copy (_2.1: usize), copy _3); + StorageLive(_7); StorageLive(_8); - StorageLive(_9); - _8 = copy _1 as *const u32 (PtrToPtr); - _9 = Offset(copy _8, copy _3); - _0 = *const [u32] from (copy _9, copy _7); - StorageDead(_9); + _7 = copy _1 as *const u32 (PtrToPtr); + _8 = Offset(copy _7, copy _3); + _0 = *const [u32] from (copy _8, copy _6); StorageDead(_8); StorageDead(_7); + StorageDead(_6); 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..713caa627b6e8 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 @@ -5,17 +5,16 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - debug index => _2; let mut _0: *const [u32]; let mut _3: usize; - let mut _4: usize; scope 1 (inlined std::ptr::const_ptr::::get_unchecked::>) { scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::get_unchecked) { - let mut _5: usize; - let _6: (); - let _7: usize; + let mut _4: usize; + let _5: (); + let _6: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_noubcheck::) { - let _8: *const u32; + let _7: *const u32; scope 7 { - let _9: *const u32; + let _8: *const u32; scope 8 { } } @@ -30,24 +29,23 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - bb0: { _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]; + StorageLive(_6); + StorageLive(_4); + _4 = PtrMetadata(copy _1); + _5 = as SliceIndex<[T]>>::get_unchecked::precondition_check(copy _3, copy (_2.1: usize), move _4) -> [return: bb1, unwind unreachable]; } bb1: { - StorageDead(_5); - _7 = SubUnchecked(copy _4, copy _3); + StorageDead(_4); + _6 = SubUnchecked(copy (_2.1: usize), copy _3); + StorageLive(_7); StorageLive(_8); - StorageLive(_9); - _8 = copy _1 as *const u32 (PtrToPtr); - _9 = Offset(copy _8, copy _3); - _0 = *const [u32] from (copy _9, copy _7); - StorageDead(_9); + _7 = copy _1 as *const u32 (PtrToPtr); + _8 = Offset(copy _7, copy _3); + _0 = *const [u32] from (copy _8, copy _6); StorageDead(_8); StorageDead(_7); + StorageDead(_6); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index 104987b0fdda9..6bf9f478673eb 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -6,22 +6,22 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _0: (); let mut _10: usize; let mut _28: std::option::Option<(usize, &T)>; - let mut _31: &impl Fn(usize, &T); - let mut _32: (usize, &T); - let _33: (); + let mut _30: &impl Fn(usize, &T); + let mut _31: (usize, &T); + let _32: (); scope 1 { debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _6; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).1: *const T) => _9; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; debug ((iter: Enumerate>).1: usize) => _10; let _29: usize; - let _30: &T; scope 2 { debug i => _29; - debug x => _30; + debug x => (((_28 as Some).0: (usize, &T)).1: &T); } scope 18 (inlined > as Iterator>::next) { let mut _23: std::option::Option<&T>; + let mut _24: std::ops::ControlFlow, &T>; let mut _26: (usize, bool); let mut _27: (usize, &T); scope 19 { @@ -40,7 +40,6 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 25 (inlined as Try>::branch) { - let _24: &T; scope 26 { } } @@ -169,7 +168,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { - StorageLive(_28); + StorageLive(_24); StorageLive(_25); StorageLive(_26); StorageLive(_23); @@ -239,7 +238,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { StorageDead(_23); StorageDead(_26); StorageDead(_25); - StorageDead(_28); + StorageDead(_24); StorageDead(_10); drop(_2) -> [return: bb11, unwind unreachable]; } @@ -266,7 +265,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { StorageDead(_19); StorageDead(_12); StorageDead(_11); - _24 = copy ((_23 as Some).0: &T); + _24 = ControlFlow::, &T>::Continue(copy ((_23 as Some).0: &T)); StorageDead(_23); _25 = copy _10; _26 = AddWithOverflow(copy _10, const 1_usize); @@ -276,24 +275,23 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb14: { _10 = move (_26.0: usize); StorageLive(_27); - _27 = (copy _25, copy _24); + _27 = (copy _25, copy ((_24 as Continue).0: &T)); _28 = Option::<(usize, &T)>::Some(move _27); StorageDead(_27); StorageDead(_26); StorageDead(_25); + StorageDead(_24); _29 = copy (((_28 as Some).0: (usize, &T)).0: usize); - _30 = copy (((_28 as Some).0: (usize, &T)).1: &T); + StorageLive(_30); + _30 = &_2; StorageLive(_31); - _31 = &_2; - StorageLive(_32); - _32 = (copy _29, copy _30); - _33 = >::call(move _31, move _32) -> [return: bb15, unwind unreachable]; + _31 = (copy _29, copy (((_28 as Some).0: (usize, &T)).1: &T)); + _32 = >::call(move _30, move _31) -> [return: bb15, unwind unreachable]; } bb15: { - StorageDead(_32); StorageDead(_31); - StorageDead(_28); + StorageDead(_30); goto -> bb4; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 28b12cdf36755..752bfe40c3087 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -11,8 +11,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _14: std::option::Option<(usize, &T)>; let mut _15: isize; let mut _18: &impl Fn(usize, &T); - let mut _19: (usize, &T); - let _20: (); + let _19: (); scope 1 { debug iter => _12; let _16: usize; @@ -128,13 +127,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { _17 = copy (((_14 as Some).0: (usize, &T)).1: &T); StorageLive(_18); _18 = &_2; - StorageLive(_19); - _19 = copy ((_14 as Some).0: (usize, &T)); - _20 = >::call(move _18, move _19) -> [return: bb9, unwind: bb11]; + _19 = >::call(move _18, move ((_14 as Some).0: (usize, &T))) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_19); StorageDead(_18); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index 4d0e3548e7d6b..9b633850d306d 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -5,16 +5,15 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug f => _2; let mut _0: (); let mut _22: std::option::Option<&T>; - let mut _24: &impl Fn(&T); - let mut _25: (&T,); - let _26: (); + let mut _23: &impl Fn(&T); + let mut _24: (&T,); + let _25: (); scope 1 { debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _6; debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _9; debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - let _23: &T; scope 2 { - debug x => _23; + debug x => ((_22 as Some).0: &T); } scope 16 (inlined as Iterator>::next) { let mut _6: std::ptr::NonNull; @@ -134,7 +133,6 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb4: { - StorageLive(_22); StorageLive(_10); StorageLive(_11); StorageLive(_18); @@ -198,7 +196,6 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb10: { - StorageDead(_22); drop(_2) -> [return: bb11, unwind unreachable]; } @@ -224,18 +221,16 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_18); StorageDead(_11); StorageDead(_10); - _23 = copy ((_22 as Some).0: &T); + StorageLive(_23); + _23 = &_2; StorageLive(_24); - _24 = &_2; - StorageLive(_25); - _25 = (copy _23,); - _26 = >::call(move _24, move _25) -> [return: bb14, unwind unreachable]; + _24 = (copy ((_22 as Some).0: &T),); + _25 = >::call(move _23, move _24) -> [return: bb14, unwind unreachable]; } bb14: { - StorageDead(_25); StorageDead(_24); - StorageDead(_22); + StorageDead(_23); goto -> bb4; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 2b5d8c27d7109..d7eb64d392de1 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -5,16 +5,15 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug f => _2; let mut _0: (); let mut _22: std::option::Option<&T>; - let mut _24: &impl Fn(&T); - let mut _25: (&T,); - let _26: (); + let mut _23: &impl Fn(&T); + let mut _24: (&T,); + let _25: (); scope 1 { debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _6; debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _9; debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - let _23: &T; scope 2 { - debug x => _23; + debug x => ((_22 as Some).0: &T); } scope 16 (inlined as Iterator>::next) { let mut _6: std::ptr::NonNull; @@ -134,7 +133,6 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb4: { - StorageLive(_22); StorageLive(_10); StorageLive(_11); StorageLive(_18); @@ -198,7 +196,6 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb10: { - StorageDead(_22); drop(_2) -> [return: bb11, unwind continue]; } @@ -224,18 +221,16 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_18); StorageDead(_11); StorageDead(_10); - _23 = copy ((_22 as Some).0: &T); + StorageLive(_23); + _23 = &_2; StorageLive(_24); - _24 = &_2; - StorageLive(_25); - _25 = (copy _23,); - _26 = >::call(move _24, move _25) -> [return: bb14, unwind: bb15]; + _24 = (copy ((_22 as Some).0: &T),); + _25 = >::call(move _23, move _24) -> [return: bb14, unwind: bb15]; } bb14: { - StorageDead(_25); StorageDead(_24); - StorageDead(_22); + StorageDead(_23); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index 3009be3f9dc67..6fe61cb6eb4de 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -8,14 +8,13 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _11: std::iter::Rev>; let mut _12: std::iter::Rev>; let mut _33: std::option::Option<&T>; - let mut _35: &impl Fn(&T); - let mut _36: (&T,); - let _37: (); + let mut _34: &impl Fn(&T); + let mut _35: (&T,); + let _36: (); scope 1 { debug iter => _12; - let _34: &T; scope 2 { - debug x => _34; + debug x => ((_33 as Some).0: &T); } scope 18 (inlined > as Iterator>::next) { scope 19 (inlined as DoubleEndedIterator>::next_back) { @@ -173,7 +172,6 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb4: { - StorageLive(_33); StorageLive(_20); StorageLive(_19); StorageLive(_14); @@ -276,18 +274,16 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_14); StorageDead(_19); StorageDead(_20); - _34 = copy ((_33 as Some).0: &T); + StorageLive(_34); + _34 = &_2; StorageLive(_35); - _35 = &_2; - StorageLive(_36); - _36 = (copy _34,); - _37 = >::call(move _35, move _36) -> [return: bb14, unwind unreachable]; + _35 = (copy ((_33 as Some).0: &T),); + _36 = >::call(move _34, move _35) -> [return: bb14, unwind unreachable]; } bb14: { - StorageDead(_36); StorageDead(_35); - StorageDead(_33); + StorageDead(_34); goto -> bb4; } @@ -297,7 +293,6 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_14); StorageDead(_19); StorageDead(_20); - StorageDead(_33); StorageDead(_12); drop(_2) -> [return: bb16, unwind unreachable]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index e40bff5ea3504..ce0eebfe43846 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -8,14 +8,13 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _11: std::iter::Rev>; let mut _12: std::iter::Rev>; let mut _33: std::option::Option<&T>; - let mut _35: &impl Fn(&T); - let mut _36: (&T,); - let _37: (); + let mut _34: &impl Fn(&T); + let mut _35: (&T,); + let _36: (); scope 1 { debug iter => _12; - let _34: &T; scope 2 { - debug x => _34; + debug x => ((_33 as Some).0: &T); } scope 18 (inlined > as Iterator>::next) { scope 19 (inlined as DoubleEndedIterator>::next_back) { @@ -173,7 +172,6 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb4: { - StorageLive(_33); StorageLive(_20); StorageLive(_19); StorageLive(_14); @@ -276,18 +274,16 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_14); StorageDead(_19); StorageDead(_20); - _34 = copy ((_33 as Some).0: &T); + StorageLive(_34); + _34 = &_2; StorageLive(_35); - _35 = &_2; - StorageLive(_36); - _36 = (copy _34,); - _37 = >::call(move _35, move _36) -> [return: bb14, unwind: bb15]; + _35 = (copy ((_33 as Some).0: &T),); + _36 = >::call(move _34, move _35) -> [return: bb14, unwind: bb15]; } bb14: { - StorageDead(_36); StorageDead(_35); - StorageDead(_33); + StorageDead(_34); goto -> bb4; } @@ -305,7 +301,6 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_14); StorageDead(_19); StorageDead(_20); - StorageDead(_33); StorageDead(_12); drop(_2) -> [return: bb18, unwind continue]; } 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..cca1179328fb6 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 @@ -4,45 +4,34 @@ fn new(_1: Result) -> Result { debug x => _1; let mut _0: std::result::Result; let mut _2: isize; - let _3: T; - let mut _4: std::ops::ControlFlow; - let _5: T; - let _6: E; - let _7: E; + let mut _3: std::ops::ControlFlow; scope 1 { - debug v => _3; + debug v => ((_1 as Ok).0: T); } scope 2 { - debug e => _6; + debug e => ((_1 as Err).0: E); } scope 3 { - debug v => _5; + debug v => ((_3 as Continue).0: T); } scope 4 { - debug e => _7; + debug e => ((_3 as Break).0: E); } bb0: { - StorageLive(_4); _2 = discriminant(_1); switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4]; } bb1: { - _3 = move ((_1 as Ok).0: T); - _4 = ControlFlow::::Continue(copy _3); - _5 = move ((_4 as Continue).0: T); - _0 = Result::::Ok(copy _5); - StorageDead(_4); + _3 = ControlFlow::::Continue(copy ((_1 as Ok).0: T)); + _0 = Result::::Ok(copy ((_3 as Continue).0: T)); goto -> bb3; } bb2: { - _6 = move ((_1 as Err).0: E); - _4 = ControlFlow::::Break(copy _6); - _7 = move ((_4 as Break).0: E); - _0 = Result::::Err(copy _7); - StorageDead(_4); + _3 = ControlFlow::::Break(copy ((_1 as Err).0: E)); + _0 = Result::::Err(copy ((_3 as Break).0: E)); goto -> bb3; } diff --git a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff index ce9d812701a8f..12c2187fc067d 100644 --- a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff +++ b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff @@ -8,11 +8,11 @@ let mut _3: isize; let _4: std::result::Result; let _5: i32; + let mut _8: i32; scope 1 { debug residual => _4; scope 2 { scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { - let _10: i32; scope 9 { scope 10 (inlined >::from) { } @@ -27,9 +27,7 @@ } scope 5 (inlined as Try>::branch) { let mut _6: isize; - let _7: i32; - let _8: i32; - let mut _9: std::result::Result; + let mut _7: std::result::Result; scope 6 { } scope 7 { @@ -39,8 +37,6 @@ bb0: { StorageLive(_2); StorageLive(_6); - StorageLive(_7); - StorageLive(_8); _6 = discriminant(_1); switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb1]; } @@ -58,15 +54,13 @@ bb3: { _4 = copy ((_2 as Break).0: std::result::Result); - _10 = copy ((_4 as Err).0: i32); - _0 = Result::::Err(copy _10); + _8 = copy ((_4 as Err).0: i32); + _0 = Result::::Err(copy _8); StorageDead(_2); return; } bb4: { - StorageDead(_8); - StorageDead(_7); StorageDead(_6); _3 = discriminant(_2); - switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; @@ -74,24 +68,20 @@ } bb5: { - _8 = copy ((_1 as Err).0: i32); - StorageLive(_9); - _9 = Result::::Err(copy _8); - _2 = ControlFlow::, i32>::Break(move _9); - StorageDead(_9); + StorageLive(_7); + _7 = Result::::Err(copy ((_1 as Err).0: i32)); + _2 = ControlFlow::, i32>::Break(move _7); + StorageDead(_7); - goto -> bb4; + goto -> bb7; } bb6: { - _7 = copy ((_1 as Ok).0: i32); - _2 = ControlFlow::, i32>::Continue(copy _7); + _2 = ControlFlow::, i32>::Continue(copy ((_1 as Ok).0: i32)); goto -> bb4; + } + + bb7: { -+ StorageDead(_8); -+ StorageDead(_7); + StorageDead(_6); + _3 = discriminant(_2); + goto -> bb3;