diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs index 2d77291293d53..e4b3b8b926213 100644 --- a/compiler/rustc_mir_transform/src/sroa.rs +++ b/compiler/rustc_mir_transform/src/sroa.rs @@ -6,23 +6,29 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_mir_dataflow::value_analysis::{excluded_locals, iter_fields}; -use rustc_target::abi::FieldIdx; +use rustc_target::abi::{FieldIdx, ReprFlags, FIRST_VARIANT}; pub struct ScalarReplacementOfAggregates; impl<'tcx> MirPass<'tcx> for ScalarReplacementOfAggregates { fn is_enabled(&self, sess: &rustc_session::Session) -> bool { - sess.mir_opt_level() >= 3 + sess.mir_opt_level() >= 2 } #[instrument(level = "debug", skip(self, tcx, body))] fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { debug!(def_id = ?body.source.def_id()); + + // Avoid query cycles (generators require optimized MIR for layout). + if tcx.type_of(body.source.def_id()).subst_identity().is_generator() { + return; + } + let mut excluded = excluded_locals(body); let param_env = tcx.param_env_reveal_all_normalized(body.source.def_id()); loop { debug!(?excluded); - let escaping = escaping_locals(&excluded, body); + let escaping = escaping_locals(tcx, param_env, &excluded, body); debug!(?escaping); let replacements = compute_flattening(tcx, param_env, body, escaping); debug!(?replacements); @@ -48,11 +54,45 @@ impl<'tcx> MirPass<'tcx> for ScalarReplacementOfAggregates { /// - the locals is a union or an enum; /// - the local's address is taken, and thus the relative addresses of the fields are observable to /// client code. -fn escaping_locals(excluded: &BitSet, body: &Body<'_>) -> BitSet { +fn escaping_locals<'tcx>( + tcx: TyCtxt<'tcx>, + param_env: ty::ParamEnv<'tcx>, + excluded: &BitSet, + body: &Body<'tcx>, +) -> BitSet { + let is_excluded_ty = |ty: Ty<'tcx>| { + if ty.is_union() || ty.is_enum() { + return true; + } + if let ty::Adt(def, _substs) = ty.kind() { + if def.repr().flags.contains(ReprFlags::IS_SIMD) { + // Exclude #[repr(simd)] types so that they are not de-optimized into an array + return true; + } + // We already excluded unions and enums, so this ADT must have one variant + let variant = def.variant(FIRST_VARIANT); + if variant.fields.len() > 1 { + // If this has more than one field, it cannot be a wrapper that only provides a + // niche, so we do not want to automatically exclude it. + return false; + } + let Ok(layout) = tcx.layout_of(param_env.and(ty)) else { + // We can't get the layout + return true; + }; + if layout.layout.largest_niche().is_some() { + // This type has a niche + return true; + } + } + // Default for non-ADTs + false + }; + let mut set = BitSet::new_empty(body.local_decls.len()); set.insert_range(RETURN_PLACE..=Local::from_usize(body.arg_count)); for (local, decl) in body.local_decls().iter_enumerated() { - if decl.ty.is_union() || decl.ty.is_enum() || excluded.contains(local) { + if excluded.contains(local) || is_excluded_ty(decl.ty) { set.insert(local); } } diff --git a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs index 2ee4d7cca0e3c..6e0eacfe40029 100644 --- a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs +++ b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs @@ -1,4 +1,5 @@ -// compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes +// compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes -Zmir-enable-passes=-ScalarReplacementOfAggregates +// MIR SROA will decompose the closure // min-llvm-version: 15.0 # this test uses opaque pointer notation #![feature(stmt_expr_attributes)] @@ -15,8 +16,8 @@ pub fn outer_function(x: S, y: S) -> usize { // Check that we do not attempt to load from the spilled arg before it is assigned to // when generating debuginfo. // CHECK-LABEL: @outer_function -// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:9:23: 9:25]" -// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]] +// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:10:23: 10:25]" +// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:10:23: 10:25]", ptr [[spill]] // CHECK-NOT: [[load:%.*]] = load ptr, ptr // CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]]) // CHECK: [[inner:%.*]] = getelementptr inbounds %"{{.*}}", ptr [[spill]] diff --git a/tests/incremental/hashes/match_expressions.rs b/tests/incremental/hashes/match_expressions.rs index 4429df6833e48..ecb19480d6547 100644 --- a/tests/incremental/hashes/match_expressions.rs +++ b/tests/incremental/hashes/match_expressions.rs @@ -225,8 +225,9 @@ pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 { } } +// Ignore optimized_mir in cfail2, the only change to optimized MIR is a span. #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] #[rustc_clean(cfg="cfail6")] diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff index d76cd0e2bb818..e82e3f1881153 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff @@ -11,35 +11,33 @@ + debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _5: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 2 { + scope 3 (inlined core::num::::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _8: std::option::Option; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _9: std::result::Result; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug x => _4; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _6: std::option::Option; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _7: std::result::Result; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 4 { + scope 5 (inlined >::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug self => _4; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 6 (inlined convert::num:: for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _12: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ debug u => _4; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + } + scope 7 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _14: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + scope 8 { -+ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + scope 9 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _15: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _13: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } @@ -52,7 +50,7 @@ + } + } + scope 12 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } @@ -70,18 +68,14 @@ - // + span: $DIR/unchecked_shifts.rs:11:7: 11:20 - // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::::unchecked_shl}, val: Value() } + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _11 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { @@ -92,7 +86,7 @@ + } + + bb2: { -+ _9 = Result::::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value() } @@ -100,22 +94,22 @@ + } + + bb3: { -+ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _12 = _7 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _9 = Result::::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { -+ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb5: { -+ _8 = Option::::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + @@ -124,25 +118,23 @@ + } + + bb7: { -+ _14 = move ((_9 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ _8 = Option::::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ _12 = move ((_7 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { -+ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb9: { -+ _5 = move ((_8 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _5 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shl::(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir index f4b2416eaab11..8fa4fdaa49aed 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir @@ -7,38 +7,36 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { scope 1 (inlined core::num::::unchecked_shl) { // at $DIR/unchecked_shifts.rs:11:7: 11:23 debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - let mut _3: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _4: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _13: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _11: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 2 { scope 3 (inlined core::num::::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug x => _4; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _8: std::result::Result; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _11: std::option::Option; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug x => _2; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _6: std::result::Result; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _9: std::option::Option; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 4 { scope 5 (inlined >::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _4; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug self => _2; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL scope 6 (inlined convert::num:: for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL - debug u => _4; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _5: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _6: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _7: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + debug u => _2; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _3: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _4: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _5: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } } scope 7 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _8; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _9: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let _10: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _6; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _7: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let _8: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL scope 8 { - debug x => _10; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug x => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL } } scope 9 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _11; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _14: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _9; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _10: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL scope 10 { - debug val => _13; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + debug val => _11; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL } scope 11 { scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL @@ -49,7 +47,7 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { } } scope 12 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _14; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _12; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL } } } @@ -58,31 +56,27 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { } bb0: { - StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _3 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _4 = move (_3.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_11); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_6); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _5 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _6 = Gt(_4, move _5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - switchInt(move _6) -> [0: bb1, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_4); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _3 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _4 = Gt(_2, move _3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _4) -> [0: bb1, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { - StorageLive(_7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _7 = _4 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _8 = Result::::Ok(move _7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = _2 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Result::::Ok(move _5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL goto -> bb3; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb2: { - _8 = Result::::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Result::::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL // mir::Constant // + span: no-location // + literal: Const { ty: TryFromIntError, val: Value() } @@ -90,45 +84,43 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { } bb3: { - StorageDead(_6); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_10); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _9 = discriminant(_8); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _9) -> [0: bb4, 1: bb5, otherwise: bb9]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_4); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _7 = discriminant(_6); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb9]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb4: { - _10 = move ((_8 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - _11 = Option::::Some(move _10); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + _8 = move ((_6 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _9 = Option::::Some(move _8); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb6; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb5: { - _11 = Option::::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _9 = Option::::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb6; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb6: { - StorageDead(_10); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _12 = discriminant(_11); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _12) -> [1: bb7, otherwise: bb9]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _10 = discriminant(_9); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _10) -> [1: bb7, otherwise: bb9]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL } bb7: { - _13 = move ((_11 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_11); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _0 = unchecked_shl::(_1, move _13) -> [return: bb8, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _11 = move ((_9 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shl::(_1, move _11) -> [return: bb8, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::}, val: Value() } } bb8: { - StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff index f3d3e6090bb3c..f20c7da4747c8 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff @@ -11,35 +11,33 @@ + debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + let mut _5: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 2 { + scope 3 (inlined core::num::::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _8: std::option::Option; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _9: std::result::Result; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug x => _4; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _6: std::option::Option; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _7: std::result::Result; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 4 { + scope 5 (inlined >::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug self => _4; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 6 (inlined convert::num:: for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _12: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ debug u => _4; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + } + scope 7 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _14: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + scope 8 { -+ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + scope 9 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _15: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _13: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } @@ -52,7 +50,7 @@ + } + } + scope 12 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } @@ -70,18 +68,14 @@ - // + span: $DIR/unchecked_shifts.rs:17:7: 17:20 - // + literal: Const { ty: unsafe fn(i16, u32) -> i16 {core::num::::unchecked_shr}, val: Value() } + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _11 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { @@ -92,7 +86,7 @@ + } + + bb2: { -+ _9 = Result::::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value() } @@ -100,22 +94,22 @@ + } + + bb3: { -+ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _12 = _7 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _9 = Result::::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { -+ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb5: { -+ _8 = Option::::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + @@ -124,25 +118,23 @@ + } + + bb7: { -+ _14 = move ((_9 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ _8 = Option::::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ _12 = move ((_7 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { -+ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb9: { -+ _5 = move ((_8 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _5 = move ((_6 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shr::(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir index 67f0fe8932f41..7f737abb9360d 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir @@ -7,38 +7,36 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { scope 1 (inlined core::num::::unchecked_shr) { // at $DIR/unchecked_shifts.rs:17:7: 17:23 debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - let mut _3: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _4: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _13: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _11: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 2 { scope 3 (inlined core::num::::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug x => _4; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _8: std::result::Result; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _11: std::option::Option; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug x => _2; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _6: std::result::Result; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _9: std::option::Option; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 4 { scope 5 (inlined >::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _4; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug self => _2; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL scope 6 (inlined convert::num:: for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL - debug u => _4; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _5: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _6: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _7: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + debug u => _2; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _3: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _4: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _5: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } } scope 7 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _8; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _9: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let _10: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _6; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _7: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let _8: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL scope 8 { - debug x => _10; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug x => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL } } scope 9 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _11; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _14: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _9; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _10: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL scope 10 { - debug val => _13; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + debug val => _11; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL } scope 11 { scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL @@ -49,7 +47,7 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { } } scope 12 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _14; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _12; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL } } } @@ -58,31 +56,27 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { } bb0: { - StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _3 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _4 = move (_3.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_11); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_6); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _5 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _6 = Gt(_4, move _5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - switchInt(move _6) -> [0: bb1, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_4); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _3 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _4 = Gt(_2, move _3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _4) -> [0: bb1, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { - StorageLive(_7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _7 = _4 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _8 = Result::::Ok(move _7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = _2 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Result::::Ok(move _5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL goto -> bb3; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb2: { - _8 = Result::::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Result::::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL // mir::Constant // + span: no-location // + literal: Const { ty: TryFromIntError, val: Value() } @@ -90,45 +84,43 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { } bb3: { - StorageDead(_6); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_10); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _9 = discriminant(_8); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _9) -> [0: bb4, 1: bb5, otherwise: bb9]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_4); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _7 = discriminant(_6); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb9]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb4: { - _10 = move ((_8 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - _11 = Option::::Some(move _10); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + _8 = move ((_6 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _9 = Option::::Some(move _8); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb6; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb5: { - _11 = Option::::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _9 = Option::::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb6; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb6: { - StorageDead(_10); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _12 = discriminant(_11); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _12) -> [1: bb7, otherwise: bb9]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _10 = discriminant(_9); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _10) -> [1: bb7, otherwise: bb9]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL } bb7: { - _13 = move ((_11 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_11); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _0 = unchecked_shr::(_1, move _13) -> [return: bb8, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _11 = move ((_9 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shr::(_1, move _11) -> [return: bb8, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::}, val: Value() } } bb8: { - StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir index 50e0538c13368..0cf9643dfc224 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir @@ -15,20 +15,18 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { scope 7 (inlined std::ptr::write::) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL debug dst => _4; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL debug src => _2; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - let mut _6: *mut u32; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 8 { scope 9 (inlined std::ptr::write::runtime::) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug dst => _6; // in scope 9 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug dst => _4; // in scope 9 at $SRC_DIR/core/src/intrinsics.rs:LL:COL } } } } scope 4 (inlined std::ptr::read::) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL debug src => _3; // in scope 4 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - let mut _5: *const u32; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 5 { scope 6 (inlined std::ptr::read::runtime::) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug src => _5; // in scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug src => _3; // in scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL } } } @@ -38,15 +36,11 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { bb0: { StorageLive(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL _3 = &raw const (*_1); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL _0 = (*_3); // scope 5 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - StorageDead(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL StorageDead(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL StorageLive(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL _4 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL (*_4) = _2; // scope 8 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - StorageDead(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL StorageDead(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL return; // scope 0 at $DIR/mem_replace.rs:+2:2: +2:2 } 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 089b0c23e2ce7..73b5678ce049b 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,24 +3,21 @@ fn ezmap(_1: Option) -> Option { debug x => _1; // in scope 0 at $DIR/simple_option_map.rs:+0:14: +0:15 let mut _0: std::option::Option; // return place in scope 0 at $DIR/simple_option_map.rs:+0:33: +0:44 - let mut _5: i32; // in scope 0 at $DIR/simple_option_map.rs:11:25: 11:29 scope 1 (inlined map::) { // at $DIR/simple_option_map.rs:18:5: 18:22 debug slf => _1; // in scope 1 at $DIR/simple_option_map.rs:6:17: 6:20 debug f => const ZeroSized: [closure@$DIR/simple_option_map.rs:18:12: 18:15]; // in scope 1 at $DIR/simple_option_map.rs:6:33: 6:34 let mut _2: isize; // in scope 1 at $DIR/simple_option_map.rs:11:9: 11:16 let _3: i32; // in scope 1 at $DIR/simple_option_map.rs:11:14: 11:15 - let mut _4: (i32,); // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29 - let mut _6: i32; // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29 + let mut _4: i32; // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29 scope 2 { debug x => _3; // in scope 2 at $DIR/simple_option_map.rs:11:14: 11:15 scope 3 (inlined ezmap::{closure#0}) { // at $DIR/simple_option_map.rs:11:25: 11:29 - debug n => _5; // in scope 3 at $DIR/simple_option_map.rs:+1:13: +1:14 + debug n => _3; // in scope 3 at $DIR/simple_option_map.rs:+1:13: +1:14 } } } bb0: { - StorageLive(_3); // scope 0 at $DIR/simple_option_map.rs:+1:5: +1:22 _2 = discriminant(_1); // scope 1 at $DIR/simple_option_map.rs:10:11: 10:14 switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4]; // scope 1 at $DIR/simple_option_map.rs:10:5: 10:14 } @@ -32,21 +29,14 @@ fn ezmap(_1: Option) -> Option { bb2: { _3 = ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map.rs:11:14: 11:15 - StorageLive(_6); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 StorageLive(_4); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - _4 = (move _3,); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - StorageLive(_5); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - _5 = move (_4.0: i32); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - _6 = Add(_5, const 1_i32); // scope 3 at $DIR/simple_option_map.rs:+1:16: +1:21 - StorageDead(_5); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - StorageDead(_4); // scope 2 at $DIR/simple_option_map.rs:11:28: 11:29 - _0 = Option::::Some(move _6); // scope 2 at $DIR/simple_option_map.rs:11:20: 11:30 - StorageDead(_6); // scope 2 at $DIR/simple_option_map.rs:11:29: 11:30 + _4 = Add(_3, const 1_i32); // scope 3 at $DIR/simple_option_map.rs:+1:16: +1:21 + _0 = Option::::Some(move _4); // scope 2 at $DIR/simple_option_map.rs:11:20: 11:30 + StorageDead(_4); // scope 2 at $DIR/simple_option_map.rs:11:29: 11:30 goto -> bb3; // scope 1 at $DIR/simple_option_map.rs:14:1: 14:2 } bb3: { - StorageDead(_3); // scope 0 at $DIR/simple_option_map.rs:+1:5: +1:22 return; // scope 0 at $DIR/simple_option_map.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir index b05d44f4d60ab..6c3062805365c 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir @@ -21,19 +21,17 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { debug self => _2; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL debug slice => _6; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL let mut _7: *mut u32; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _10: usize; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - let mut _11: *mut [u32]; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 5 { debug this => _2; // in scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 6 { scope 7 (inlined >::get_unchecked_mut::runtime::) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug this => _10; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug slice => _11; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug this => _2; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug slice => _6; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 8 (inlined ptr::mut_ptr::::len) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug self => _11; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - let mut _12: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _6; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _10: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 9 (inlined std::ptr::metadata::<[u32]>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug ptr => _12; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + debug ptr => _10; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL scope 10 { } } @@ -81,14 +79,10 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { StorageLive(_6); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL _6 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageLive(_10); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_11); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageLive(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL _7 = _6 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL _8 = Offset(_7, _2); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL StorageDead(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageDead(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageDead(_11); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageDead(_10); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageDead(_6); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL _9 = &mut (*_8); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir index 6d9ec5d9a27f5..727ccc1de5350 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir @@ -4,65 +4,63 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:45: +0:50 debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:64: +0:69 let mut _0: &mut [u32]; // return place in scope 0 at $DIR/slice_index.rs:+0:88: +0:98 + let mut _3: usize; // in scope 0 at $DIR/slice_index.rs:+1:29: +1:34 + let mut _4: usize; // in scope 0 at $DIR/slice_index.rs:+1:29: +1:34 scope 1 (inlined core::slice::::get_unchecked_mut::>) { // at $DIR/slice_index.rs:26:11: 26:35 debug self => _1; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - debug index => _2; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - let mut _3: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - let mut _15: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + debug index => std::ops::Range{ .0 => _3, .1 => _4, }; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + let mut _5: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + let mut _14: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL scope 2 { scope 3 (inlined as SliceIndex<[u32]>>::get_unchecked_mut) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL - debug self => _2; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug slice => _3; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _4: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _5: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug self => std::ops::Range{ .0 => _3, .1 => _4, }; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug slice => _5; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL let mut _7: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _8: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _9: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _10: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let _16: std::ops::Range; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _17: std::ops::Range; // in scope 3 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - let mut _18: *mut [u32]; // in scope 3 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + let mut _8: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _9: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let _16: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let _17: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 4 { - debug this => _16; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug this => std::ops::Range{ .0 => _16, .1 => _17, }; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 5 { let _6: usize; // in scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 6 { debug new_len => _6; // in scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 11 (inlined ptr::mut_ptr::::as_mut_ptr) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug self => _3; // in scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _5; // in scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL } scope 12 (inlined ptr::mut_ptr::::add) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL debug self => _7; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug count => _8; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug count => _3; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 13 { } } scope 14 (inlined slice_from_raw_parts_mut::) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug data => _9; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - debug len => _10; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - let mut _11: *mut (); // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + debug data => _8; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + debug len => _9; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + let mut _10: *mut (); // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL scope 15 (inlined ptr::mut_ptr::::cast::<()>) { // at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - debug self => _9; // in scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _8; // in scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL } scope 16 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { // at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - debug data_address => _11; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - debug metadata => _10; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - let mut _12: *const (); // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - let mut _13: std::ptr::metadata::PtrComponents<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - let mut _14: std::ptr::metadata::PtrRepr<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + debug data_address => _10; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + debug metadata => _9; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + let mut _11: *const (); // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + let mut _12: std::ptr::metadata::PtrComponents<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + let mut _13: std::ptr::metadata::PtrRepr<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL scope 17 { } } } } scope 7 (inlined as SliceIndex<[T]>>::get_unchecked_mut::runtime::) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug this => _17; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug slice => _18; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug this => std::ops::Range{ .0 => _16, .1 => _17, }; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug slice => _5; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 8 (inlined ptr::mut_ptr::::len) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug self => _18; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - let mut _19: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _5; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _15: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 9 (inlined std::ptr::metadata::<[u32]>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug ptr => _19; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + debug ptr => _15; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL scope 10 { } } @@ -75,60 +73,51 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> } bb0: { + _3 = move (_2.0: usize); // scope 0 at $DIR/slice_index.rs:+1:29: +1:34 + _4 = move (_2.1: usize); // scope 0 at $DIR/slice_index.rs:+1:29: +1:34 + StorageLive(_14); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _5 = &raw mut (*_1); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageLive(_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - _3 = &raw mut (*_1); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageLive(_16); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageLive(_17); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageLive(_18); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageLive(_19); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageLive(_6); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_4); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _4 = (_2.1: usize); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_5); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _5 = (_2.0: usize); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _6 = unchecked_sub::(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _6 = unchecked_sub::(_4, _3) -> [return: bb1, unwind unreachable]; // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/slice/index.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize, usize) -> usize {unchecked_sub::}, val: Value() } } bb1: { - StorageDead(_5); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageDead(_4); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _7 = _3 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL StorageLive(_8); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _8 = (_2.0: usize); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _9 = Offset(_7, _8); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageDead(_8); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _7 = _5 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + _8 = Offset(_7, _3); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL StorageDead(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_10); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _10 = _6; // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_11); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - _11 = _9 as *mut () (PtrToPtr); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageLive(_14); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageLive(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _9 = _6; // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_10); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + _10 = _8 as *mut () (PtrToPtr); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL StorageLive(_13); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL StorageLive(_12); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - _12 = _11 as *const () (Pointer(MutToConstPointer)); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - _13 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _12, metadata: _10 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageLive(_11); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _11 = _10 as *const () (Pointer(MutToConstPointer)); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _12 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _11, metadata: _9 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_11); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _13 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _12 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL StorageDead(_12); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - _14 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _13 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - StorageDead(_13); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - _15 = (_14.1: *mut [u32]); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - StorageDead(_14); // scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - StorageDead(_11); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - StorageDead(_10); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _14 = (_13.1: *mut [u32]); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_13); // scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_10); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL StorageDead(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_8); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageDead(_6); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageDead(_19); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageDead(_18); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageDead(_17); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageDead(_16); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - _0 = &mut (*_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageDead(_15); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _0 = &mut (*_14); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_14); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir index 0cf1d68d18a2e..0c18fb84bcd74 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir @@ -39,21 +39,20 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 13 (inlined NonNull::::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL debug ptr => _9; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL let mut _10: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - let mut _22: *mut T; // in scope 13 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug ptr => _22; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug ptr => _9; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 16 (inlined ptr::mut_ptr::::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - debug self => _22; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - let mut _23: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _9; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _22: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 17 { scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug ptr => _23; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug ptr => _22; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 19 (inlined ptr::mut_ptr::::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug self => _23; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _22; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 20 { scope 21 (inlined ptr::mut_ptr::::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug self => _23; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _22; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL } } } @@ -122,10 +121,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageLive(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageLive(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL - StorageLive(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL _10 = _9 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL _11 = NonNull:: { pointer: _10 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - StorageDead(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_9); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir index 4fde50c6fe43a..1aa05cbeb9770 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir @@ -44,21 +44,20 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 13 (inlined NonNull::::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL debug ptr => _9; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL let mut _10: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - let mut _24: *mut T; // in scope 13 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug ptr => _24; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug ptr => _9; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 16 (inlined ptr::mut_ptr::::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - debug self => _24; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - let mut _25: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _9; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _24: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 17 { scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug ptr => _25; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug ptr => _24; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 19 (inlined ptr::mut_ptr::::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug self => _25; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _24; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 20 { scope 21 (inlined ptr::mut_ptr::::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug self => _25; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _24; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL } } } @@ -134,10 +133,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageLive(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageLive(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL - StorageLive(_25); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL _10 = _9 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL _11 = NonNull:: { pointer: _10 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - StorageDead(_25); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_9); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL