From d05545c05d9399a70a796cfd18b60416909e2d6b Mon Sep 17 00:00:00 2001
From: Scott McMurray <scottmcm@users.noreply.github.com>
Date: Sun, 14 Apr 2024 18:22:35 -0700
Subject: [PATCH 1/5] At debuginfo=0, don't inline debuginfo when inlining

---
 compiler/rustc_mir_transform/src/inline.rs    |   6 +-
 tests/codegen/mem-replace-simple-type.rs      |   6 +-
 tests/codegen/slice-ref-equality.rs           |  32 ++--
 ...inherit_overflow.main.GVN.panic-abort.diff |   2 -
 ...nherit_overflow.main.GVN.panic-unwind.diff |   2 -
 ...n.DataflowConstProp.32bit.panic-abort.diff |   4 -
 ....DataflowConstProp.32bit.panic-unwind.diff |   4 -
 ...n.DataflowConstProp.64bit.panic-abort.diff |   4 -
 ....DataflowConstProp.64bit.panic-unwind.diff |   4 -
 ...oxed_slice.main.GVN.32bit.panic-abort.diff |   4 -
 ...xed_slice.main.GVN.32bit.panic-unwind.diff |   4 -
 ...oxed_slice.main.GVN.64bit.panic-abort.diff |   4 -
 ...xed_slice.main.GVN.64bit.panic-unwind.diff |   4 -
 ...ow.main.DataflowConstProp.panic-abort.diff |   2 -
 ...w.main.DataflowConstProp.panic-unwind.diff |   2 -
 tests/mir-opt/dest-prop/union.rs              |   2 +-
 ...to_exponential_common.GVN.panic-abort.diff |   2 -
 ...o_exponential_common.GVN.panic-unwind.diff |   2 -
 tests/mir-opt/inline/asm_unwind.rs            |   2 +-
 tests/mir-opt/inline/cycle.rs                 |   2 +-
 tests/mir-opt/inline/dyn_trait.rs             |   1 +
 tests/mir-opt/inline/inline_any_operand.rs    |   2 +-
 tests/mir-opt/inline/inline_closure.rs        |   2 +-
 ...e_closure_borrows_arg.foo.Inline.after.mir |   3 -
 ...line_closure_captures.foo.Inline.after.mir |   3 -
 ...ine_coroutine.main.Inline.panic-abort.diff |   1 -
 ...ne_coroutine.main.Inline.panic-unwind.diff |   1 -
 tests/mir-opt/inline/inline_coroutine.rs      |   2 +-
 tests/mir-opt/inline/inline_cycle.rs          |   1 +
 tests/mir-opt/inline/inline_diverging.rs      |   2 +-
 tests/mir-opt/inline/inline_retag.rs          |   2 +-
 tests/mir-opt/inline/inline_trait_method_2.rs |   2 +-
 tests/mir-opt/inline/issue_106141.rs          |   1 +
 .../issue_58867_inline_as_ref_as_mut.rs       |   2 +
 ...ine_scopes_parenting.main.Inline.after.mir |   6 +-
 .../issue_76997_inline_scopes_parenting.rs    |   1 +
 tests/mir-opt/inline/issue_78442.rs           |   2 +-
 ...l_unsigned_smaller.Inline.panic-abort.diff |   2 -
 ..._unsigned_smaller.Inline.panic-unwind.diff |   2 -
 ...d_smaller.PreCodegen.after.panic-abort.mir |   2 -
 ..._smaller.PreCodegen.after.panic-unwind.mir |   2 -
 ..._shr_signed_bigger.Inline.panic-abort.diff |   2 -
 ...shr_signed_bigger.Inline.panic-unwind.diff |   2 -
 ...ed_bigger.PreCodegen.after.panic-abort.mir |   2 -
 ...d_bigger.PreCodegen.after.panic-unwind.mir |   2 -
 ...d.unwrap_unchecked.Inline.panic-abort.diff |   2 -
 ....unwrap_unchecked.Inline.panic-unwind.diff |   2 -
 ...unchecked.PreCodegen.after.panic-abort.mir |   2 -
 ...nchecked.PreCodegen.after.panic-unwind.mir |   2 -
 ...y.run2-{closure#0}.Inline.panic-abort.diff |   8 -
 ....run2-{closure#0}.Inline.panic-unwind.diff |   8 -
 ...line_generically_if_sized.call.Inline.diff |   1 -
 .../casts.redundant.InstSimplify.diff         |   1 -
 ...b_check.unwrap_unchecked.InstSimplify.diff |   2 -
 .../issue_101973.inner.GVN.panic-abort.diff   |   9 +-
 .../issue_101973.inner.GVN.panic-unwind.diff  |   9 +-
 ..._to_digit.PreCodegen.after.panic-abort.mir |  40 ++---
 ...to_digit.PreCodegen.after.panic-unwind.mir |  40 ++---
 ...ng.identity.JumpThreading.panic-abort.diff |   6 -
 ...g.identity.JumpThreading.panic-unwind.diff |   6 -
 ...ecked_ops.checked_shl.PreCodegen.after.mir |   6 -
 ...cked_ops.step_forward.PreCodegen.after.mir |  79 +++++++++-
 ....{impl#0}-partial_cmp.PreCodegen.after.mir |  68 +++------
 .../intrinsics.f_u64.PreCodegen.after.mir     |   1 -
 .../intrinsics.f_unit.PreCodegen.after.mir    |   1 -
 ...d_constant.main.GVN.32bit.panic-abort.diff |   8 -
 ..._constant.main.GVN.32bit.panic-unwind.diff |   5 -
 ...d_constant.main.GVN.64bit.panic-abort.diff |   8 -
 ..._constant.main.GVN.64bit.panic-unwind.diff |   5 -
 ...m_replace.PreCodegen.after.panic-abort.mir |   6 -
 ..._replace.PreCodegen.after.panic-unwind.mir |   6 -
 ...ward_loop.PreCodegen.after.panic-abort.mir | 107 +++++--------
 ...ard_loop.PreCodegen.after.panic-unwind.mir | 107 +++++--------
 ...sive_loop.PreCodegen.after.panic-abort.mir |   4 -
 ...ive_loop.PreCodegen.after.panic-unwind.mir |   4 -
 ...iter_next.PreCodegen.after.panic-abort.mir |   1 -
 ...ter_next.PreCodegen.after.panic-unwind.mir |   1 -
 ...iter_next.PreCodegen.after.panic-abort.mir |  57 +++----
 ...ter_next.PreCodegen.after.panic-unwind.mir |  57 +++----
 ...mple_option_map.ezmap.PreCodegen.after.mir |   4 -
 ...mut_usize.PreCodegen.after.panic-abort.mir |   2 -
 ...ut_usize.PreCodegen.after.panic-unwind.mir |   2 -
 ...mut_range.PreCodegen.after.panic-abort.mir |   2 -
 ...ut_range.PreCodegen.after.panic-unwind.mir |   2 -
 ...dex_range.PreCodegen.after.panic-abort.mir |   2 -
 ...ex_range.PreCodegen.after.panic-unwind.mir |   2 -
 ...ated_loop.PreCodegen.after.panic-abort.mir | 141 ++++++++---------
 ...ted_loop.PreCodegen.after.panic-unwind.mir | 141 ++++++++---------
 ...ward_loop.PreCodegen.after.panic-abort.mir | 125 +++++++--------
 ...ard_loop.PreCodegen.after.panic-unwind.mir | 125 +++++++--------
 ...ange_loop.PreCodegen.after.panic-abort.mir | 123 ++++++---------
 ...nge_loop.PreCodegen.after.panic-unwind.mir | 123 ++++++---------
 ...erse_loop.PreCodegen.after.panic-abort.mir | 144 ++++++++----------
 ...rse_loop.PreCodegen.after.panic-unwind.mir | 144 ++++++++----------
 tests/mir-opt/pre-codegen/spans.rs            |   2 +-
 ...neric.RemoveUnneededDrops.panic-abort.diff |   1 -
 ...eric.RemoveUnneededDrops.panic-unwind.diff |   1 -
 ...t_opt.RemoveUnneededDrops.panic-abort.diff |   1 -
 ..._opt.RemoveUnneededDrops.panic-unwind.diff |   1 -
 ...s.opt.RemoveUnneededDrops.panic-abort.diff |   1 -
 ....opt.RemoveUnneededDrops.panic-unwind.diff |   1 -
 ..._copy.RemoveUnneededDrops.panic-abort.diff |   1 -
 ...copy.RemoveUnneededDrops.panic-unwind.diff |   1 -
 ...e_const_switch.identity.JumpThreading.diff |  81 ++++------
 104 files changed, 791 insertions(+), 1195 deletions(-)

diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs
index 60513a674af95..1182a73840280 100644
--- a/compiler/rustc_mir_transform/src/inline.rs
+++ b/compiler/rustc_mir_transform/src/inline.rs
@@ -11,7 +11,7 @@ use rustc_middle::mir::visit::*;
 use rustc_middle::mir::*;
 use rustc_middle::ty::TypeVisitableExt;
 use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
-use rustc_session::config::OptLevel;
+use rustc_session::config::{DebugInfo, OptLevel};
 use rustc_span::source_map::Spanned;
 use rustc_span::sym;
 use rustc_target::abi::FieldIdx;
@@ -699,7 +699,9 @@ impl<'tcx> Inliner<'tcx> {
         // Insert all of the (mapped) parts of the callee body into the caller.
         caller_body.local_decls.extend(callee_body.drain_vars_and_temps());
         caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
-        caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
+        if self.tcx.sess.opts.debuginfo != DebugInfo::None {
+            caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
+        }
         caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
 
         caller_body[callsite.block].terminator = Some(Terminator {
diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs
index 50b43f5854a1a..7209fa21925ad 100644
--- a/tests/codegen/mem-replace-simple-type.rs
+++ b/tests/codegen/mem-replace-simple-type.rs
@@ -34,18 +34,20 @@ pub fn replace_ref_str<'a>(r: &mut &'a str, v: &'a str) -> &'a str {
 
 #[no_mangle]
 // CHECK-LABEL: @replace_short_array_3(
+// CHECK-SAME: ptr{{.+}}sret{{.+}}%[[RET:.+]], ptr{{.+}}%r, ptr{{.+}}%v
 pub fn replace_short_array_3(r: &mut [u32; 3], v: [u32; 3]) -> [u32; 3] {
     // CHECK-NOT: alloca
-    // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %result, ptr align 4 %r, i64 12, i1 false)
+    // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[RET]], ptr align 4 %r, i64 12, i1 false)
     // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %r, ptr align 4 %v, i64 12, i1 false)
     std::mem::replace(r, v)
 }
 
 #[no_mangle]
 // CHECK-LABEL: @replace_short_array_4(
+// CHECK-SAME: ptr{{.+}}sret{{.+}}%[[RET:.+]], ptr{{.+}}%r, ptr{{.+}}%v
 pub fn replace_short_array_4(r: &mut [u32; 4], v: [u32; 4]) -> [u32; 4] {
     // CHECK-NOT: alloca
-    // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %result, ptr align 4 %r, i64 16, i1 false)
+    // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[RET]], ptr align 4 %r, i64 16, i1 false)
     // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %r, ptr align 4 %v, i64 16, i1 false)
     std::mem::replace(r, v)
 }
diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs
index 85d9c34a30b5a..7ab70108fe0c1 100644
--- a/tests/codegen/slice-ref-equality.rs
+++ b/tests/codegen/slice-ref-equality.rs
@@ -43,48 +43,48 @@ pub fn is_zero_array(data: &[u8; 4]) -> bool {
 // equality for non-byte types also just emit a `bcmp`, not a loop.
 
 // CHECK-LABEL: @eq_slice_of_nested_u8(
-// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
-// CHECK-SAME: [[USIZE]] noundef %3
+// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1
+// CHECK-SAME: [[USIZE]] noundef %y.1
 #[no_mangle]
 fn eq_slice_of_nested_u8(x: &[[u8; 3]], y: &[[u8; 3]]) -> bool {
-    // CHECK: icmp eq [[USIZE]] %1, %3
-    // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %1, 3
+    // CHECK: icmp eq [[USIZE]] %x.1, %y.1
+    // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] {{%x.1|%y.1}}, 3
     // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
     // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]])
     x == y
 }
 
 // CHECK-LABEL: @eq_slice_of_i32(
-// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
-// CHECK-SAME: [[USIZE]] noundef %3
+// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1
+// CHECK-SAME: [[USIZE]] noundef %y.1
 #[no_mangle]
 fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool {
-    // CHECK: icmp eq [[USIZE]] %1, %3
-    // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2
+    // CHECK: icmp eq [[USIZE]] %x.1, %y.1
+    // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] {{%x.1|%y.1}}, 2
     // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
     // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]])
     x == y
 }
 
 // CHECK-LABEL: @eq_slice_of_nonzero(
-// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
-// CHECK-SAME: [[USIZE]] noundef %3
+// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1
+// CHECK-SAME: [[USIZE]] noundef %y.1
 #[no_mangle]
 fn eq_slice_of_nonzero(x: &[NonZero<i32>], y: &[NonZero<i32>]) -> bool {
-    // CHECK: icmp eq [[USIZE]] %1, %3
-    // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2
+    // CHECK: icmp eq [[USIZE]] %x.1, %y.1
+    // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] {{%x.1|%y.1}}, 2
     // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
     // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]])
     x == y
 }
 
 // CHECK-LABEL: @eq_slice_of_option_of_nonzero(
-// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
-// CHECK-SAME: [[USIZE]] noundef %3
+// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1
+// CHECK-SAME: [[USIZE]] noundef %y.1
 #[no_mangle]
 fn eq_slice_of_option_of_nonzero(x: &[Option<NonZero<i16>>], y: &[Option<NonZero<i16>>]) -> bool {
-    // CHECK: icmp eq [[USIZE]] %1, %3
-    // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 1
+    // CHECK: icmp eq [[USIZE]] %x.1, %y.1
+    // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] {{%x.1|%y.1}}, 1
     // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
     // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]])
     x == y
diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff
index 4c2df228eb853..8c5a0df94f428 100644
--- a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff
+++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff
@@ -9,8 +9,6 @@
       scope 1 {
       }
       scope 2 (inlined #[track_caller] <u8 as Add>::add) {
-          debug self => _2;
-          debug other => _3;
           let mut _4: (u8, bool);
       }
   
diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff
index c4e666b489e0b..7887a8a907277 100644
--- a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff
@@ -9,8 +9,6 @@
       scope 1 {
       }
       scope 2 (inlined #[track_caller] <u8 as Add>::add) {
-          debug self => _2;
-          debug other => _3;
           let mut _4: (u8, bool);
       }
   
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff
index 44e73b5609822..8005bc23cf699 100644
--- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff
@@ -12,16 +12,13 @@
           let _3: std::ptr::Unique<[bool]>;
           let mut _4: std::ptr::Unique<[bool; 0]>;
           scope 3 {
-              debug ptr => _3;
           }
           scope 4 (inlined Unique::<[bool; 0]>::dangling) {
               let mut _5: std::ptr::NonNull<[bool; 0]>;
               scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
                   let _6: *mut [bool; 0];
                   scope 6 {
-                      debug ptr => _6;
                       scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
-                          debug ptr => _6;
                           let mut _8: bool;
                           let _9: ();
                           let mut _10: *mut ();
@@ -37,7 +34,6 @@
                       scope 8 (inlined align_of::<[bool; 0]>) {
                       }
                       scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
-                          debug addr => _7;
                       }
                   }
               }
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff
index 6cef8b692ba7f..42b1be32387c4 100644
--- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff
@@ -12,16 +12,13 @@
           let _3: std::ptr::Unique<[bool]>;
           let mut _4: std::ptr::Unique<[bool; 0]>;
           scope 3 {
-              debug ptr => _3;
           }
           scope 4 (inlined Unique::<[bool; 0]>::dangling) {
               let mut _5: std::ptr::NonNull<[bool; 0]>;
               scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
                   let _6: *mut [bool; 0];
                   scope 6 {
-                      debug ptr => _6;
                       scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
-                          debug ptr => _6;
                           let mut _8: bool;
                           let _9: ();
                           let mut _10: *mut ();
@@ -37,7 +34,6 @@
                       scope 8 (inlined align_of::<[bool; 0]>) {
                       }
                       scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
-                          debug addr => _7;
                       }
                   }
               }
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff
index 6efccded99397..7b57b0db50c94 100644
--- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff
@@ -12,16 +12,13 @@
           let _3: std::ptr::Unique<[bool]>;
           let mut _4: std::ptr::Unique<[bool; 0]>;
           scope 3 {
-              debug ptr => _3;
           }
           scope 4 (inlined Unique::<[bool; 0]>::dangling) {
               let mut _5: std::ptr::NonNull<[bool; 0]>;
               scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
                   let _6: *mut [bool; 0];
                   scope 6 {
-                      debug ptr => _6;
                       scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
-                          debug ptr => _6;
                           let mut _8: bool;
                           let _9: ();
                           let mut _10: *mut ();
@@ -37,7 +34,6 @@
                       scope 8 (inlined align_of::<[bool; 0]>) {
                       }
                       scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
-                          debug addr => _7;
                       }
                   }
               }
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff
index a705d0064cbac..2e75a63e29052 100644
--- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff
@@ -12,16 +12,13 @@
           let _3: std::ptr::Unique<[bool]>;
           let mut _4: std::ptr::Unique<[bool; 0]>;
           scope 3 {
-              debug ptr => _3;
           }
           scope 4 (inlined Unique::<[bool; 0]>::dangling) {
               let mut _5: std::ptr::NonNull<[bool; 0]>;
               scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
                   let _6: *mut [bool; 0];
                   scope 6 {
-                      debug ptr => _6;
                       scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
-                          debug ptr => _6;
                           let mut _8: bool;
                           let _9: ();
                           let mut _10: *mut ();
@@ -37,7 +34,6 @@
                       scope 8 (inlined align_of::<[bool; 0]>) {
                       }
                       scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
-                          debug addr => _7;
                       }
                   }
               }
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff
index f9c854ca3f47c..ca445046279b8 100644
--- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff
@@ -12,16 +12,13 @@
           let _3: std::ptr::Unique<[bool]>;
           let mut _4: std::ptr::Unique<[bool; 0]>;
           scope 3 {
-              debug ptr => _3;
           }
           scope 4 (inlined Unique::<[bool; 0]>::dangling) {
               let mut _5: std::ptr::NonNull<[bool; 0]>;
               scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
                   let _6: *mut [bool; 0];
                   scope 6 {
-                      debug ptr => _6;
                       scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
-                          debug ptr => _6;
                           let mut _8: bool;
                           let _9: ();
                           let mut _10: *mut ();
@@ -37,7 +34,6 @@
                       scope 8 (inlined align_of::<[bool; 0]>) {
                       }
                       scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
-                          debug addr => _7;
                       }
                   }
               }
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff
index 333726689d7af..1f498c65fa780 100644
--- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff
@@ -12,16 +12,13 @@
           let _3: std::ptr::Unique<[bool]>;
           let mut _4: std::ptr::Unique<[bool; 0]>;
           scope 3 {
-              debug ptr => _3;
           }
           scope 4 (inlined Unique::<[bool; 0]>::dangling) {
               let mut _5: std::ptr::NonNull<[bool; 0]>;
               scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
                   let _6: *mut [bool; 0];
                   scope 6 {
-                      debug ptr => _6;
                       scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
-                          debug ptr => _6;
                           let mut _8: bool;
                           let _9: ();
                           let mut _10: *mut ();
@@ -37,7 +34,6 @@
                       scope 8 (inlined align_of::<[bool; 0]>) {
                       }
                       scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
-                          debug addr => _7;
                       }
                   }
               }
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff
index e1841760077dd..da72e581496e1 100644
--- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff
@@ -12,16 +12,13 @@
           let _3: std::ptr::Unique<[bool]>;
           let mut _4: std::ptr::Unique<[bool; 0]>;
           scope 3 {
-              debug ptr => _3;
           }
           scope 4 (inlined Unique::<[bool; 0]>::dangling) {
               let mut _5: std::ptr::NonNull<[bool; 0]>;
               scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
                   let _6: *mut [bool; 0];
                   scope 6 {
-                      debug ptr => _6;
                       scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
-                          debug ptr => _6;
                           let mut _8: bool;
                           let _9: ();
                           let mut _10: *mut ();
@@ -37,7 +34,6 @@
                       scope 8 (inlined align_of::<[bool; 0]>) {
                       }
                       scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
-                          debug addr => _7;
                       }
                   }
               }
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff
index 7aa02556ec5e2..920e66452e3b3 100644
--- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff
@@ -12,16 +12,13 @@
           let _3: std::ptr::Unique<[bool]>;
           let mut _4: std::ptr::Unique<[bool; 0]>;
           scope 3 {
-              debug ptr => _3;
           }
           scope 4 (inlined Unique::<[bool; 0]>::dangling) {
               let mut _5: std::ptr::NonNull<[bool; 0]>;
               scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
                   let _6: *mut [bool; 0];
                   scope 6 {
-                      debug ptr => _6;
                       scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
-                          debug ptr => _6;
                           let mut _8: bool;
                           let _9: ();
                           let mut _10: *mut ();
@@ -37,7 +34,6 @@
                       scope 8 (inlined align_of::<[bool; 0]>) {
                       }
                       scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
-                          debug addr => _7;
                       }
                   }
               }
diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff
index 09fc48043b9c8..ca1bd737caf06 100644
--- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff
+++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff
@@ -9,8 +9,6 @@
       scope 1 {
       }
       scope 2 (inlined #[track_caller] <u8 as Add>::add) {
-          debug self => _2;
-          debug other => _3;
           let mut _4: (u8, bool);
       }
   
diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff
index c0b26080f56fe..0d7fe9360c117 100644
--- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff
+++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff
@@ -9,8 +9,6 @@
       scope 1 {
       }
       scope 2 (inlined #[track_caller] <u8 as Add>::add) {
-          debug self => _2;
-          debug other => _3;
           let mut _4: (u8, bool);
       }
   
diff --git a/tests/mir-opt/dest-prop/union.rs b/tests/mir-opt/dest-prop/union.rs
index abd1f1b2c937a..66fadd8471225 100644
--- a/tests/mir-opt/dest-prop/union.rs
+++ b/tests/mir-opt/dest-prop/union.rs
@@ -1,7 +1,7 @@
 // skip-filecheck
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
 //! Tests that we can propagate into places that are projections into unions
-//@ compile-flags: -Zunsound-mir-opts
+//@ compile-flags: -Zunsound-mir-opts -C debuginfo=full
 fn val() -> u32 {
     1
 }
diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff
index bd346af6d16e4..8a701641ff9ab 100644
--- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff
+++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff
@@ -29,13 +29,11 @@
                   debug precision => _8;
                   let _8: usize;
                   scope 5 (inlined Formatter::<'_>::precision) {
-                      debug self => _1;
                   }
               }
           }
       }
       scope 4 (inlined Formatter::<'_>::sign_plus) {
-          debug self => _1;
           let mut _20: u32;
           let mut _21: u32;
       }
diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff
index 422cbeaa224ea..5e65700ee4aae 100644
--- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff
+++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff
@@ -29,13 +29,11 @@
                   debug precision => _8;
                   let _8: usize;
                   scope 5 (inlined Formatter::<'_>::precision) {
-                      debug self => _1;
                   }
               }
           }
       }
       scope 4 (inlined Formatter::<'_>::sign_plus) {
-          debug self => _1;
           let mut _20: u32;
           let mut _21: u32;
       }
diff --git a/tests/mir-opt/inline/asm_unwind.rs b/tests/mir-opt/inline/asm_unwind.rs
index 7708f567c7172..8a102b2f56138 100644
--- a/tests/mir-opt/inline/asm_unwind.rs
+++ b/tests/mir-opt/inline/asm_unwind.rs
@@ -3,7 +3,7 @@
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
 //@ needs-asm-support
 //@ needs-unwind
-//@ compile-flags: -Zinline-mir-hint-threshold=1000
+//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full
 #![feature(asm_unwind)]
 
 struct D;
diff --git a/tests/mir-opt/inline/cycle.rs b/tests/mir-opt/inline/cycle.rs
index b2eacfe33b17f..cb50638473f6c 100644
--- a/tests/mir-opt/inline/cycle.rs
+++ b/tests/mir-opt/inline/cycle.rs
@@ -1,5 +1,5 @@
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
-//@ compile-flags: -Zinline-mir-hint-threshold=1000
+//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full
 
 // EMIT_MIR cycle.f.Inline.diff
 #[inline(always)]
diff --git a/tests/mir-opt/inline/dyn_trait.rs b/tests/mir-opt/inline/dyn_trait.rs
index ecf220a85e6a3..d991403a5aced 100644
--- a/tests/mir-opt/inline/dyn_trait.rs
+++ b/tests/mir-opt/inline/dyn_trait.rs
@@ -1,4 +1,5 @@
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+//@ compile-flags: -C debuginfo=full
 #![crate_type = "lib"]
 
 use std::fmt::Debug;
diff --git a/tests/mir-opt/inline/inline_any_operand.rs b/tests/mir-opt/inline/inline_any_operand.rs
index 8151949214b1f..b34f71a697923 100644
--- a/tests/mir-opt/inline/inline_any_operand.rs
+++ b/tests/mir-opt/inline/inline_any_operand.rs
@@ -1,4 +1,4 @@
-//@ compile-flags: -Z span_free_formats
+//@ compile-flags: -Z span_free_formats -C debuginfo=full
 
 // Tests that MIR inliner works for any operand
 
diff --git a/tests/mir-opt/inline/inline_closure.rs b/tests/mir-opt/inline/inline_closure.rs
index 9a3cf54ef078b..a5954955c0f88 100644
--- a/tests/mir-opt/inline/inline_closure.rs
+++ b/tests/mir-opt/inline/inline_closure.rs
@@ -1,4 +1,4 @@
-//@ compile-flags: -Z span_free_formats
+//@ compile-flags: -Z span_free_formats -C debuginfo=full
 
 // Tests that MIR inliner can handle closure arguments. (#45894)
 
diff --git a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir
index 6e77a9bc575c1..a6198ca053bc4 100644
--- a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir
+++ b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir
@@ -14,10 +14,7 @@ fn foo(_1: T, _2: &i32) -> i32 {
     scope 1 {
         debug x => _3;
         scope 2 (inlined foo::<T>::{closure#0}) {
-            debug r => _8;
-            debug _s => _9;
             scope 3 {
-                debug variable => _8;
             }
         }
     }
diff --git a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir
index 10b81e59b5f4b..2f9d28ea09376 100644
--- a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir
+++ b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir
@@ -14,9 +14,6 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
     scope 1 {
         debug x => _3;
         scope 2 (inlined foo::<T>::{closure#0}) {
-            debug _q => _9;
-            debug q => (*((*_6).0: &i32));
-            debug t => (*((*_6).1: &T));
             let mut _10: &i32;
             let mut _11: i32;
             let mut _12: &T;
diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff
index 859082c311190..fcfa5953fc2c6 100644
--- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff
+++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff
@@ -16,7 +16,6 @@
 +     scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
 +         debug pointer => _3;
 +         scope 4 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
-+             debug pointer => _3;
 +         }
 +     }
 +     scope 5 (inlined g::{closure#0}) {
diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff
index 44b06c34972af..69c632a9043da 100644
--- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff
+++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff
@@ -16,7 +16,6 @@
 +     scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
 +         debug pointer => _3;
 +         scope 4 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
-+             debug pointer => _3;
 +         }
 +     }
 +     scope 5 (inlined g::{closure#0}) {
diff --git a/tests/mir-opt/inline/inline_coroutine.rs b/tests/mir-opt/inline/inline_coroutine.rs
index 9500c2261cc19..180f9d4a6fddd 100644
--- a/tests/mir-opt/inline/inline_coroutine.rs
+++ b/tests/mir-opt/inline/inline_coroutine.rs
@@ -1,5 +1,5 @@
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
-//@ compile-flags: -Zinline-mir-hint-threshold=1000
+//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full
 #![feature(coroutines, coroutine_trait)]
 
 use std::ops::Coroutine;
diff --git a/tests/mir-opt/inline/inline_cycle.rs b/tests/mir-opt/inline/inline_cycle.rs
index e3dd082556b95..1826e38f894dc 100644
--- a/tests/mir-opt/inline/inline_cycle.rs
+++ b/tests/mir-opt/inline/inline_cycle.rs
@@ -1,4 +1,5 @@
 // skip-filecheck
+//@ compile-flags: -C debuginfo=full
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
 // Check that inliner handles various forms of recursion and doesn't fall into
 // an infinite inlining cycle. The particular outcome of inlining is not
diff --git a/tests/mir-opt/inline/inline_diverging.rs b/tests/mir-opt/inline/inline_diverging.rs
index 89ef0fc4a61f8..e1cea3618f176 100644
--- a/tests/mir-opt/inline/inline_diverging.rs
+++ b/tests/mir-opt/inline/inline_diverging.rs
@@ -1,7 +1,7 @@
 // Tests inlining of diverging calls.
 //
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
-//@ compile-flags: -Zinline-mir-hint-threshold=1000
+//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full
 #![crate_type = "lib"]
 
 // EMIT_MIR inline_diverging.f.Inline.diff
diff --git a/tests/mir-opt/inline/inline_retag.rs b/tests/mir-opt/inline/inline_retag.rs
index 5cf7f768f9170..81e636378879d 100644
--- a/tests/mir-opt/inline/inline_retag.rs
+++ b/tests/mir-opt/inline/inline_retag.rs
@@ -1,4 +1,4 @@
-//@ compile-flags: -Z span_free_formats -Z mir-emit-retag
+//@ compile-flags: -Z span_free_formats -Z mir-emit-retag -C debuginfo=full
 
 // Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag
 
diff --git a/tests/mir-opt/inline/inline_trait_method_2.rs b/tests/mir-opt/inline/inline_trait_method_2.rs
index c3a71e63783f3..2ca71afad4cbb 100644
--- a/tests/mir-opt/inline/inline_trait_method_2.rs
+++ b/tests/mir-opt/inline/inline_trait_method_2.rs
@@ -1,5 +1,5 @@
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
-//@ compile-flags: -Z span_free_formats -Z mir-opt-level=4
+//@ compile-flags: -Z span_free_formats -Z mir-opt-level=4 -C debuginfo=full
 
 // EMIT_MIR inline_trait_method_2.test2.Inline.after.mir
 fn test2(x: &dyn X) -> bool {
diff --git a/tests/mir-opt/inline/issue_106141.rs b/tests/mir-opt/inline/issue_106141.rs
index 592b4d9b72377..1cca7d76b25ac 100644
--- a/tests/mir-opt/inline/issue_106141.rs
+++ b/tests/mir-opt/inline/issue_106141.rs
@@ -1,3 +1,4 @@
+//@ compile-flags: -C debuginfo=full
 // Verify that we do not ICE inlining a function which uses _0 as an index.
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
 
diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs
index 4517c88d71340..d8a5c47850dbc 100644
--- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs
+++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs
@@ -1,3 +1,5 @@
+//@ compile-flags: -C debuginfo=full
+
 // EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir
 pub fn a<T>(x: &mut [T]) -> &mut [T] {
     // CHECK-LABEL: fn a(
diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
index ba4f91b28d536..63d3ae2a86987 100644
--- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
+++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
@@ -2,8 +2,8 @@
 
 fn main() -> () {
     let mut _0: ();
-    let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
-    let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
+    let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:16:13: 16:16};
+    let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:16:13: 16:16};
     let mut _3: ((),);
     let mut _4: ();
     let mut _5: ();
@@ -19,7 +19,7 @@ fn main() -> () {
 
     bb0: {
         StorageLive(_1);
-        _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
+        _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:16:13: 16:16};
         StorageLive(_2);
         _2 = &_1;
         StorageLive(_3);
diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs
index 2fb363c19044d..75772c1612773 100644
--- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs
+++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs
@@ -1,3 +1,4 @@
+//@ compile-flags: -C debuginfo=full
 // Tests that MIR inliner can handle `SourceScopeData` parenting correctly. (#76997)
 
 // EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir
diff --git a/tests/mir-opt/inline/issue_78442.rs b/tests/mir-opt/inline/issue_78442.rs
index 2fbe0c6c64c6c..6dc875f9a407c 100644
--- a/tests/mir-opt/inline/issue_78442.rs
+++ b/tests/mir-opt/inline/issue_78442.rs
@@ -1,4 +1,4 @@
-//@ compile-flags: -Z mir-opt-level=3 -Z inline-mir
+//@ compile-flags: -Z mir-opt-level=3 -Z inline-mir -C debuginfo=full
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
 #![crate_type = "lib"]
 
diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff
index cc1b8b9b70f5c..a624ab78dad15 100644
--- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff
+++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff
@@ -8,8 +8,6 @@
       let mut _3: u16;
       let mut _4: u32;
 +     scope 1 (inlined core::num::<impl u16>::unchecked_shl) {
-+         debug self => _3;
-+         debug rhs => _4;
 +     }
   
       bb0: {
diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff
index f244f378bce3f..81a0a5b39f71d 100644
--- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff
+++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff
@@ -8,8 +8,6 @@
       let mut _3: u16;
       let mut _4: u32;
 +     scope 1 (inlined core::num::<impl u16>::unchecked_shl) {
-+         debug self => _3;
-+         debug rhs => _4;
 +     }
   
       bb0: {
diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir
index c96983c18cb6a..9e3802b7501f5 100644
--- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir
@@ -5,8 +5,6 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 {
     debug b => _2;
     let mut _0: u16;
     scope 1 (inlined core::num::<impl u16>::unchecked_shl) {
-        debug self => _1;
-        debug rhs => _2;
     }
 
     bb0: {
diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir
index c96983c18cb6a..9e3802b7501f5 100644
--- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir
@@ -5,8 +5,6 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 {
     debug b => _2;
     let mut _0: u16;
     scope 1 (inlined core::num::<impl u16>::unchecked_shl) {
-        debug self => _1;
-        debug rhs => _2;
     }
 
     bb0: {
diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff
index 74518db370f1b..a2b3ad4b3babb 100644
--- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff
+++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff
@@ -8,8 +8,6 @@
       let mut _3: i64;
       let mut _4: u32;
 +     scope 1 (inlined core::num::<impl i64>::unchecked_shr) {
-+         debug self => _3;
-+         debug rhs => _4;
 +     }
   
       bb0: {
diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff
index aab04624f6cdf..2ff6b532d61fa 100644
--- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff
+++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff
@@ -8,8 +8,6 @@
       let mut _3: i64;
       let mut _4: u32;
 +     scope 1 (inlined core::num::<impl i64>::unchecked_shr) {
-+         debug self => _3;
-+         debug rhs => _4;
 +     }
   
       bb0: {
diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir
index 1dd8cb2731439..f3961982648a8 100644
--- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir
@@ -5,8 +5,6 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 {
     debug b => _2;
     let mut _0: i64;
     scope 1 (inlined core::num::<impl i64>::unchecked_shr) {
-        debug self => _1;
-        debug rhs => _2;
     }
 
     bb0: {
diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir
index 1dd8cb2731439..f3961982648a8 100644
--- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir
@@ -5,8 +5,6 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 {
     debug b => _2;
     let mut _0: i64;
     scope 1 (inlined core::num::<impl i64>::unchecked_shr) {
-        debug self => _1;
-        debug rhs => _2;
     }
 
     bb0: {
diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff
index 814eda1045979..c1f7879cf0e8c 100644
--- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff
+++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff
@@ -6,10 +6,8 @@
       let mut _0: T;
       let mut _2: std::option::Option<T>;
 +     scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
-+         debug self => _2;
 +         let mut _3: isize;
 +         scope 2 {
-+             debug val => _0;
 +         }
 +         scope 3 (inlined unreachable_unchecked) {
 +             let mut _4: bool;
diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff
index d5d6907438264..5271e538dafe4 100644
--- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff
+++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff
@@ -6,10 +6,8 @@
       let mut _0: T;
       let mut _2: std::option::Option<T>;
 +     scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
-+         debug self => _2;
 +         let mut _3: isize;
 +         scope 2 {
-+             debug val => _0;
 +         }
 +         scope 3 (inlined unreachable_unchecked) {
 +             let mut _4: bool;
diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir
index 7c24a97166c11..dcab8a679a875 100644
--- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir
@@ -4,10 +4,8 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
     debug slf => _1;
     let mut _0: T;
     scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
-        debug self => _1;
         let mut _2: isize;
         scope 2 {
-            debug val => _0;
         }
         scope 3 (inlined unreachable_unchecked) {
             scope 4 (inlined core::ub_checks::check_language_ub) {
diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir
index 7c24a97166c11..dcab8a679a875 100644
--- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir
@@ -4,10 +4,8 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
     debug slf => _1;
     let mut _0: T;
     scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
-        debug self => _1;
         let mut _2: isize;
         scope 2 {
-            debug val => _0;
         }
         scope 3 (inlined unreachable_unchecked) {
             scope 4 (inlined core::ub_checks::check_language_ub) {
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 f8cceacd7e694..f8715789cec14 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
@@ -21,8 +21,6 @@
               scope 3 {
               }
 +             scope 6 (inlined ActionPermit::<'_, T>::perform::{closure#0}) {
-+                 debug _task_context => _31;
-+                 debug self => ((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})).0: ActionPermit<'_, T>);
 +                 let _11: ActionPermit<'_, T>;
 +                 let mut _12: std::future::Ready<()>;
 +                 let mut _13: std::future::Ready<()>;
@@ -52,28 +50,22 @@
 +                 let mut _39: &mut {async fn body of ActionPermit<'_, T>::perform()};
 +                 let mut _40: &mut {async fn body of ActionPermit<'_, T>::perform()};
 +                 scope 7 {
-+                     debug self => (((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})) as variant#3).0: ActionPermit<'_, T>);
 +                     let mut _15: std::future::Ready<()>;
 +                     scope 8 {
-+                         debug __awaitee => (((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})) as variant#3).1: std::future::Ready<()>);
 +                         let _26: ();
 +                         scope 9 {
-+                             debug result => _26;
 +                         }
 +                     }
 +                     scope 10 (inlined ready::<()>) {
-+                         debug t => _14;
 +                         let mut _41: std::option::Option<()>;
 +                     }
 +                 }
 +             }
           }
 +         scope 5 (inlined Pin::<&mut {async fn body of ActionPermit<'_, T>::perform()}>::new_unchecked) {
-+             debug pointer => _5;
 +         }
       }
 +     scope 4 (inlined ActionPermit::<'_, T>::perform) {
-+         debug self => _3;
 +     }
   
       bb0: {
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 fd080d22d3ad7..494f5591e3250 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
@@ -21,8 +21,6 @@
               scope 3 {
               }
 +             scope 6 (inlined ActionPermit::<'_, T>::perform::{closure#0}) {
-+                 debug _task_context => _31;
-+                 debug self => ((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})).0: ActionPermit<'_, T>);
 +                 let _11: ActionPermit<'_, T>;
 +                 let mut _12: std::future::Ready<()>;
 +                 let mut _13: std::future::Ready<()>;
@@ -54,28 +52,22 @@
 +                 let mut _41: &mut {async fn body of ActionPermit<'_, T>::perform()};
 +                 let mut _42: &mut {async fn body of ActionPermit<'_, T>::perform()};
 +                 scope 7 {
-+                     debug self => (((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})) as variant#3).0: ActionPermit<'_, T>);
 +                     let mut _15: std::future::Ready<()>;
 +                     scope 8 {
-+                         debug __awaitee => (((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})) as variant#3).1: std::future::Ready<()>);
 +                         let _26: ();
 +                         scope 9 {
-+                             debug result => _26;
 +                         }
 +                     }
 +                     scope 10 (inlined ready::<()>) {
-+                         debug t => _14;
 +                         let mut _43: std::option::Option<()>;
 +                     }
 +                 }
 +             }
           }
 +         scope 5 (inlined Pin::<&mut {async fn body of ActionPermit<'_, T>::perform()}>::new_unchecked) {
-+             debug pointer => _5;
 +         }
       }
 +     scope 4 (inlined ActionPermit::<'_, T>::perform) {
-+         debug self => _3;
 +     }
   
       bb0: {
diff --git a/tests/mir-opt/inline_generically_if_sized.call.Inline.diff b/tests/mir-opt/inline_generically_if_sized.call.Inline.diff
index 0cf4565dc994c..fc5833f54ec66 100644
--- a/tests/mir-opt/inline_generically_if_sized.call.Inline.diff
+++ b/tests/mir-opt/inline_generically_if_sized.call.Inline.diff
@@ -6,7 +6,6 @@
       let mut _0: i32;
       let mut _2: &T;
 +     scope 1 (inlined <T as Foo>::bar) {
-+         debug self => _2;
 +     }
   
       bb0: {
diff --git a/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff
index 9e1bce1ee202a..e7451d55777e7 100644
--- a/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff
+++ b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff
@@ -8,7 +8,6 @@
       let mut _3: *const &u8;
       let mut _4: *const &u8;
       scope 1 (inlined generic_cast::<&u8, &u8>) {
-          debug x => _4;
           let mut _5: *const &u8;
       }
   
diff --git a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff
index 6d6c9c9a7a162..4d8d658984235 100644
--- a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff
+++ b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff
@@ -6,10 +6,8 @@
       let mut _0: i32;
       let mut _2: std::option::Option<i32>;
       scope 1 (inlined #[track_caller] Option::<i32>::unwrap_unchecked) {
-          debug self => _2;
           let mut _3: isize;
           scope 2 {
-              debug val => _0;
           }
           scope 3 (inlined unreachable_unchecked) {
               let mut _4: bool;
diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff
index 187290785c032..311de9e1c93f3 100644
--- a/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff
+++ b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff
@@ -17,15 +17,11 @@
       let mut _12: u32;
       let mut _13: bool;
       scope 1 (inlined imm8) {
-          debug x => _5;
           let mut _14: u32;
           scope 2 {
-              debug out => _4;
           }
       }
       scope 3 (inlined core::num::<impl u32>::rotate_right) {
-          debug self => _4;
-          debug n => _6;
       }
   
       bb0: {
@@ -34,7 +30,7 @@
           StorageLive(_4);
           StorageLive(_5);
           _5 = _1;
-          _4 = const 0_u32;
+          nop;
 -         StorageLive(_14);
 -         _14 = BitAnd(_5, const 255_u32);
 -         _4 = BitOr(const 0_u32, move _14);
@@ -74,7 +70,8 @@
       bb2: {
           _6 = Shl(move _7, const 1_i32);
           StorageDead(_7);
-          _3 = rotate_right::<u32>(move _4, move _6) -> [return: bb3, unwind unreachable];
+-         _3 = rotate_right::<u32>(move _4, move _6) -> [return: bb3, unwind unreachable];
++         _3 = rotate_right::<u32>(_14, move _6) -> [return: bb3, unwind unreachable];
       }
   
       bb3: {
diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff
index 99350bac478d9..c5fd042161d27 100644
--- a/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff
+++ b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff
@@ -17,15 +17,11 @@
       let mut _12: u32;
       let mut _13: bool;
       scope 1 (inlined imm8) {
-          debug x => _5;
           let mut _14: u32;
           scope 2 {
-              debug out => _4;
           }
       }
       scope 3 (inlined core::num::<impl u32>::rotate_right) {
-          debug self => _4;
-          debug n => _6;
       }
   
       bb0: {
@@ -34,7 +30,7 @@
           StorageLive(_4);
           StorageLive(_5);
           _5 = _1;
-          _4 = const 0_u32;
+          nop;
 -         StorageLive(_14);
 -         _14 = BitAnd(_5, const 255_u32);
 -         _4 = BitOr(const 0_u32, move _14);
@@ -74,7 +70,8 @@
       bb2: {
           _6 = Shl(move _7, const 1_i32);
           StorageDead(_7);
-          _3 = rotate_right::<u32>(move _4, move _6) -> [return: bb3, unwind unreachable];
+-         _3 = rotate_right::<u32>(move _4, move _6) -> [return: bb3, unwind unreachable];
++         _3 = rotate_right::<u32>(_14, move _6) -> [return: bb3, unwind unreachable];
       }
   
       bb3: {
diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir
index bc12002490a16..8da56d59aaa60 100644
--- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir
@@ -3,66 +3,56 @@
 fn num_to_digit(_1: char) -> u32 {
     debug num => _1;
     let mut _0: u32;
-    let mut _5: std::option::Option<u32>;
+    let mut _4: std::option::Option<u32>;
     scope 1 (inlined char::methods::<impl char>::is_digit) {
-        debug self => _1;
-        debug radix => const 8_u32;
         let _2: std::option::Option<u32>;
-        let mut _3: &std::option::Option<u32>;
         scope 2 (inlined Option::<u32>::is_some) {
-            debug self => _3;
-            let mut _4: isize;
+            let mut _3: isize;
         }
     }
     scope 3 (inlined #[track_caller] Option::<u32>::unwrap) {
-        debug self => _5;
-        let mut _6: isize;
-        let mut _7: !;
+        let mut _5: isize;
+        let mut _6: !;
         scope 4 {
-            debug val => _0;
         }
     }
 
     bb0: {
-        StorageLive(_3);
         StorageLive(_2);
         _2 = char::methods::<impl char>::to_digit(_1, const 8_u32) -> [return: bb1, unwind unreachable];
     }
 
     bb1: {
-        _3 = &_2;
-        StorageLive(_4);
-        _4 = discriminant(_2);
-        switchInt(move _4) -> [1: bb2, 0: bb6, otherwise: bb8];
+        StorageLive(_3);
+        _3 = discriminant(_2);
+        switchInt(move _3) -> [1: bb2, 0: bb6, otherwise: bb8];
     }
 
     bb2: {
-        StorageDead(_4);
         StorageDead(_3);
         StorageDead(_2);
-        StorageLive(_5);
-        _5 = char::methods::<impl char>::to_digit(move _1, const 8_u32) -> [return: bb3, unwind unreachable];
+        StorageLive(_4);
+        _4 = char::methods::<impl char>::to_digit(move _1, const 8_u32) -> [return: bb3, unwind unreachable];
     }
 
     bb3: {
-        StorageLive(_6);
-        _6 = discriminant(_5);
-        switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb8];
+        StorageLive(_5);
+        _5 = discriminant(_4);
+        switchInt(move _5) -> [0: bb4, 1: bb5, otherwise: bb8];
     }
 
     bb4: {
-        _7 = option::unwrap_failed() -> unwind unreachable;
+        _6 = option::unwrap_failed() -> unwind unreachable;
     }
 
     bb5: {
-        _0 = move ((_5 as Some).0: u32);
-        StorageDead(_6);
+        _0 = move ((_4 as Some).0: u32);
         StorageDead(_5);
+        StorageDead(_4);
         goto -> bb7;
     }
 
     bb6: {
-        StorageDead(_4);
         StorageDead(_3);
         StorageDead(_2);
         _0 = const 0_u32;
diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir
index 6c7e10a45250a..61bc09d901cbf 100644
--- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir
@@ -3,66 +3,56 @@
 fn num_to_digit(_1: char) -> u32 {
     debug num => _1;
     let mut _0: u32;
-    let mut _5: std::option::Option<u32>;
+    let mut _4: std::option::Option<u32>;
     scope 1 (inlined char::methods::<impl char>::is_digit) {
-        debug self => _1;
-        debug radix => const 8_u32;
         let _2: std::option::Option<u32>;
-        let mut _3: &std::option::Option<u32>;
         scope 2 (inlined Option::<u32>::is_some) {
-            debug self => _3;
-            let mut _4: isize;
+            let mut _3: isize;
         }
     }
     scope 3 (inlined #[track_caller] Option::<u32>::unwrap) {
-        debug self => _5;
-        let mut _6: isize;
-        let mut _7: !;
+        let mut _5: isize;
+        let mut _6: !;
         scope 4 {
-            debug val => _0;
         }
     }
 
     bb0: {
-        StorageLive(_3);
         StorageLive(_2);
         _2 = char::methods::<impl char>::to_digit(_1, const 8_u32) -> [return: bb1, unwind continue];
     }
 
     bb1: {
-        _3 = &_2;
-        StorageLive(_4);
-        _4 = discriminant(_2);
-        switchInt(move _4) -> [1: bb2, 0: bb6, otherwise: bb8];
+        StorageLive(_3);
+        _3 = discriminant(_2);
+        switchInt(move _3) -> [1: bb2, 0: bb6, otherwise: bb8];
     }
 
     bb2: {
-        StorageDead(_4);
         StorageDead(_3);
         StorageDead(_2);
-        StorageLive(_5);
-        _5 = char::methods::<impl char>::to_digit(move _1, const 8_u32) -> [return: bb3, unwind continue];
+        StorageLive(_4);
+        _4 = char::methods::<impl char>::to_digit(move _1, const 8_u32) -> [return: bb3, unwind continue];
     }
 
     bb3: {
-        StorageLive(_6);
-        _6 = discriminant(_5);
-        switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb8];
+        StorageLive(_5);
+        _5 = discriminant(_4);
+        switchInt(move _5) -> [0: bb4, 1: bb5, otherwise: bb8];
     }
 
     bb4: {
-        _7 = option::unwrap_failed() -> unwind continue;
+        _6 = option::unwrap_failed() -> unwind continue;
     }
 
     bb5: {
-        _0 = move ((_5 as Some).0: u32);
-        StorageDead(_6);
+        _0 = move ((_4 as Some).0: u32);
         StorageDead(_5);
+        StorageDead(_4);
         goto -> bb7;
     }
 
     bb6: {
-        StorageDead(_4);
         StorageDead(_3);
         StorageDead(_2);
         _0 = const 0_u32;
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 d67477ab1b9b3..65379ae8b890e 100644
--- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff
+++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff
@@ -16,13 +16,10 @@
           debug residual => _6;
           scope 2 {
               scope 8 (inlined #[track_caller] <Result<i32, i32> as FromResidual<Result<Infallible, i32>>>::from_residual) {
-                  debug residual => _8;
                   let _14: i32;
                   let mut _15: i32;
                   scope 9 {
-                      debug e => _14;
                       scope 10 (inlined <i32 as From<i32>>::from) {
-                          debug t => _14;
                       }
                   }
               }
@@ -34,16 +31,13 @@
           }
       }
       scope 5 (inlined <Result<i32, i32> as Try>::branch) {
-          debug self => _4;
           let mut _10: isize;
           let _11: i32;
           let _12: i32;
           let mut _13: std::result::Result<std::convert::Infallible, i32>;
           scope 6 {
-              debug v => _11;
           }
           scope 7 {
-              debug e => _12;
           }
       }
   
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 d67477ab1b9b3..65379ae8b890e 100644
--- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff
+++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff
@@ -16,13 +16,10 @@
           debug residual => _6;
           scope 2 {
               scope 8 (inlined #[track_caller] <Result<i32, i32> as FromResidual<Result<Infallible, i32>>>::from_residual) {
-                  debug residual => _8;
                   let _14: i32;
                   let mut _15: i32;
                   scope 9 {
-                      debug e => _14;
                       scope 10 (inlined <i32 as From<i32>>::from) {
-                          debug t => _14;
                       }
                   }
               }
@@ -34,16 +31,13 @@
           }
       }
       scope 5 (inlined <Result<i32, i32> as Try>::branch) {
-          debug self => _4;
           let mut _10: isize;
           let _11: i32;
           let _12: i32;
           let mut _13: std::result::Result<std::convert::Infallible, i32>;
           scope 6 {
-              debug v => _11;
           }
           scope 7 {
-              debug e => _12;
           }
       }
   
diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir
index 845673601b2fb..cadebcdf1f875 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir
@@ -13,17 +13,11 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
             debug b => _5;
         }
         scope 3 (inlined core::num::<impl u32>::overflowing_shl) {
-            debug self => _1;
-            debug rhs => _2;
             let mut _4: u32;
             let mut _5: bool;
             scope 4 (inlined core::num::<impl u32>::wrapping_shl) {
-                debug self => _1;
-                debug rhs => _2;
                 let mut _3: u32;
                 scope 5 (inlined core::num::<impl u32>::unchecked_shl) {
-                    debug self => _1;
-                    debug rhs => _3;
                 }
             }
         }
diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir
index f1d0da28b4ef1..abbd170b4b9c2 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir
@@ -4,12 +4,89 @@ fn step_forward(_1: u32, _2: usize) -> u32 {
     debug x => _1;
     debug n => _2;
     let mut _0: u32;
+    scope 1 (inlined <u32 as Step>::forward) {
+        debug start => _1;
+        debug n => _2;
+        let mut _8: u32;
+        scope 2 {
+        }
+        scope 3 (inlined <u32 as Step>::forward_checked) {
+            scope 4 {
+                scope 6 (inlined core::num::<impl u32>::checked_add) {
+                    let mut _7: bool;
+                    scope 7 {
+                    }
+                    scope 8 (inlined core::num::<impl u32>::overflowing_add) {
+                        let mut _5: (u32, bool);
+                        let _6: bool;
+                        scope 9 {
+                        }
+                    }
+                }
+            }
+            scope 5 (inlined convert::num::ptr_try_from_impls::<impl TryFrom<usize> for u32>::try_from) {
+                let mut _3: bool;
+                let mut _4: u32;
+            }
+        }
+        scope 10 (inlined Option::<u32>::is_none) {
+            scope 11 (inlined Option::<u32>::is_some) {
+            }
+        }
+        scope 12 (inlined core::num::<impl u32>::wrapping_add) {
+        }
+    }
 
     bb0: {
-        _0 = <u32 as Step>::forward(move _1, move _2) -> [return: bb1, unwind continue];
+        StorageLive(_4);
+        StorageLive(_3);
+        _3 = Gt(_2, const 4294967295_usize);
+        switchInt(move _3) -> [0: bb1, otherwise: bb5];
     }
 
     bb1: {
+        _4 = _2 as u32 (IntToInt);
+        StorageDead(_3);
+        StorageLive(_6);
+        StorageLive(_5);
+        _5 = CheckedAdd(_1, _4);
+        _6 = (_5.1: bool);
+        StorageDead(_5);
+        StorageLive(_7);
+        _7 = unlikely(move _6) -> [return: bb2, unwind unreachable];
+    }
+
+    bb2: {
+        switchInt(move _7) -> [0: bb3, otherwise: bb4];
+    }
+
+    bb3: {
+        StorageDead(_7);
+        StorageDead(_6);
+        goto -> bb7;
+    }
+
+    bb4: {
+        StorageDead(_7);
+        StorageDead(_6);
+        goto -> bb6;
+    }
+
+    bb5: {
+        StorageDead(_3);
+        goto -> bb6;
+    }
+
+    bb6: {
+        assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::<impl u32>::MAX, const 1_u32) -> [success: bb7, unwind continue];
+    }
+
+    bb7: {
+        StorageLive(_8);
+        _8 = _2 as u32 (IntToInt);
+        _0 = Add(_1, _8);
+        StorageDead(_8);
+        StorageDead(_4);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir
index a6c644259124a..47f10451b057c 100644
--- a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir
@@ -4,71 +4,51 @@ fn <impl at $DIR/derived_ord.rs:6:10: 6:20>::partial_cmp(_1: &MultiField, _2: &M
     debug self => _1;
     debug other => _2;
     let mut _0: std::option::Option<std::cmp::Ordering>;
-    let mut _3: &char;
-    let mut _4: &char;
-    let mut _8: std::option::Option<std::cmp::Ordering>;
-    let mut _9: i8;
-    let mut _10: &i16;
-    let mut _11: &i16;
+    let mut _6: std::option::Option<std::cmp::Ordering>;
+    let mut _7: i8;
     scope 1 {
-        debug cmp => _8;
+        debug cmp => _6;
     }
     scope 2 (inlined std::cmp::impls::<impl PartialOrd for char>::partial_cmp) {
-        debug self => _3;
-        debug other => _4;
-        let mut _5: char;
-        let mut _6: char;
-        let mut _7: std::cmp::Ordering;
+        let mut _3: char;
+        let mut _4: char;
+        let mut _5: std::cmp::Ordering;
     }
     scope 3 (inlined std::cmp::impls::<impl PartialOrd for i16>::partial_cmp) {
-        debug self => _10;
-        debug other => _11;
-        let mut _12: i16;
-        let mut _13: i16;
-        let mut _14: std::cmp::Ordering;
+        let mut _8: i16;
+        let mut _9: i16;
+        let mut _10: std::cmp::Ordering;
     }
 
     bb0: {
         StorageLive(_3);
-        _3 = &((*_1).0: char);
+        _3 = ((*_1).0: char);
         StorageLive(_4);
-        _4 = &((*_2).0: char);
-        StorageLive(_5);
-        _5 = ((*_1).0: char);
-        StorageLive(_6);
-        _6 = ((*_2).0: char);
-        _7 = Cmp(move _5, move _6);
-        StorageDead(_6);
-        StorageDead(_5);
-        _8 = Option::<std::cmp::Ordering>::Some(_7);
+        _4 = ((*_2).0: char);
+        _5 = Cmp(move _3, move _4);
         StorageDead(_4);
         StorageDead(_3);
-        _9 = discriminant(_7);
-        switchInt(move _9) -> [0: bb1, otherwise: bb2];
+        _6 = Option::<std::cmp::Ordering>::Some(_5);
+        _7 = discriminant(_5);
+        switchInt(move _7) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
         StorageLive(_10);
-        _10 = &((*_1).1: i16);
-        StorageLive(_11);
-        _11 = &((*_2).1: i16);
-        StorageLive(_14);
-        StorageLive(_12);
-        _12 = ((*_1).1: i16);
-        StorageLive(_13);
-        _13 = ((*_2).1: i16);
-        _14 = Cmp(move _12, move _13);
-        StorageDead(_13);
-        StorageDead(_12);
-        _0 = Option::<std::cmp::Ordering>::Some(move _14);
-        StorageDead(_14);
-        StorageDead(_11);
+        StorageLive(_8);
+        _8 = ((*_1).1: i16);
+        StorageLive(_9);
+        _9 = ((*_2).1: i16);
+        _10 = Cmp(move _8, move _9);
+        StorageDead(_9);
+        StorageDead(_8);
+        _0 = Option::<std::cmp::Ordering>::Some(move _10);
         StorageDead(_10);
         goto -> bb3;
     }
 
     bb2: {
-        _0 = _8;
+        _0 = _6;
         goto -> bb3;
     }
 
diff --git a/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir
index 174fb2c0c3c06..1109da31d958a 100644
--- a/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir
@@ -3,7 +3,6 @@
 fn f_u64() -> () {
     let mut _0: ();
     scope 1 (inlined f_dispatch::<u64>) {
-        debug t => const 0_u64;
         let _1: ();
         scope 2 (inlined std::mem::size_of::<u64>) {
         }
diff --git a/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir
index 578cb2d706985..2768c2bb2d7b8 100644
--- a/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir
@@ -3,7 +3,6 @@
 fn f_unit() -> () {
     let mut _0: ();
     scope 1 (inlined f_dispatch::<()>) {
-        debug t => const ();
         let _1: ();
         scope 2 (inlined std::mem::size_of::<()>) {
         }
diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff
index 2865b829e3e54..17d83752fc138 100644
--- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff
+++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff
@@ -18,11 +18,8 @@
               debug ptr => _3;
           }
           scope 5 (inlined <std::alloc::Global as Allocator>::allocate) {
-              debug self => _9;
-              debug layout => _8;
           }
           scope 6 (inlined #[track_caller] Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap) {
-              debug self => _6;
               let mut _12: isize;
               let _13: std::alloc::AllocError;
               let mut _14: !;
@@ -30,23 +27,18 @@
               let mut _16: &dyn std::fmt::Debug;
               let mut _17: &std::alloc::AllocError;
               scope 7 {
-                  debug t => _5;
               }
               scope 8 {
-                  debug e => const std::alloc::AllocError;
               }
           }
           scope 9 (inlined NonNull::<[u8]>::as_ptr) {
-              debug self => _5;
               let mut _18: *const [u8];
           }
       }
       scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
-          debug self => _2;
           let mut _10: isize;
           let mut _11: !;
           scope 4 {
-              debug val => _1;
           }
       }
   
diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff
index 603b140556226..4a37c8603204b 100644
--- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff
+++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff
@@ -18,20 +18,15 @@
               debug ptr => _3;
           }
           scope 5 (inlined <std::alloc::Global as Allocator>::allocate) {
-              debug self => _9;
-              debug layout => _8;
           }
           scope 6 (inlined NonNull::<[u8]>::as_ptr) {
-              debug self => _5;
               let mut _12: *const [u8];
           }
       }
       scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
-          debug self => _2;
           let mut _10: isize;
           let mut _11: !;
           scope 4 {
-              debug val => _1;
           }
       }
   
diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff
index 44964392dd658..1cf950402c360 100644
--- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff
+++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff
@@ -18,11 +18,8 @@
               debug ptr => _3;
           }
           scope 5 (inlined <std::alloc::Global as Allocator>::allocate) {
-              debug self => _9;
-              debug layout => _8;
           }
           scope 6 (inlined #[track_caller] Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap) {
-              debug self => _6;
               let mut _12: isize;
               let _13: std::alloc::AllocError;
               let mut _14: !;
@@ -30,23 +27,18 @@
               let mut _16: &dyn std::fmt::Debug;
               let mut _17: &std::alloc::AllocError;
               scope 7 {
-                  debug t => _5;
               }
               scope 8 {
-                  debug e => const std::alloc::AllocError;
               }
           }
           scope 9 (inlined NonNull::<[u8]>::as_ptr) {
-              debug self => _5;
               let mut _18: *const [u8];
           }
       }
       scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
-          debug self => _2;
           let mut _10: isize;
           let mut _11: !;
           scope 4 {
-              debug val => _1;
           }
       }
   
diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff
index 5fd4af21a11bc..ec2e95fecb620 100644
--- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff
+++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff
@@ -18,20 +18,15 @@
               debug ptr => _3;
           }
           scope 5 (inlined <std::alloc::Global as Allocator>::allocate) {
-              debug self => _9;
-              debug layout => _8;
           }
           scope 6 (inlined NonNull::<[u8]>::as_ptr) {
-              debug self => _5;
               let mut _12: *const [u8];
           }
       }
       scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
-          debug self => _2;
           let mut _10: isize;
           let mut _11: !;
           scope 4 {
-              debug val => _1;
           }
       }
   
diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir
index c744787fce2ce..a3dc54f73c8d0 100644
--- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir
@@ -5,17 +5,11 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 {
     debug v => _2;
     let mut _0: u32;
     scope 1 (inlined std::mem::replace::<u32>) {
-        debug dest => _1;
-        debug src => _2;
         scope 2 {
-            debug result => _0;
             scope 4 (inlined std::ptr::write::<u32>) {
-                debug dst => _1;
-                debug src => _2;
             }
         }
         scope 3 (inlined std::ptr::read::<u32>) {
-            debug src => _1;
         }
     }
 
diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir
index c744787fce2ce..a3dc54f73c8d0 100644
--- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir
@@ -5,17 +5,11 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 {
     debug v => _2;
     let mut _0: u32;
     scope 1 (inlined std::mem::replace::<u32>) {
-        debug dest => _1;
-        debug src => _2;
         scope 2 {
-            debug result => _0;
             scope 4 (inlined std::ptr::write::<u32>) {
-                debug dst => _1;
-                debug src => _2;
             }
         }
         scope 3 (inlined std::ptr::read::<u32>) {
-            debug src => _1;
         }
     }
 
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 002d55ad9d9e2..96b4962854de9 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
@@ -5,77 +5,56 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
     debug end => _2;
     debug f => _3;
     let mut _0: ();
-    let mut _4: std::ops::Range<u32>;
-    let mut _5: std::ops::Range<u32>;
-    let mut _6: &mut std::ops::Range<u32>;
-    let mut _14: std::option::Option<u32>;
-    let mut _16: &impl Fn(u32);
-    let mut _17: (u32,);
-    let _18: ();
+    let mut _4: u32;
+    let mut _9: std::option::Option<u32>;
+    let mut _11: &impl Fn(u32);
+    let mut _12: (u32,);
+    let _13: ();
     scope 1 {
-        debug iter => _5;
-        let _15: u32;
+        debug ((iter: std::ops::Range<u32>).0: u32) => _4;
+        debug ((iter: std::ops::Range<u32>).1: u32) => _2;
+        let _10: u32;
         scope 2 {
-            debug x => _15;
+            debug x => _10;
         }
         scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
-            debug self => _6;
             scope 5 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) {
-                debug self => _6;
-                let mut _7: &u32;
-                let mut _8: &u32;
-                let mut _11: bool;
-                let _12: u32;
-                let mut _13: u32;
+                let mut _6: bool;
+                let _7: u32;
+                let mut _8: u32;
                 scope 6 {
-                    debug old => _12;
                 }
                 scope 7 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) {
-                    debug self => _7;
-                    debug other => _8;
-                    let mut _9: u32;
-                    let mut _10: u32;
+                    let mut _5: u32;
                 }
             }
         }
     }
     scope 3 (inlined <std::ops::Range<u32> as IntoIterator>::into_iter) {
-        debug self => _4;
     }
 
     bb0: {
-        _4 = std::ops::Range::<u32> { start: _1, end: _2 };
-        StorageLive(_5);
-        _5 = _4;
+        StorageLive(_4);
+        _4 = _1;
         goto -> bb1;
     }
 
     bb1: {
-        StorageLive(_14);
-        _6 = &mut _5;
-        StorageLive(_12);
-        StorageLive(_11);
-        StorageLive(_7);
-        _7 = &(_5.0: u32);
-        StorageLive(_8);
-        _8 = &(_5.1: u32);
         StorageLive(_9);
-        _9 = (_5.0: u32);
-        StorageLive(_10);
-        _10 = (_5.1: u32);
-        _11 = Lt(move _9, move _10);
-        StorageDead(_10);
-        StorageDead(_9);
-        switchInt(move _11) -> [0: bb2, otherwise: bb4];
+        StorageLive(_7);
+        StorageLive(_6);
+        StorageLive(_5);
+        _5 = _4;
+        _6 = Lt(move _5, _2);
+        StorageDead(_5);
+        switchInt(move _6) -> [0: bb2, otherwise: bb4];
     }
 
     bb2: {
-        StorageDead(_8);
+        StorageDead(_6);
         StorageDead(_7);
-        StorageDead(_11);
-        StorageDead(_12);
-        StorageDead(_14);
-        StorageDead(_5);
+        StorageDead(_9);
+        StorageDead(_4);
         drop(_3) -> [return: bb3, unwind unreachable];
     }
 
@@ -84,31 +63,29 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
     }
 
     bb4: {
-        StorageDead(_8);
-        StorageDead(_7);
-        _12 = (_5.0: u32);
-        StorageLive(_13);
-        _13 = <u32 as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind unreachable];
+        _7 = _4;
+        StorageLive(_8);
+        _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind unreachable];
     }
 
     bb5: {
-        (_5.0: u32) = move _13;
-        StorageDead(_13);
-        _14 = Option::<u32>::Some(_12);
-        StorageDead(_11);
-        StorageDead(_12);
-        _15 = ((_14 as Some).0: u32);
-        StorageLive(_16);
-        _16 = &_3;
-        StorageLive(_17);
-        _17 = (_15,);
-        _18 = <impl Fn(u32) as Fn<(u32,)>>::call(move _16, move _17) -> [return: bb6, unwind unreachable];
+        _4 = move _8;
+        StorageDead(_8);
+        _9 = Option::<u32>::Some(_7);
+        StorageDead(_6);
+        StorageDead(_7);
+        _10 = ((_9 as Some).0: u32);
+        StorageLive(_11);
+        _11 = &_3;
+        StorageLive(_12);
+        _12 = (_10,);
+        _13 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb6, unwind unreachable];
     }
 
     bb6: {
-        StorageDead(_17);
-        StorageDead(_16);
-        StorageDead(_14);
+        StorageDead(_12);
+        StorageDead(_11);
+        StorageDead(_9);
         goto -> bb1;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir
index d5021ac84d281..ce8e2bd083ed4 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
@@ -5,77 +5,56 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
     debug end => _2;
     debug f => _3;
     let mut _0: ();
-    let mut _4: std::ops::Range<u32>;
-    let mut _5: std::ops::Range<u32>;
-    let mut _6: &mut std::ops::Range<u32>;
-    let mut _14: std::option::Option<u32>;
-    let mut _16: &impl Fn(u32);
-    let mut _17: (u32,);
-    let _18: ();
+    let mut _4: u32;
+    let mut _9: std::option::Option<u32>;
+    let mut _11: &impl Fn(u32);
+    let mut _12: (u32,);
+    let _13: ();
     scope 1 {
-        debug iter => _5;
-        let _15: u32;
+        debug ((iter: std::ops::Range<u32>).0: u32) => _4;
+        debug ((iter: std::ops::Range<u32>).1: u32) => _2;
+        let _10: u32;
         scope 2 {
-            debug x => _15;
+            debug x => _10;
         }
         scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
-            debug self => _6;
             scope 5 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) {
-                debug self => _6;
-                let mut _7: &u32;
-                let mut _8: &u32;
-                let mut _11: bool;
-                let _12: u32;
-                let mut _13: u32;
+                let mut _6: bool;
+                let _7: u32;
+                let mut _8: u32;
                 scope 6 {
-                    debug old => _12;
                 }
                 scope 7 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) {
-                    debug self => _7;
-                    debug other => _8;
-                    let mut _9: u32;
-                    let mut _10: u32;
+                    let mut _5: u32;
                 }
             }
         }
     }
     scope 3 (inlined <std::ops::Range<u32> as IntoIterator>::into_iter) {
-        debug self => _4;
     }
 
     bb0: {
-        _4 = std::ops::Range::<u32> { start: _1, end: _2 };
-        StorageLive(_5);
-        _5 = _4;
+        StorageLive(_4);
+        _4 = _1;
         goto -> bb1;
     }
 
     bb1: {
-        StorageLive(_14);
-        _6 = &mut _5;
-        StorageLive(_12);
-        StorageLive(_11);
-        StorageLive(_7);
-        _7 = &(_5.0: u32);
-        StorageLive(_8);
-        _8 = &(_5.1: u32);
         StorageLive(_9);
-        _9 = (_5.0: u32);
-        StorageLive(_10);
-        _10 = (_5.1: u32);
-        _11 = Lt(move _9, move _10);
-        StorageDead(_10);
-        StorageDead(_9);
-        switchInt(move _11) -> [0: bb2, otherwise: bb4];
+        StorageLive(_7);
+        StorageLive(_6);
+        StorageLive(_5);
+        _5 = _4;
+        _6 = Lt(move _5, _2);
+        StorageDead(_5);
+        switchInt(move _6) -> [0: bb2, otherwise: bb4];
     }
 
     bb2: {
-        StorageDead(_8);
+        StorageDead(_6);
         StorageDead(_7);
-        StorageDead(_11);
-        StorageDead(_12);
-        StorageDead(_14);
-        StorageDead(_5);
+        StorageDead(_9);
+        StorageDead(_4);
         drop(_3) -> [return: bb3, unwind continue];
     }
 
@@ -84,31 +63,29 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
     }
 
     bb4: {
-        StorageDead(_8);
-        StorageDead(_7);
-        _12 = (_5.0: u32);
-        StorageLive(_13);
-        _13 = <u32 as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind: bb7];
+        _7 = _4;
+        StorageLive(_8);
+        _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind: bb7];
     }
 
     bb5: {
-        (_5.0: u32) = move _13;
-        StorageDead(_13);
-        _14 = Option::<u32>::Some(_12);
-        StorageDead(_11);
-        StorageDead(_12);
-        _15 = ((_14 as Some).0: u32);
-        StorageLive(_16);
-        _16 = &_3;
-        StorageLive(_17);
-        _17 = (_15,);
-        _18 = <impl Fn(u32) as Fn<(u32,)>>::call(move _16, move _17) -> [return: bb6, unwind: bb7];
+        _4 = move _8;
+        StorageDead(_8);
+        _9 = Option::<u32>::Some(_7);
+        StorageDead(_6);
+        StorageDead(_7);
+        _10 = ((_9 as Some).0: u32);
+        StorageLive(_11);
+        _11 = &_3;
+        StorageLive(_12);
+        _12 = (_10,);
+        _13 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb6, unwind: bb7];
     }
 
     bb6: {
-        StorageDead(_17);
-        StorageDead(_16);
-        StorageDead(_14);
+        StorageDead(_12);
+        StorageDead(_11);
+        StorageDead(_9);
         goto -> bb1;
     }
 
diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir
index 0836600cb6e6d..ce79a33013d95 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
@@ -20,15 +20,11 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
             debug x => _9;
         }
         scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) {
-            debug self => _6;
         }
     }
     scope 3 (inlined RangeInclusive::<u32>::new) {
-        debug start => _1;
-        debug end => _2;
     }
     scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) {
-        debug self => _4;
     }
 
     bb0: {
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 8c1794de5244c..602ecb7c9b835 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
@@ -20,15 +20,11 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
             debug x => _9;
         }
         scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) {
-            debug self => _6;
         }
     }
     scope 3 (inlined RangeInclusive::<u32>::new) {
-        debug start => _1;
-        debug end => _2;
     }
     scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) {
-        debug self => _4;
     }
 
     bb0: {
diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir
index b0f475b4db7fc..8e038246fa2d7 100644
--- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir
@@ -4,7 +4,6 @@ fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> {
     debug it => _1;
     let mut _0: std::option::Option<u32>;
     scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) {
-        debug self => _1;
     }
 
     bb0: {
diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir
index 663ec229f723c..f54d003c662f6 100644
--- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir
@@ -4,7 +4,6 @@ fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> {
     debug it => _1;
     let mut _0: std::option::Option<u32>;
     scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) {
-        debug self => _1;
     }
 
     bb0: {
diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir
index 7faae1d863c13..2ac7e880ccb58 100644
--- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir
@@ -4,68 +4,53 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> {
     debug it => _1;
     let mut _0: std::option::Option<u32>;
     scope 1 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
-        debug self => _1;
         scope 2 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) {
-            debug self => _1;
-            let mut _2: &u32;
-            let mut _3: &u32;
-            let mut _6: bool;
-            let _7: u32;
-            let mut _8: u32;
+            let mut _4: bool;
+            let _5: u32;
+            let mut _6: u32;
             scope 3 {
-                debug old => _7;
             }
             scope 4 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) {
-                debug self => _2;
-                debug other => _3;
-                let mut _4: u32;
-                let mut _5: u32;
+                let mut _2: u32;
+                let mut _3: u32;
             }
         }
     }
 
     bb0: {
-        StorageLive(_7);
-        StorageLive(_6);
+        StorageLive(_5);
+        StorageLive(_4);
         StorageLive(_2);
-        _2 = &((*_1).0: u32);
+        _2 = ((*_1).0: u32);
         StorageLive(_3);
-        _3 = &((*_1).1: u32);
-        StorageLive(_4);
-        _4 = ((*_1).0: u32);
-        StorageLive(_5);
-        _5 = ((*_1).1: u32);
-        _6 = Lt(move _4, move _5);
-        StorageDead(_5);
-        StorageDead(_4);
-        switchInt(move _6) -> [0: bb1, otherwise: bb2];
+        _3 = ((*_1).1: u32);
+        _4 = Lt(move _2, move _3);
+        StorageDead(_3);
+        StorageDead(_2);
+        switchInt(move _4) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageDead(_3);
-        StorageDead(_2);
         _0 = const Option::<u32>::None;
         goto -> bb4;
     }
 
     bb2: {
-        StorageDead(_3);
-        StorageDead(_2);
-        _7 = ((*_1).0: u32);
-        StorageLive(_8);
-        _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb3, unwind unreachable];
+        _5 = ((*_1).0: u32);
+        StorageLive(_6);
+        _6 = <u32 as Step>::forward_unchecked(_5, const 1_usize) -> [return: bb3, unwind unreachable];
     }
 
     bb3: {
-        ((*_1).0: u32) = move _8;
-        StorageDead(_8);
-        _0 = Option::<u32>::Some(_7);
+        ((*_1).0: u32) = move _6;
+        StorageDead(_6);
+        _0 = Option::<u32>::Some(_5);
         goto -> bb4;
     }
 
     bb4: {
-        StorageDead(_6);
-        StorageDead(_7);
+        StorageDead(_4);
+        StorageDead(_5);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir
index 37f00533b6063..60bf644fce6be 100644
--- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir
@@ -4,68 +4,53 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> {
     debug it => _1;
     let mut _0: std::option::Option<u32>;
     scope 1 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
-        debug self => _1;
         scope 2 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) {
-            debug self => _1;
-            let mut _2: &u32;
-            let mut _3: &u32;
-            let mut _6: bool;
-            let _7: u32;
-            let mut _8: u32;
+            let mut _4: bool;
+            let _5: u32;
+            let mut _6: u32;
             scope 3 {
-                debug old => _7;
             }
             scope 4 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) {
-                debug self => _2;
-                debug other => _3;
-                let mut _4: u32;
-                let mut _5: u32;
+                let mut _2: u32;
+                let mut _3: u32;
             }
         }
     }
 
     bb0: {
-        StorageLive(_7);
-        StorageLive(_6);
+        StorageLive(_5);
+        StorageLive(_4);
         StorageLive(_2);
-        _2 = &((*_1).0: u32);
+        _2 = ((*_1).0: u32);
         StorageLive(_3);
-        _3 = &((*_1).1: u32);
-        StorageLive(_4);
-        _4 = ((*_1).0: u32);
-        StorageLive(_5);
-        _5 = ((*_1).1: u32);
-        _6 = Lt(move _4, move _5);
-        StorageDead(_5);
-        StorageDead(_4);
-        switchInt(move _6) -> [0: bb1, otherwise: bb2];
+        _3 = ((*_1).1: u32);
+        _4 = Lt(move _2, move _3);
+        StorageDead(_3);
+        StorageDead(_2);
+        switchInt(move _4) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageDead(_3);
-        StorageDead(_2);
         _0 = const Option::<u32>::None;
         goto -> bb4;
     }
 
     bb2: {
-        StorageDead(_3);
-        StorageDead(_2);
-        _7 = ((*_1).0: u32);
-        StorageLive(_8);
-        _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb3, unwind continue];
+        _5 = ((*_1).0: u32);
+        StorageLive(_6);
+        _6 = <u32 as Step>::forward_unchecked(_5, const 1_usize) -> [return: bb3, unwind continue];
     }
 
     bb3: {
-        ((*_1).0: u32) = move _8;
-        StorageDead(_8);
-        _0 = Option::<u32>::Some(_7);
+        ((*_1).0: u32) = move _6;
+        StorageDead(_6);
+        _0 = Option::<u32>::Some(_5);
         goto -> bb4;
     }
 
     bb4: {
-        StorageDead(_6);
-        StorageDead(_7);
+        StorageDead(_4);
+        StorageDead(_5);
         return;
     }
 }
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 7265a4fc942d8..030f9c3b93e0c 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
@@ -4,15 +4,11 @@ fn ezmap(_1: Option<i32>) -> Option<i32> {
     debug x => _1;
     let mut _0: std::option::Option<i32>;
     scope 1 (inlined map::<i32, i32, {closure@$DIR/simple_option_map.rs:17:12: 17:15}>) {
-        debug slf => _1;
-        debug f => const ZeroSized: {closure@$DIR/simple_option_map.rs:17:12: 17:15};
         let mut _2: isize;
         let _3: i32;
         let mut _4: i32;
         scope 2 {
-            debug x => _3;
             scope 3 (inlined ezmap::{closure#0}) {
-                debug n => _3;
             }
         }
     }
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir
index 153505b1bbb43..7e20817cf2301 100644
--- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir
@@ -5,8 +5,6 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
     debug index => _2;
     let mut _0: std::option::Option<&mut u32>;
     scope 1 (inlined core::slice::<impl [u32]>::get_mut::<usize>) {
-        debug self => _1;
-        debug index => _2;
     }
 
     bb0: {
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir
index d37ee783117d8..2f65b8c640170 100644
--- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir
@@ -5,8 +5,6 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
     debug index => _2;
     let mut _0: std::option::Option<&mut u32>;
     scope 1 (inlined core::slice::<impl [u32]>::get_mut::<usize>) {
-        debug self => _1;
-        debug index => _2;
     }
 
     bb0: {
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 e5490955a3655..ef3f4a2172005 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,8 +5,6 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
     debug index => _2;
     let mut _0: &mut [u32];
     scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) {
-        debug self => _1;
-        debug index => _2;
         let mut _3: *mut [u32];
         let mut _4: *mut [u32];
     }
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 810fee9a14988..9e93a43ac725b 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,8 +5,6 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
     debug index => _2;
     let mut _0: &mut [u32];
     scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) {
-        debug self => _1;
-        debug index => _2;
         let mut _3: *mut [u32];
         let mut _4: *mut [u32];
     }
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 d97c96ac8a088..731f6438a6ec7 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,8 +5,6 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] {
     debug index => _2;
     let mut _0: &[u32];
     scope 1 (inlined #[track_caller] core::slice::index::<impl Index<std::ops::Range<usize>> for [u32]>::index) {
-        debug self => _1;
-        debug index => _2;
     }
 
     bb0: {
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 4a976002fa5a8..d879d06bb4e47 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,8 +5,6 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] {
     debug index => _2;
     let mut _0: &[u32];
     scope 1 (inlined #[track_caller] core::slice::index::<impl Index<std::ops::Range<usize>> for [u32]>::index) {
-        debug self => _1;
-        debug index => _2;
     }
 
     bb0: {
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 1ec85906385e1..d979c5ec1d5a4 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
@@ -4,147 +4,128 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     debug slice => _1;
     debug f => _2;
     let mut _0: ();
-    let mut _13: std::slice::Iter<'_, T>;
+    let mut _12: std::slice::Iter<'_, T>;
+    let mut _13: std::iter::Enumerate<std::slice::Iter<'_, T>>;
     let mut _14: std::iter::Enumerate<std::slice::Iter<'_, T>>;
-    let mut _15: std::iter::Enumerate<std::slice::Iter<'_, T>>;
-    let mut _16: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>;
-    let mut _17: std::option::Option<(usize, &T)>;
-    let mut _18: isize;
-    let mut _21: &impl Fn(usize, &T);
-    let mut _22: (usize, &T);
-    let _23: ();
+    let mut _15: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>;
+    let mut _16: std::option::Option<(usize, &T)>;
+    let mut _17: isize;
+    let mut _20: &impl Fn(usize, &T);
+    let mut _21: (usize, &T);
+    let _22: ();
     scope 1 {
-        debug iter => _15;
-        let _19: usize;
-        let _20: &T;
+        debug iter => _14;
+        let _18: usize;
+        let _19: &T;
         scope 2 {
-            debug i => _19;
-            debug x => _20;
+            debug i => _18;
+            debug x => _19;
         }
     }
     scope 3 (inlined core::slice::<impl [T]>::iter) {
-        debug self => _1;
         scope 4 (inlined std::slice::Iter::<'_, T>::new) {
-            debug slice => _1;
             let _3: usize;
-            let mut _5: std::ptr::NonNull<[T]>;
-            let mut _8: bool;
+            let mut _7: bool;
+            let mut _8: *mut T;
             let mut _9: *mut T;
-            let mut _10: *mut T;
-            let mut _12: *const T;
+            let mut _11: *const T;
             scope 5 {
-                debug len => _3;
-                let _7: std::ptr::NonNull<T>;
+                let _6: std::ptr::NonNull<T>;
                 scope 6 {
-                    debug ptr => _7;
-                    let _11: *const T;
+                    let _10: *const T;
                     scope 7 {
-                        debug end_or_len => _11;
                     }
                     scope 11 (inlined without_provenance::<T>) {
-                        debug addr => _3;
                     }
                     scope 12 (inlined NonNull::<T>::as_ptr) {
-                        debug self => _7;
                     }
                     scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
-                        debug self => _9;
-                        debug count => _3;
                     }
                 }
                 scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) {
-                    debug reference => _1;
                     let mut _4: *const [T];
                 }
                 scope 9 (inlined NonNull::<[T]>::cast::<T>) {
-                    debug self => _5;
-                    let mut _6: *const T;
+                    let mut _5: *const T;
                     scope 10 (inlined NonNull::<[T]>::as_ptr) {
-                        debug self => _5;
                     }
                 }
             }
         }
     }
     scope 14 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) {
-        debug self => _13;
         scope 15 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) {
-            debug iter => _13;
         }
     }
     scope 16 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) {
-        debug self => _14;
     }
 
     bb0: {
-        StorageLive(_13);
+        StorageLive(_12);
         StorageLive(_3);
-        StorageLive(_7);
-        StorageLive(_4);
         StorageLive(_6);
-        _3 = Len((*_1));
+        StorageLive(_4);
         StorageLive(_5);
+        _3 = Len((*_1));
         _4 = &raw const (*_1);
-        _5 = NonNull::<[T]> { pointer: _4 };
-        _6 = _4 as *const T (PtrToPtr);
-        _7 = NonNull::<T> { pointer: _6 };
-        StorageDead(_5);
-        StorageLive(_11);
-        StorageLive(_8);
-        _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
-        switchInt(move _8) -> [0: bb1, otherwise: bb2];
+        _5 = _4 as *const T (PtrToPtr);
+        _6 = NonNull::<T> { pointer: _5 };
+        StorageLive(_10);
+        StorageLive(_7);
+        _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
+        switchInt(move _7) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageLive(_10);
         StorageLive(_9);
-        _9 = _4 as *mut T (PtrToPtr);
-        _10 = Offset(_9, _3);
+        StorageLive(_8);
+        _8 = _4 as *mut T (PtrToPtr);
+        _9 = Offset(_8, _3);
+        StorageDead(_8);
+        _10 = move _9 as *const T (PointerCoercion(MutToConstPointer));
         StorageDead(_9);
-        _11 = move _10 as *const T (PointerCoercion(MutToConstPointer));
-        StorageDead(_10);
         goto -> bb3;
     }
 
     bb2: {
-        _11 = _3 as *const T (Transmute);
+        _10 = _3 as *const T (Transmute);
         goto -> bb3;
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageLive(_12);
-        _12 = _11;
-        _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> };
-        StorageDead(_12);
+        StorageDead(_7);
+        StorageLive(_11);
+        _11 = _10;
+        _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> };
         StorageDead(_11);
-        StorageDead(_6);
+        StorageDead(_10);
+        StorageDead(_5);
         StorageDead(_4);
-        StorageDead(_7);
+        StorageDead(_6);
         StorageDead(_3);
-        _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize };
-        StorageDead(_13);
-        StorageLive(_15);
-        _15 = _14;
+        _13 = Enumerate::<std::slice::Iter<'_, T>> { iter: _12, count: const 0_usize };
+        StorageDead(_12);
+        StorageLive(_14);
+        _14 = _13;
         goto -> bb4;
     }
 
     bb4: {
-        StorageLive(_17);
         StorageLive(_16);
-        _16 = &mut _15;
-        _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind unreachable];
+        StorageLive(_15);
+        _15 = &mut _14;
+        _16 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _15) -> [return: bb5, unwind unreachable];
     }
 
     bb5: {
-        StorageDead(_16);
-        _18 = discriminant(_17);
-        switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10];
+        StorageDead(_15);
+        _17 = discriminant(_16);
+        switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10];
     }
 
     bb6: {
-        StorageDead(_17);
-        StorageDead(_15);
+        StorageDead(_16);
+        StorageDead(_14);
         drop(_2) -> [return: bb7, unwind unreachable];
     }
 
@@ -153,19 +134,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb8: {
-        _19 = (((_17 as Some).0: (usize, &T)).0: usize);
-        _20 = (((_17 as Some).0: (usize, &T)).1: &T);
+        _18 = (((_16 as Some).0: (usize, &T)).0: usize);
+        _19 = (((_16 as Some).0: (usize, &T)).1: &T);
+        StorageLive(_20);
+        _20 = &_2;
         StorageLive(_21);
-        _21 = &_2;
-        StorageLive(_22);
-        _22 = (_19, _20);
-        _23 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable];
+        _21 = (_18, _19);
+        _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb9, unwind unreachable];
     }
 
     bb9: {
-        StorageDead(_22);
         StorageDead(_21);
-        StorageDead(_17);
+        StorageDead(_20);
+        StorageDead(_16);
         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 70cdf3f41c2b7..8491c49f76737 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
@@ -4,147 +4,128 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     debug slice => _1;
     debug f => _2;
     let mut _0: ();
-    let mut _13: std::slice::Iter<'_, T>;
+    let mut _12: std::slice::Iter<'_, T>;
+    let mut _13: std::iter::Enumerate<std::slice::Iter<'_, T>>;
     let mut _14: std::iter::Enumerate<std::slice::Iter<'_, T>>;
-    let mut _15: std::iter::Enumerate<std::slice::Iter<'_, T>>;
-    let mut _16: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>;
-    let mut _17: std::option::Option<(usize, &T)>;
-    let mut _18: isize;
-    let mut _21: &impl Fn(usize, &T);
-    let mut _22: (usize, &T);
-    let _23: ();
+    let mut _15: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>;
+    let mut _16: std::option::Option<(usize, &T)>;
+    let mut _17: isize;
+    let mut _20: &impl Fn(usize, &T);
+    let mut _21: (usize, &T);
+    let _22: ();
     scope 1 {
-        debug iter => _15;
-        let _19: usize;
-        let _20: &T;
+        debug iter => _14;
+        let _18: usize;
+        let _19: &T;
         scope 2 {
-            debug i => _19;
-            debug x => _20;
+            debug i => _18;
+            debug x => _19;
         }
     }
     scope 3 (inlined core::slice::<impl [T]>::iter) {
-        debug self => _1;
         scope 4 (inlined std::slice::Iter::<'_, T>::new) {
-            debug slice => _1;
             let _3: usize;
-            let mut _5: std::ptr::NonNull<[T]>;
-            let mut _8: bool;
+            let mut _7: bool;
+            let mut _8: *mut T;
             let mut _9: *mut T;
-            let mut _10: *mut T;
-            let mut _12: *const T;
+            let mut _11: *const T;
             scope 5 {
-                debug len => _3;
-                let _7: std::ptr::NonNull<T>;
+                let _6: std::ptr::NonNull<T>;
                 scope 6 {
-                    debug ptr => _7;
-                    let _11: *const T;
+                    let _10: *const T;
                     scope 7 {
-                        debug end_or_len => _11;
                     }
                     scope 11 (inlined without_provenance::<T>) {
-                        debug addr => _3;
                     }
                     scope 12 (inlined NonNull::<T>::as_ptr) {
-                        debug self => _7;
                     }
                     scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
-                        debug self => _9;
-                        debug count => _3;
                     }
                 }
                 scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) {
-                    debug reference => _1;
                     let mut _4: *const [T];
                 }
                 scope 9 (inlined NonNull::<[T]>::cast::<T>) {
-                    debug self => _5;
-                    let mut _6: *const T;
+                    let mut _5: *const T;
                     scope 10 (inlined NonNull::<[T]>::as_ptr) {
-                        debug self => _5;
                     }
                 }
             }
         }
     }
     scope 14 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) {
-        debug self => _13;
         scope 15 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) {
-            debug iter => _13;
         }
     }
     scope 16 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) {
-        debug self => _14;
     }
 
     bb0: {
-        StorageLive(_13);
+        StorageLive(_12);
         StorageLive(_3);
-        StorageLive(_7);
-        StorageLive(_4);
         StorageLive(_6);
-        _3 = Len((*_1));
+        StorageLive(_4);
         StorageLive(_5);
+        _3 = Len((*_1));
         _4 = &raw const (*_1);
-        _5 = NonNull::<[T]> { pointer: _4 };
-        _6 = _4 as *const T (PtrToPtr);
-        _7 = NonNull::<T> { pointer: _6 };
-        StorageDead(_5);
-        StorageLive(_11);
-        StorageLive(_8);
-        _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
-        switchInt(move _8) -> [0: bb1, otherwise: bb2];
+        _5 = _4 as *const T (PtrToPtr);
+        _6 = NonNull::<T> { pointer: _5 };
+        StorageLive(_10);
+        StorageLive(_7);
+        _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
+        switchInt(move _7) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageLive(_10);
         StorageLive(_9);
-        _9 = _4 as *mut T (PtrToPtr);
-        _10 = Offset(_9, _3);
+        StorageLive(_8);
+        _8 = _4 as *mut T (PtrToPtr);
+        _9 = Offset(_8, _3);
+        StorageDead(_8);
+        _10 = move _9 as *const T (PointerCoercion(MutToConstPointer));
         StorageDead(_9);
-        _11 = move _10 as *const T (PointerCoercion(MutToConstPointer));
-        StorageDead(_10);
         goto -> bb3;
     }
 
     bb2: {
-        _11 = _3 as *const T (Transmute);
+        _10 = _3 as *const T (Transmute);
         goto -> bb3;
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageLive(_12);
-        _12 = _11;
-        _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> };
-        StorageDead(_12);
+        StorageDead(_7);
+        StorageLive(_11);
+        _11 = _10;
+        _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> };
         StorageDead(_11);
-        StorageDead(_6);
+        StorageDead(_10);
+        StorageDead(_5);
         StorageDead(_4);
-        StorageDead(_7);
+        StorageDead(_6);
         StorageDead(_3);
-        _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize };
-        StorageDead(_13);
-        StorageLive(_15);
-        _15 = _14;
+        _13 = Enumerate::<std::slice::Iter<'_, T>> { iter: _12, count: const 0_usize };
+        StorageDead(_12);
+        StorageLive(_14);
+        _14 = _13;
         goto -> bb4;
     }
 
     bb4: {
-        StorageLive(_17);
         StorageLive(_16);
-        _16 = &mut _15;
-        _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind: bb11];
+        StorageLive(_15);
+        _15 = &mut _14;
+        _16 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _15) -> [return: bb5, unwind: bb11];
     }
 
     bb5: {
-        StorageDead(_16);
-        _18 = discriminant(_17);
-        switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10];
+        StorageDead(_15);
+        _17 = discriminant(_16);
+        switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10];
     }
 
     bb6: {
-        StorageDead(_17);
-        StorageDead(_15);
+        StorageDead(_16);
+        StorageDead(_14);
         drop(_2) -> [return: bb7, unwind continue];
     }
 
@@ -153,19 +134,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb8: {
-        _19 = (((_17 as Some).0: (usize, &T)).0: usize);
-        _20 = (((_17 as Some).0: (usize, &T)).1: &T);
+        _18 = (((_16 as Some).0: (usize, &T)).0: usize);
+        _19 = (((_16 as Some).0: (usize, &T)).1: &T);
+        StorageLive(_20);
+        _20 = &_2;
         StorageLive(_21);
-        _21 = &_2;
-        StorageLive(_22);
-        _22 = (_19, _20);
-        _23 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11];
+        _21 = (_18, _19);
+        _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb9, unwind: bb11];
     }
 
     bb9: {
-        StorageDead(_22);
         StorageDead(_21);
-        StorageDead(_17);
+        StorageDead(_20);
+        StorageDead(_16);
         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 d8252e7267a0e..67dd0c85ea1da 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
@@ -4,135 +4,118 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     debug slice => _1;
     debug f => _2;
     let mut _0: ();
+    let mut _12: std::slice::Iter<'_, T>;
     let mut _13: std::slice::Iter<'_, T>;
-    let mut _14: std::slice::Iter<'_, T>;
-    let mut _15: &mut std::slice::Iter<'_, T>;
-    let mut _16: std::option::Option<&T>;
-    let mut _17: isize;
-    let mut _19: &impl Fn(&T);
-    let mut _20: (&T,);
-    let _21: ();
+    let mut _14: &mut std::slice::Iter<'_, T>;
+    let mut _15: std::option::Option<&T>;
+    let mut _16: isize;
+    let mut _18: &impl Fn(&T);
+    let mut _19: (&T,);
+    let _20: ();
     scope 1 {
-        debug iter => _14;
-        let _18: &T;
+        debug iter => _13;
+        let _17: &T;
         scope 2 {
-            debug x => _18;
+            debug x => _17;
         }
     }
     scope 3 (inlined core::slice::<impl [T]>::iter) {
-        debug self => _1;
         scope 4 (inlined std::slice::Iter::<'_, T>::new) {
-            debug slice => _1;
             let _3: usize;
-            let mut _5: std::ptr::NonNull<[T]>;
-            let mut _8: bool;
+            let mut _7: bool;
+            let mut _8: *mut T;
             let mut _9: *mut T;
-            let mut _10: *mut T;
-            let mut _12: *const T;
+            let mut _11: *const T;
             scope 5 {
-                debug len => _3;
-                let _7: std::ptr::NonNull<T>;
+                let _6: std::ptr::NonNull<T>;
                 scope 6 {
-                    debug ptr => _7;
-                    let _11: *const T;
+                    let _10: *const T;
                     scope 7 {
-                        debug end_or_len => _11;
                     }
                     scope 11 (inlined without_provenance::<T>) {
-                        debug addr => _3;
                     }
                     scope 12 (inlined NonNull::<T>::as_ptr) {
-                        debug self => _7;
                     }
                     scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
-                        debug self => _9;
-                        debug count => _3;
                     }
                 }
                 scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) {
-                    debug reference => _1;
                     let mut _4: *const [T];
                 }
                 scope 9 (inlined NonNull::<[T]>::cast::<T>) {
-                    debug self => _5;
-                    let mut _6: *const T;
+                    let mut _5: *const T;
                     scope 10 (inlined NonNull::<[T]>::as_ptr) {
-                        debug self => _5;
                     }
                 }
             }
         }
     }
     scope 14 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) {
-        debug self => _13;
     }
 
     bb0: {
         StorageLive(_3);
-        StorageLive(_7);
-        StorageLive(_4);
         StorageLive(_6);
-        _3 = Len((*_1));
+        StorageLive(_4);
         StorageLive(_5);
+        _3 = Len((*_1));
         _4 = &raw const (*_1);
-        _5 = NonNull::<[T]> { pointer: _4 };
-        _6 = _4 as *const T (PtrToPtr);
-        _7 = NonNull::<T> { pointer: _6 };
-        StorageDead(_5);
-        StorageLive(_11);
-        StorageLive(_8);
-        _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
-        switchInt(move _8) -> [0: bb1, otherwise: bb2];
+        _5 = _4 as *const T (PtrToPtr);
+        _6 = NonNull::<T> { pointer: _5 };
+        StorageLive(_10);
+        StorageLive(_7);
+        _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
+        switchInt(move _7) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageLive(_10);
         StorageLive(_9);
-        _9 = _4 as *mut T (PtrToPtr);
-        _10 = Offset(_9, _3);
+        StorageLive(_8);
+        _8 = _4 as *mut T (PtrToPtr);
+        _9 = Offset(_8, _3);
+        StorageDead(_8);
+        _10 = move _9 as *const T (PointerCoercion(MutToConstPointer));
         StorageDead(_9);
-        _11 = move _10 as *const T (PointerCoercion(MutToConstPointer));
-        StorageDead(_10);
         goto -> bb3;
     }
 
     bb2: {
-        _11 = _3 as *const T (Transmute);
+        _10 = _3 as *const T (Transmute);
         goto -> bb3;
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageLive(_12);
-        _12 = _11;
-        _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> };
-        StorageDead(_12);
+        StorageDead(_7);
+        StorageLive(_11);
+        _11 = _10;
+        _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> };
         StorageDead(_11);
-        StorageDead(_6);
+        StorageDead(_10);
+        StorageDead(_5);
         StorageDead(_4);
-        StorageDead(_7);
+        StorageDead(_6);
         StorageDead(_3);
-        StorageLive(_14);
-        _14 = _13;
+        StorageLive(_13);
+        _13 = _12;
         goto -> bb4;
     }
 
     bb4: {
-        StorageLive(_16);
         StorageLive(_15);
-        _15 = &mut _14;
-        _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind unreachable];
+        StorageLive(_14);
+        _14 = &mut _13;
+        _15 = <std::slice::Iter<'_, T> as Iterator>::next(move _14) -> [return: bb5, unwind unreachable];
     }
 
     bb5: {
-        StorageDead(_15);
-        _17 = discriminant(_16);
-        switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10];
+        StorageDead(_14);
+        _16 = discriminant(_15);
+        switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10];
     }
 
     bb6: {
-        StorageDead(_16);
-        StorageDead(_14);
+        StorageDead(_15);
+        StorageDead(_13);
         drop(_2) -> [return: bb7, unwind unreachable];
     }
 
@@ -141,18 +124,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb8: {
-        _18 = ((_16 as Some).0: &T);
+        _17 = ((_15 as Some).0: &T);
+        StorageLive(_18);
+        _18 = &_2;
         StorageLive(_19);
-        _19 = &_2;
-        StorageLive(_20);
-        _20 = (_18,);
-        _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind unreachable];
+        _19 = (_17,);
+        _20 = <impl Fn(&T) as Fn<(&T,)>>::call(move _18, move _19) -> [return: bb9, unwind unreachable];
     }
 
     bb9: {
-        StorageDead(_20);
         StorageDead(_19);
-        StorageDead(_16);
+        StorageDead(_18);
+        StorageDead(_15);
         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 b3904dc70a603..7c41e9e1f1b7c 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
@@ -4,135 +4,118 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     debug slice => _1;
     debug f => _2;
     let mut _0: ();
+    let mut _12: std::slice::Iter<'_, T>;
     let mut _13: std::slice::Iter<'_, T>;
-    let mut _14: std::slice::Iter<'_, T>;
-    let mut _15: &mut std::slice::Iter<'_, T>;
-    let mut _16: std::option::Option<&T>;
-    let mut _17: isize;
-    let mut _19: &impl Fn(&T);
-    let mut _20: (&T,);
-    let _21: ();
+    let mut _14: &mut std::slice::Iter<'_, T>;
+    let mut _15: std::option::Option<&T>;
+    let mut _16: isize;
+    let mut _18: &impl Fn(&T);
+    let mut _19: (&T,);
+    let _20: ();
     scope 1 {
-        debug iter => _14;
-        let _18: &T;
+        debug iter => _13;
+        let _17: &T;
         scope 2 {
-            debug x => _18;
+            debug x => _17;
         }
     }
     scope 3 (inlined core::slice::<impl [T]>::iter) {
-        debug self => _1;
         scope 4 (inlined std::slice::Iter::<'_, T>::new) {
-            debug slice => _1;
             let _3: usize;
-            let mut _5: std::ptr::NonNull<[T]>;
-            let mut _8: bool;
+            let mut _7: bool;
+            let mut _8: *mut T;
             let mut _9: *mut T;
-            let mut _10: *mut T;
-            let mut _12: *const T;
+            let mut _11: *const T;
             scope 5 {
-                debug len => _3;
-                let _7: std::ptr::NonNull<T>;
+                let _6: std::ptr::NonNull<T>;
                 scope 6 {
-                    debug ptr => _7;
-                    let _11: *const T;
+                    let _10: *const T;
                     scope 7 {
-                        debug end_or_len => _11;
                     }
                     scope 11 (inlined without_provenance::<T>) {
-                        debug addr => _3;
                     }
                     scope 12 (inlined NonNull::<T>::as_ptr) {
-                        debug self => _7;
                     }
                     scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
-                        debug self => _9;
-                        debug count => _3;
                     }
                 }
                 scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) {
-                    debug reference => _1;
                     let mut _4: *const [T];
                 }
                 scope 9 (inlined NonNull::<[T]>::cast::<T>) {
-                    debug self => _5;
-                    let mut _6: *const T;
+                    let mut _5: *const T;
                     scope 10 (inlined NonNull::<[T]>::as_ptr) {
-                        debug self => _5;
                     }
                 }
             }
         }
     }
     scope 14 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) {
-        debug self => _13;
     }
 
     bb0: {
         StorageLive(_3);
-        StorageLive(_7);
-        StorageLive(_4);
         StorageLive(_6);
-        _3 = Len((*_1));
+        StorageLive(_4);
         StorageLive(_5);
+        _3 = Len((*_1));
         _4 = &raw const (*_1);
-        _5 = NonNull::<[T]> { pointer: _4 };
-        _6 = _4 as *const T (PtrToPtr);
-        _7 = NonNull::<T> { pointer: _6 };
-        StorageDead(_5);
-        StorageLive(_11);
-        StorageLive(_8);
-        _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
-        switchInt(move _8) -> [0: bb1, otherwise: bb2];
+        _5 = _4 as *const T (PtrToPtr);
+        _6 = NonNull::<T> { pointer: _5 };
+        StorageLive(_10);
+        StorageLive(_7);
+        _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
+        switchInt(move _7) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageLive(_10);
         StorageLive(_9);
-        _9 = _4 as *mut T (PtrToPtr);
-        _10 = Offset(_9, _3);
+        StorageLive(_8);
+        _8 = _4 as *mut T (PtrToPtr);
+        _9 = Offset(_8, _3);
+        StorageDead(_8);
+        _10 = move _9 as *const T (PointerCoercion(MutToConstPointer));
         StorageDead(_9);
-        _11 = move _10 as *const T (PointerCoercion(MutToConstPointer));
-        StorageDead(_10);
         goto -> bb3;
     }
 
     bb2: {
-        _11 = _3 as *const T (Transmute);
+        _10 = _3 as *const T (Transmute);
         goto -> bb3;
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageLive(_12);
-        _12 = _11;
-        _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> };
-        StorageDead(_12);
+        StorageDead(_7);
+        StorageLive(_11);
+        _11 = _10;
+        _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> };
         StorageDead(_11);
-        StorageDead(_6);
+        StorageDead(_10);
+        StorageDead(_5);
         StorageDead(_4);
-        StorageDead(_7);
+        StorageDead(_6);
         StorageDead(_3);
-        StorageLive(_14);
-        _14 = _13;
+        StorageLive(_13);
+        _13 = _12;
         goto -> bb4;
     }
 
     bb4: {
-        StorageLive(_16);
         StorageLive(_15);
-        _15 = &mut _14;
-        _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind: bb11];
+        StorageLive(_14);
+        _14 = &mut _13;
+        _15 = <std::slice::Iter<'_, T> as Iterator>::next(move _14) -> [return: bb5, unwind: bb11];
     }
 
     bb5: {
-        StorageDead(_15);
-        _17 = discriminant(_16);
-        switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10];
+        StorageDead(_14);
+        _16 = discriminant(_15);
+        switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10];
     }
 
     bb6: {
-        StorageDead(_16);
-        StorageDead(_14);
+        StorageDead(_15);
+        StorageDead(_13);
         drop(_2) -> [return: bb7, unwind continue];
     }
 
@@ -141,18 +124,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb8: {
-        _18 = ((_16 as Some).0: &T);
+        _17 = ((_15 as Some).0: &T);
+        StorageLive(_18);
+        _18 = &_2;
         StorageLive(_19);
-        _19 = &_2;
-        StorageLive(_20);
-        _20 = (_18,);
-        _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind: bb11];
+        _19 = (_17,);
+        _20 = <impl Fn(&T) as Fn<(&T,)>>::call(move _18, move _19) -> [return: bb9, unwind: bb11];
     }
 
     bb9: {
-        StorageDead(_20);
         StorageDead(_19);
-        StorageDead(_16);
+        StorageDead(_18);
+        StorageDead(_15);
         goto -> bb4;
     }
 
diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir
index 5ab88c9b85592..dbe6f39548c8c 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir
@@ -5,86 +5,63 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     debug f => _2;
     let mut _0: ();
     let mut _3: usize;
-    let mut _4: std::ops::Range<usize>;
-    let mut _5: std::ops::Range<usize>;
-    let mut _6: &mut std::ops::Range<usize>;
-    let mut _14: std::option::Option<usize>;
-    let mut _16: usize;
-    let mut _17: bool;
-    let mut _19: &impl Fn(usize, &T);
-    let mut _20: (usize, &T);
-    let _21: ();
+    let mut _4: usize;
+    let mut _9: std::option::Option<usize>;
+    let mut _11: usize;
+    let mut _12: bool;
+    let mut _14: &impl Fn(usize, &T);
+    let mut _15: (usize, &T);
+    let _16: ();
     scope 1 {
-        debug iter => _5;
-        let _15: usize;
+        debug ((iter: std::ops::Range<usize>).0: usize) => _4;
+        debug ((iter: std::ops::Range<usize>).1: usize) => _3;
+        let _10: usize;
         scope 2 {
-            debug i => _15;
-            let _18: &T;
+            debug i => _10;
+            let _13: &T;
             scope 3 {
-                debug x => _18;
+                debug x => _13;
             }
         }
         scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
-            debug self => _6;
             scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
-                debug self => _6;
-                let mut _7: &usize;
-                let mut _8: &usize;
-                let mut _11: bool;
-                let _12: usize;
-                let mut _13: usize;
+                let mut _6: bool;
+                let _7: usize;
+                let mut _8: usize;
                 scope 7 {
-                    debug old => _12;
                 }
                 scope 8 (inlined std::cmp::impls::<impl PartialOrd for usize>::lt) {
-                    debug self => _7;
-                    debug other => _8;
-                    let mut _9: usize;
-                    let mut _10: usize;
+                    let mut _5: usize;
                 }
             }
         }
     }
     scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) {
-        debug self => _4;
     }
 
     bb0: {
-        StorageLive(_3);
         _3 = Len((*_1));
-        _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _3 };
-        StorageDead(_3);
-        StorageLive(_5);
-        _5 = _4;
+        StorageLive(_4);
+        _4 = const 0_usize;
         goto -> bb1;
     }
 
     bb1: {
-        StorageLive(_14);
-        _6 = &mut _5;
-        StorageLive(_12);
-        StorageLive(_11);
-        StorageLive(_7);
-        _7 = &(_5.0: usize);
-        StorageLive(_8);
-        _8 = &(_5.1: usize);
         StorageLive(_9);
-        _9 = (_5.0: usize);
-        StorageLive(_10);
-        _10 = (_5.1: usize);
-        _11 = Lt(move _9, move _10);
-        StorageDead(_10);
-        StorageDead(_9);
-        switchInt(move _11) -> [0: bb2, otherwise: bb4];
+        StorageLive(_7);
+        StorageLive(_6);
+        StorageLive(_5);
+        _5 = _4;
+        _6 = Lt(move _5, _3);
+        StorageDead(_5);
+        switchInt(move _6) -> [0: bb2, otherwise: bb4];
     }
 
     bb2: {
-        StorageDead(_8);
+        StorageDead(_6);
         StorageDead(_7);
-        StorageDead(_11);
-        StorageDead(_12);
-        StorageDead(_14);
-        StorageDead(_5);
+        StorageDead(_9);
+        StorageDead(_4);
         drop(_2) -> [return: bb3, unwind unreachable];
     }
 
@@ -93,38 +70,36 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb4: {
-        StorageDead(_8);
-        StorageDead(_7);
-        _12 = (_5.0: usize);
-        StorageLive(_13);
-        _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind unreachable];
+        _7 = _4;
+        StorageLive(_8);
+        _8 = <usize as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind unreachable];
     }
 
     bb5: {
-        (_5.0: usize) = move _13;
-        StorageDead(_13);
-        _14 = Option::<usize>::Some(_12);
-        StorageDead(_11);
-        StorageDead(_12);
-        _15 = ((_14 as Some).0: usize);
-        _16 = Len((*_1));
-        _17 = Lt(_15, _16);
-        assert(move _17, "index out of bounds: the length is {} but the index is {}", move _16, _15) -> [success: bb6, unwind unreachable];
+        _4 = move _8;
+        StorageDead(_8);
+        _9 = Option::<usize>::Some(_7);
+        StorageDead(_6);
+        StorageDead(_7);
+        _10 = ((_9 as Some).0: usize);
+        _11 = Len((*_1));
+        _12 = Lt(_10, _11);
+        assert(move _12, "index out of bounds: the length is {} but the index is {}", move _11, _10) -> [success: bb6, unwind unreachable];
     }
 
     bb6: {
-        _18 = &(*_1)[_15];
-        StorageLive(_19);
-        _19 = &_2;
-        StorageLive(_20);
-        _20 = (_15, _18);
-        _21 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _19, move _20) -> [return: bb7, unwind unreachable];
+        _13 = &(*_1)[_10];
+        StorageLive(_14);
+        _14 = &_2;
+        StorageLive(_15);
+        _15 = (_10, _13);
+        _16 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _14, move _15) -> [return: bb7, unwind unreachable];
     }
 
     bb7: {
-        StorageDead(_20);
-        StorageDead(_19);
+        StorageDead(_15);
         StorageDead(_14);
+        StorageDead(_9);
         goto -> bb1;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir
index 513651090a853..5b6441cfb3b21 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir
@@ -5,86 +5,63 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     debug f => _2;
     let mut _0: ();
     let mut _3: usize;
-    let mut _4: std::ops::Range<usize>;
-    let mut _5: std::ops::Range<usize>;
-    let mut _6: &mut std::ops::Range<usize>;
-    let mut _14: std::option::Option<usize>;
-    let mut _16: usize;
-    let mut _17: bool;
-    let mut _19: &impl Fn(usize, &T);
-    let mut _20: (usize, &T);
-    let _21: ();
+    let mut _4: usize;
+    let mut _9: std::option::Option<usize>;
+    let mut _11: usize;
+    let mut _12: bool;
+    let mut _14: &impl Fn(usize, &T);
+    let mut _15: (usize, &T);
+    let _16: ();
     scope 1 {
-        debug iter => _5;
-        let _15: usize;
+        debug ((iter: std::ops::Range<usize>).0: usize) => _4;
+        debug ((iter: std::ops::Range<usize>).1: usize) => _3;
+        let _10: usize;
         scope 2 {
-            debug i => _15;
-            let _18: &T;
+            debug i => _10;
+            let _13: &T;
             scope 3 {
-                debug x => _18;
+                debug x => _13;
             }
         }
         scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
-            debug self => _6;
             scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
-                debug self => _6;
-                let mut _7: &usize;
-                let mut _8: &usize;
-                let mut _11: bool;
-                let _12: usize;
-                let mut _13: usize;
+                let mut _6: bool;
+                let _7: usize;
+                let mut _8: usize;
                 scope 7 {
-                    debug old => _12;
                 }
                 scope 8 (inlined std::cmp::impls::<impl PartialOrd for usize>::lt) {
-                    debug self => _7;
-                    debug other => _8;
-                    let mut _9: usize;
-                    let mut _10: usize;
+                    let mut _5: usize;
                 }
             }
         }
     }
     scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) {
-        debug self => _4;
     }
 
     bb0: {
-        StorageLive(_3);
         _3 = Len((*_1));
-        _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _3 };
-        StorageDead(_3);
-        StorageLive(_5);
-        _5 = _4;
+        StorageLive(_4);
+        _4 = const 0_usize;
         goto -> bb1;
     }
 
     bb1: {
-        StorageLive(_14);
-        _6 = &mut _5;
-        StorageLive(_12);
-        StorageLive(_11);
-        StorageLive(_7);
-        _7 = &(_5.0: usize);
-        StorageLive(_8);
-        _8 = &(_5.1: usize);
         StorageLive(_9);
-        _9 = (_5.0: usize);
-        StorageLive(_10);
-        _10 = (_5.1: usize);
-        _11 = Lt(move _9, move _10);
-        StorageDead(_10);
-        StorageDead(_9);
-        switchInt(move _11) -> [0: bb2, otherwise: bb4];
+        StorageLive(_7);
+        StorageLive(_6);
+        StorageLive(_5);
+        _5 = _4;
+        _6 = Lt(move _5, _3);
+        StorageDead(_5);
+        switchInt(move _6) -> [0: bb2, otherwise: bb4];
     }
 
     bb2: {
-        StorageDead(_8);
+        StorageDead(_6);
         StorageDead(_7);
-        StorageDead(_11);
-        StorageDead(_12);
-        StorageDead(_14);
-        StorageDead(_5);
+        StorageDead(_9);
+        StorageDead(_4);
         drop(_2) -> [return: bb3, unwind continue];
     }
 
@@ -93,38 +70,36 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb4: {
-        StorageDead(_8);
-        StorageDead(_7);
-        _12 = (_5.0: usize);
-        StorageLive(_13);
-        _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind: bb8];
+        _7 = _4;
+        StorageLive(_8);
+        _8 = <usize as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind: bb8];
     }
 
     bb5: {
-        (_5.0: usize) = move _13;
-        StorageDead(_13);
-        _14 = Option::<usize>::Some(_12);
-        StorageDead(_11);
-        StorageDead(_12);
-        _15 = ((_14 as Some).0: usize);
-        _16 = Len((*_1));
-        _17 = Lt(_15, _16);
-        assert(move _17, "index out of bounds: the length is {} but the index is {}", move _16, _15) -> [success: bb6, unwind: bb8];
+        _4 = move _8;
+        StorageDead(_8);
+        _9 = Option::<usize>::Some(_7);
+        StorageDead(_6);
+        StorageDead(_7);
+        _10 = ((_9 as Some).0: usize);
+        _11 = Len((*_1));
+        _12 = Lt(_10, _11);
+        assert(move _12, "index out of bounds: the length is {} but the index is {}", move _11, _10) -> [success: bb6, unwind: bb8];
     }
 
     bb6: {
-        _18 = &(*_1)[_15];
-        StorageLive(_19);
-        _19 = &_2;
-        StorageLive(_20);
-        _20 = (_15, _18);
-        _21 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _19, move _20) -> [return: bb7, unwind: bb8];
+        _13 = &(*_1)[_10];
+        StorageLive(_14);
+        _14 = &_2;
+        StorageLive(_15);
+        _15 = (_10, _13);
+        _16 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _14, move _15) -> [return: bb7, unwind: bb8];
     }
 
     bb7: {
-        StorageDead(_20);
-        StorageDead(_19);
+        StorageDead(_15);
         StorageDead(_14);
+        StorageDead(_9);
         goto -> bb1;
     }
 
diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir
index 091c8a0e9681c..ffeef1e04a154 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
@@ -4,150 +4,128 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     debug slice => _1;
     debug f => _2;
     let mut _0: ();
-    let mut _13: std::slice::Iter<'_, T>;
+    let mut _12: std::slice::Iter<'_, T>;
+    let mut _13: std::iter::Rev<std::slice::Iter<'_, T>>;
     let mut _14: std::iter::Rev<std::slice::Iter<'_, T>>;
-    let mut _15: std::iter::Rev<std::slice::Iter<'_, T>>;
-    let mut _16: &mut std::iter::Rev<std::slice::Iter<'_, T>>;
-    let mut _18: std::option::Option<&T>;
-    let mut _19: isize;
-    let mut _21: &impl Fn(&T);
-    let mut _22: (&T,);
-    let _23: ();
+    let mut _16: std::option::Option<&T>;
+    let mut _17: isize;
+    let mut _19: &impl Fn(&T);
+    let mut _20: (&T,);
+    let _21: ();
     scope 1 {
-        debug iter => _15;
-        let _20: &T;
+        debug iter => _14;
+        let _18: &T;
         scope 2 {
-            debug x => _20;
+            debug x => _18;
         }
         scope 17 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
-            debug self => _16;
-            let mut _17: &mut std::slice::Iter<'_, T>;
+            let mut _15: &mut std::slice::Iter<'_, T>;
         }
     }
     scope 3 (inlined core::slice::<impl [T]>::iter) {
-        debug self => _1;
         scope 4 (inlined std::slice::Iter::<'_, T>::new) {
-            debug slice => _1;
             let _3: usize;
-            let mut _5: std::ptr::NonNull<[T]>;
-            let mut _8: bool;
+            let mut _7: bool;
+            let mut _8: *mut T;
             let mut _9: *mut T;
-            let mut _10: *mut T;
-            let mut _12: *const T;
+            let mut _11: *const T;
             scope 5 {
-                debug len => _3;
-                let _7: std::ptr::NonNull<T>;
+                let _6: std::ptr::NonNull<T>;
                 scope 6 {
-                    debug ptr => _7;
-                    let _11: *const T;
+                    let _10: *const T;
                     scope 7 {
-                        debug end_or_len => _11;
                     }
                     scope 11 (inlined without_provenance::<T>) {
-                        debug addr => _3;
                     }
                     scope 12 (inlined NonNull::<T>::as_ptr) {
-                        debug self => _7;
                     }
                     scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
-                        debug self => _9;
-                        debug count => _3;
                     }
                 }
                 scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) {
-                    debug reference => _1;
                     let mut _4: *const [T];
                 }
                 scope 9 (inlined NonNull::<[T]>::cast::<T>) {
-                    debug self => _5;
-                    let mut _6: *const T;
+                    let mut _5: *const T;
                     scope 10 (inlined NonNull::<[T]>::as_ptr) {
-                        debug self => _5;
                     }
                 }
             }
         }
     }
     scope 14 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) {
-        debug self => _13;
         scope 15 (inlined Rev::<std::slice::Iter<'_, T>>::new) {
-            debug iter => _13;
         }
     }
     scope 16 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) {
-        debug self => _14;
     }
 
     bb0: {
-        StorageLive(_13);
+        StorageLive(_12);
         StorageLive(_3);
-        StorageLive(_7);
-        StorageLive(_4);
         StorageLive(_6);
-        _3 = Len((*_1));
+        StorageLive(_4);
         StorageLive(_5);
+        _3 = Len((*_1));
         _4 = &raw const (*_1);
-        _5 = NonNull::<[T]> { pointer: _4 };
-        _6 = _4 as *const T (PtrToPtr);
-        _7 = NonNull::<T> { pointer: _6 };
-        StorageDead(_5);
-        StorageLive(_11);
-        StorageLive(_8);
-        _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
-        switchInt(move _8) -> [0: bb1, otherwise: bb2];
+        _5 = _4 as *const T (PtrToPtr);
+        _6 = NonNull::<T> { pointer: _5 };
+        StorageLive(_10);
+        StorageLive(_7);
+        _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
+        switchInt(move _7) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageLive(_10);
         StorageLive(_9);
-        _9 = _4 as *mut T (PtrToPtr);
-        _10 = Offset(_9, _3);
+        StorageLive(_8);
+        _8 = _4 as *mut T (PtrToPtr);
+        _9 = Offset(_8, _3);
+        StorageDead(_8);
+        _10 = move _9 as *const T (PointerCoercion(MutToConstPointer));
         StorageDead(_9);
-        _11 = move _10 as *const T (PointerCoercion(MutToConstPointer));
-        StorageDead(_10);
         goto -> bb3;
     }
 
     bb2: {
-        _11 = _3 as *const T (Transmute);
+        _10 = _3 as *const T (Transmute);
         goto -> bb3;
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageLive(_12);
-        _12 = _11;
-        _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> };
-        StorageDead(_12);
+        StorageDead(_7);
+        StorageLive(_11);
+        _11 = _10;
+        _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> };
         StorageDead(_11);
-        StorageDead(_6);
+        StorageDead(_10);
+        StorageDead(_5);
         StorageDead(_4);
-        StorageDead(_7);
+        StorageDead(_6);
         StorageDead(_3);
-        _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 };
-        StorageDead(_13);
-        StorageLive(_15);
-        _15 = _14;
+        _13 = Rev::<std::slice::Iter<'_, T>> { iter: _12 };
+        StorageDead(_12);
+        StorageLive(_14);
+        _14 = _13;
         goto -> bb4;
     }
 
     bb4: {
-        StorageLive(_18);
-        _16 = &mut _15;
-        StorageLive(_17);
-        _17 = &mut (_15.0: std::slice::Iter<'_, T>);
-        _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind unreachable];
+        StorageLive(_16);
+        StorageLive(_15);
+        _15 = &mut (_14.0: std::slice::Iter<'_, T>);
+        _16 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _15) -> [return: bb5, unwind unreachable];
     }
 
     bb5: {
-        StorageDead(_17);
-        _19 = discriminant(_18);
-        switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10];
+        StorageDead(_15);
+        _17 = discriminant(_16);
+        switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10];
     }
 
     bb6: {
-        StorageDead(_18);
-        StorageDead(_15);
+        StorageDead(_16);
+        StorageDead(_14);
         drop(_2) -> [return: bb7, unwind unreachable];
     }
 
@@ -156,18 +134,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb8: {
-        _20 = ((_18 as Some).0: &T);
-        StorageLive(_21);
-        _21 = &_2;
-        StorageLive(_22);
-        _22 = (_20,);
-        _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable];
+        _18 = ((_16 as Some).0: &T);
+        StorageLive(_19);
+        _19 = &_2;
+        StorageLive(_20);
+        _20 = (_18,);
+        _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind unreachable];
     }
 
     bb9: {
-        StorageDead(_22);
-        StorageDead(_21);
-        StorageDead(_18);
+        StorageDead(_20);
+        StorageDead(_19);
+        StorageDead(_16);
         goto -> bb4;
     }
 
diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir
index 1873d452f3454..c7cd37afd8660 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
@@ -4,150 +4,128 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     debug slice => _1;
     debug f => _2;
     let mut _0: ();
-    let mut _13: std::slice::Iter<'_, T>;
+    let mut _12: std::slice::Iter<'_, T>;
+    let mut _13: std::iter::Rev<std::slice::Iter<'_, T>>;
     let mut _14: std::iter::Rev<std::slice::Iter<'_, T>>;
-    let mut _15: std::iter::Rev<std::slice::Iter<'_, T>>;
-    let mut _16: &mut std::iter::Rev<std::slice::Iter<'_, T>>;
-    let mut _18: std::option::Option<&T>;
-    let mut _19: isize;
-    let mut _21: &impl Fn(&T);
-    let mut _22: (&T,);
-    let _23: ();
+    let mut _16: std::option::Option<&T>;
+    let mut _17: isize;
+    let mut _19: &impl Fn(&T);
+    let mut _20: (&T,);
+    let _21: ();
     scope 1 {
-        debug iter => _15;
-        let _20: &T;
+        debug iter => _14;
+        let _18: &T;
         scope 2 {
-            debug x => _20;
+            debug x => _18;
         }
         scope 17 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
-            debug self => _16;
-            let mut _17: &mut std::slice::Iter<'_, T>;
+            let mut _15: &mut std::slice::Iter<'_, T>;
         }
     }
     scope 3 (inlined core::slice::<impl [T]>::iter) {
-        debug self => _1;
         scope 4 (inlined std::slice::Iter::<'_, T>::new) {
-            debug slice => _1;
             let _3: usize;
-            let mut _5: std::ptr::NonNull<[T]>;
-            let mut _8: bool;
+            let mut _7: bool;
+            let mut _8: *mut T;
             let mut _9: *mut T;
-            let mut _10: *mut T;
-            let mut _12: *const T;
+            let mut _11: *const T;
             scope 5 {
-                debug len => _3;
-                let _7: std::ptr::NonNull<T>;
+                let _6: std::ptr::NonNull<T>;
                 scope 6 {
-                    debug ptr => _7;
-                    let _11: *const T;
+                    let _10: *const T;
                     scope 7 {
-                        debug end_or_len => _11;
                     }
                     scope 11 (inlined without_provenance::<T>) {
-                        debug addr => _3;
                     }
                     scope 12 (inlined NonNull::<T>::as_ptr) {
-                        debug self => _7;
                     }
                     scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
-                        debug self => _9;
-                        debug count => _3;
                     }
                 }
                 scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) {
-                    debug reference => _1;
                     let mut _4: *const [T];
                 }
                 scope 9 (inlined NonNull::<[T]>::cast::<T>) {
-                    debug self => _5;
-                    let mut _6: *const T;
+                    let mut _5: *const T;
                     scope 10 (inlined NonNull::<[T]>::as_ptr) {
-                        debug self => _5;
                     }
                 }
             }
         }
     }
     scope 14 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) {
-        debug self => _13;
         scope 15 (inlined Rev::<std::slice::Iter<'_, T>>::new) {
-            debug iter => _13;
         }
     }
     scope 16 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) {
-        debug self => _14;
     }
 
     bb0: {
-        StorageLive(_13);
+        StorageLive(_12);
         StorageLive(_3);
-        StorageLive(_7);
-        StorageLive(_4);
         StorageLive(_6);
-        _3 = Len((*_1));
+        StorageLive(_4);
         StorageLive(_5);
+        _3 = Len((*_1));
         _4 = &raw const (*_1);
-        _5 = NonNull::<[T]> { pointer: _4 };
-        _6 = _4 as *const T (PtrToPtr);
-        _7 = NonNull::<T> { pointer: _6 };
-        StorageDead(_5);
-        StorageLive(_11);
-        StorageLive(_8);
-        _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
-        switchInt(move _8) -> [0: bb1, otherwise: bb2];
+        _5 = _4 as *const T (PtrToPtr);
+        _6 = NonNull::<T> { pointer: _5 };
+        StorageLive(_10);
+        StorageLive(_7);
+        _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST;
+        switchInt(move _7) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageLive(_10);
         StorageLive(_9);
-        _9 = _4 as *mut T (PtrToPtr);
-        _10 = Offset(_9, _3);
+        StorageLive(_8);
+        _8 = _4 as *mut T (PtrToPtr);
+        _9 = Offset(_8, _3);
+        StorageDead(_8);
+        _10 = move _9 as *const T (PointerCoercion(MutToConstPointer));
         StorageDead(_9);
-        _11 = move _10 as *const T (PointerCoercion(MutToConstPointer));
-        StorageDead(_10);
         goto -> bb3;
     }
 
     bb2: {
-        _11 = _3 as *const T (Transmute);
+        _10 = _3 as *const T (Transmute);
         goto -> bb3;
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageLive(_12);
-        _12 = _11;
-        _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> };
-        StorageDead(_12);
+        StorageDead(_7);
+        StorageLive(_11);
+        _11 = _10;
+        _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> };
         StorageDead(_11);
-        StorageDead(_6);
+        StorageDead(_10);
+        StorageDead(_5);
         StorageDead(_4);
-        StorageDead(_7);
+        StorageDead(_6);
         StorageDead(_3);
-        _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 };
-        StorageDead(_13);
-        StorageLive(_15);
-        _15 = _14;
+        _13 = Rev::<std::slice::Iter<'_, T>> { iter: _12 };
+        StorageDead(_12);
+        StorageLive(_14);
+        _14 = _13;
         goto -> bb4;
     }
 
     bb4: {
-        StorageLive(_18);
-        _16 = &mut _15;
-        StorageLive(_17);
-        _17 = &mut (_15.0: std::slice::Iter<'_, T>);
-        _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind: bb11];
+        StorageLive(_16);
+        StorageLive(_15);
+        _15 = &mut (_14.0: std::slice::Iter<'_, T>);
+        _16 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _15) -> [return: bb5, unwind: bb11];
     }
 
     bb5: {
-        StorageDead(_17);
-        _19 = discriminant(_18);
-        switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10];
+        StorageDead(_15);
+        _17 = discriminant(_16);
+        switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10];
     }
 
     bb6: {
-        StorageDead(_18);
-        StorageDead(_15);
+        StorageDead(_16);
+        StorageDead(_14);
         drop(_2) -> [return: bb7, unwind continue];
     }
 
@@ -156,18 +134,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb8: {
-        _20 = ((_18 as Some).0: &T);
-        StorageLive(_21);
-        _21 = &_2;
-        StorageLive(_22);
-        _22 = (_20,);
-        _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11];
+        _18 = ((_16 as Some).0: &T);
+        StorageLive(_19);
+        _19 = &_2;
+        StorageLive(_20);
+        _20 = (_18,);
+        _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind: bb11];
     }
 
     bb9: {
-        StorageDead(_22);
-        StorageDead(_21);
-        StorageDead(_18);
+        StorageDead(_20);
+        StorageDead(_19);
+        StorageDead(_16);
         goto -> bb4;
     }
 
diff --git a/tests/mir-opt/pre-codegen/spans.rs b/tests/mir-opt/pre-codegen/spans.rs
index 4d3dc7ec3e595..940089d2d498c 100644
--- a/tests/mir-opt/pre-codegen/spans.rs
+++ b/tests/mir-opt/pre-codegen/spans.rs
@@ -2,7 +2,7 @@
 // Test that the comments we emit in MIR opts are accurate.
 //
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
-//@ compile-flags: -Zmir-include-spans
+//@ compile-flags: -Zmir-include-spans -C debuginfo=full
 
 #![crate_type = "lib"]
 
diff --git a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff
index 22a1a882b41c8..0c73602bec84b 100644
--- a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff
+++ b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff
@@ -7,7 +7,6 @@
       let _2: ();
       let mut _3: T;
       scope 1 (inlined std::mem::drop::<T>) {
-          debug _x => _3;
       }
   
       bb0: {
diff --git a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff
index 56070e6102f11..59cce9fbcdd0a 100644
--- a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff
+++ b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff
@@ -7,7 +7,6 @@
       let _2: ();
       let mut _3: T;
       scope 1 (inlined std::mem::drop::<T>) {
-          debug _x => _3;
       }
   
       bb0: {
diff --git a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff
index 105bedd0ac823..428b366b5a684 100644
--- a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff
+++ b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff
@@ -7,7 +7,6 @@
       let _2: ();
       let mut _3: std::vec::Vec<bool>;
       scope 1 (inlined std::mem::drop::<Vec<bool>>) {
-          debug _x => _3;
       }
   
       bb0: {
diff --git a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff
index c9790dc071d63..445c1f82a96f8 100644
--- a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff
+++ b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff
@@ -7,7 +7,6 @@
       let _2: ();
       let mut _3: std::vec::Vec<bool>;
       scope 1 (inlined std::mem::drop::<Vec<bool>>) {
-          debug _x => _3;
       }
   
       bb0: {
diff --git a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff
index a48ac82ea7da6..5afeb8620a176 100644
--- a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff
+++ b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff
@@ -7,7 +7,6 @@
       let _2: ();
       let mut _3: bool;
       scope 1 (inlined std::mem::drop::<bool>) {
-          debug _x => _3;
       }
   
       bb0: {
diff --git a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff
index a335e8853f38f..b9919ddea568a 100644
--- a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff
+++ b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff
@@ -7,7 +7,6 @@
       let _2: ();
       let mut _3: bool;
       scope 1 (inlined std::mem::drop::<bool>) {
-          debug _x => _3;
       }
   
       bb0: {
diff --git a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff
index 049b32f284d8b..b89432dd6d626 100644
--- a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff
+++ b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff
@@ -7,7 +7,6 @@
       let _2: ();
       let mut _3: T;
       scope 1 (inlined std::mem::drop::<T>) {
-          debug _x => _3;
       }
   
       bb0: {
diff --git a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff
index 1f7a6f9ad59fc..48d0260533223 100644
--- a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff
+++ b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff
@@ -7,7 +7,6 @@
       let _2: ();
       let mut _3: T;
       scope 1 (inlined std::mem::drop::<T>) {
-          debug _x => _3;
       }
   
       bb0: {
diff --git a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff
index d0abebff214d3..8dd904c7d7b99 100644
--- a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff
+++ b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff
@@ -5,54 +5,44 @@
       debug x => _1;
       let mut _0: std::result::Result<i32, i32>;
       let mut _2: std::ops::ControlFlow<std::result::Result<std::convert::Infallible, i32>, i32>;
-      let mut _3: std::result::Result<i32, i32>;
-      let mut _4: isize;
-      let _5: std::result::Result<std::convert::Infallible, i32>;
-      let mut _6: std::result::Result<std::convert::Infallible, i32>;
-      let _7: i32;
+      let mut _3: isize;
+      let _4: std::result::Result<std::convert::Infallible, i32>;
+      let _5: i32;
       scope 1 {
-          debug residual => _5;
+          debug residual => _4;
           scope 2 {
               scope 8 (inlined #[track_caller] <Result<i32, i32> as FromResidual<Result<Infallible, i32>>>::from_residual) {
-                  debug residual => _6;
-                  let _12: i32;
+                  let _10: i32;
                   scope 9 {
-                      debug e => _12;
                       scope 10 (inlined <i32 as From<i32>>::from) {
-                          debug t => _12;
                       }
                   }
               }
           }
       }
       scope 3 {
-          debug val => _7;
+          debug val => _5;
           scope 4 {
           }
       }
       scope 5 (inlined <Result<i32, i32> as Try>::branch) {
-          debug self => _3;
-          let mut _8: isize;
-          let _9: i32;
-          let _10: i32;
-          let mut _11: std::result::Result<std::convert::Infallible, i32>;
+          let mut _6: isize;
+          let _7: i32;
+          let _8: i32;
+          let mut _9: std::result::Result<std::convert::Infallible, i32>;
           scope 6 {
-              debug v => _9;
           }
           scope 7 {
-              debug e => _10;
           }
       }
   
       bb0: {
           StorageLive(_2);
-          StorageLive(_3);
-          _3 = _1;
+          StorageLive(_6);
+          StorageLive(_7);
           StorageLive(_8);
-          StorageLive(_9);
-          StorageLive(_10);
-          _8 = discriminant(_1);
-          switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb1];
+          _6 = discriminant(_1);
+          switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb1];
       }
   
       bb1: {
@@ -60,55 +50,50 @@
       }
   
       bb2: {
-          _7 = ((_2 as Continue).0: i32);
-          _0 = Result::<i32, i32>::Ok(_7);
+          _5 = ((_2 as Continue).0: i32);
+          _0 = Result::<i32, i32>::Ok(_5);
           StorageDead(_2);
           return;
       }
   
       bb3: {
-          _5 = ((_2 as Break).0: std::result::Result<std::convert::Infallible, i32>);
-          StorageLive(_6);
-          _6 = _5;
-          _12 = ((_5 as Err).0: i32);
-          _0 = Result::<i32, i32>::Err(_12);
-          StorageDead(_6);
+          _4 = ((_2 as Break).0: std::result::Result<std::convert::Infallible, i32>);
+          _10 = ((_4 as Err).0: i32);
+          _0 = Result::<i32, i32>::Err(_10);
           StorageDead(_2);
           return;
       }
   
       bb4: {
-          StorageDead(_10);
-          StorageDead(_9);
           StorageDead(_8);
-          StorageDead(_3);
-          _4 = discriminant(_2);
--         switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb1];
+          StorageDead(_7);
+          StorageDead(_6);
+          _3 = discriminant(_2);
+-         switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1];
 +         goto -> bb2;
       }
   
       bb5: {
-          _10 = ((_1 as Err).0: i32);
-          StorageLive(_11);
-          _11 = Result::<Infallible, i32>::Err(_10);
-          _2 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _11);
-          StorageDead(_11);
+          _8 = ((_1 as Err).0: i32);
+          StorageLive(_9);
+          _9 = Result::<Infallible, i32>::Err(_8);
+          _2 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _9);
+          StorageDead(_9);
 -         goto -> bb4;
 +         goto -> bb7;
       }
   
       bb6: {
-          _9 = ((_1 as Ok).0: i32);
-          _2 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(_9);
+          _7 = ((_1 as Ok).0: i32);
+          _2 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(_7);
           goto -> bb4;
 +     }
 + 
 +     bb7: {
-+         StorageDead(_10);
-+         StorageDead(_9);
 +         StorageDead(_8);
-+         StorageDead(_3);
-+         _4 = discriminant(_2);
++         StorageDead(_7);
++         StorageDead(_6);
++         _3 = discriminant(_2);
 +         goto -> bb3;
       }
   }

From 6094063c35d3b3f7c07b6c069ebeb27797ddadc1 Mon Sep 17 00:00:00 2001
From: Scott McMurray <scottmcm@users.noreply.github.com>
Date: Tue, 16 Apr 2024 11:11:30 -0700
Subject: [PATCH 2/5] Update `checked_ops` so 32- and 64-bit gets the same
 checks

---
 ...cked_shl.PreCodegen.after.panic-abort.mir} |  0
 ...cked_shl.PreCodegen.after.panic-unwind.mir | 62 +++++++++++++
 tests/mir-opt/pre-codegen/checked_ops.rs      |  5 +-
 ...p_forward.PreCodegen.after.panic-abort.mir | 92 +++++++++++++++++++
 ...forward.PreCodegen.after.panic-unwind.mir} | 34 +++----
 5 files changed, 174 insertions(+), 19 deletions(-)
 rename tests/mir-opt/pre-codegen/{checked_ops.checked_shl.PreCodegen.after.mir => checked_ops.checked_shl.PreCodegen.after.panic-abort.mir} (100%)
 create mode 100644 tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir
 create mode 100644 tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir
 rename tests/mir-opt/pre-codegen/{checked_ops.step_forward.PreCodegen.after.mir => checked_ops.step_forward.PreCodegen.after.panic-unwind.mir} (66%)

diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir
similarity index 100%
rename from tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir
rename to tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir
diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir
new file mode 100644
index 0000000000000..cadebcdf1f875
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,62 @@
+// MIR for `checked_shl` after PreCodegen
+
+fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
+    debug x => _1;
+    debug rhs => _2;
+    let mut _0: std::option::Option<u32>;
+    scope 1 (inlined core::num::<impl u32>::checked_shl) {
+        debug self => _1;
+        debug rhs => _2;
+        let mut _6: bool;
+        scope 2 {
+            debug a => _4;
+            debug b => _5;
+        }
+        scope 3 (inlined core::num::<impl u32>::overflowing_shl) {
+            let mut _4: u32;
+            let mut _5: bool;
+            scope 4 (inlined core::num::<impl u32>::wrapping_shl) {
+                let mut _3: u32;
+                scope 5 (inlined core::num::<impl u32>::unchecked_shl) {
+                }
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_4);
+        StorageLive(_5);
+        StorageLive(_3);
+        _3 = BitAnd(_2, const 31_u32);
+        _4 = ShlUnchecked(_1, _3);
+        StorageDead(_3);
+        _5 = Ge(_2, const core::num::<impl u32>::BITS);
+        StorageLive(_6);
+        _6 = unlikely(move _5) -> [return: bb1, unwind unreachable];
+    }
+
+    bb1: {
+        switchInt(move _6) -> [0: bb2, otherwise: bb3];
+    }
+
+    bb2: {
+        _0 = Option::<u32>::Some(_4);
+        goto -> bb4;
+    }
+
+    bb3: {
+        _0 = const Option::<u32>::None;
+        goto -> bb4;
+    }
+
+    bb4: {
+        StorageDead(_6);
+        StorageDead(_5);
+        StorageDead(_4);
+        return;
+    }
+}
+
+ALLOC0 (size: 8, align: 4) {
+    00 00 00 00 __ __ __ __                         │ ....░░░░
+}
diff --git a/tests/mir-opt/pre-codegen/checked_ops.rs b/tests/mir-opt/pre-codegen/checked_ops.rs
index 3ff1123d0b1e5..8dd5c4b495ec3 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.rs
+++ b/tests/mir-opt/pre-codegen/checked_ops.rs
@@ -1,12 +1,13 @@
 // skip-filecheck
 //@ compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2
-//@ needs-unwind
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
 
 #![crate_type = "lib"]
 #![feature(step_trait)]
 
 // EMIT_MIR checked_ops.step_forward.PreCodegen.after.mir
-pub fn step_forward(x: u32, n: usize) -> u32 {
+pub fn step_forward(x: u16, n: usize) -> u16 {
+    // This uses `u16` so that the conversion to usize is always widening.
     std::iter::Step::forward(x, n)
 }
 
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
new file mode 100644
index 0000000000000..9ff61d35fc51e
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,92 @@
+// MIR for `step_forward` after PreCodegen
+
+fn step_forward(_1: u16, _2: usize) -> u16 {
+    debug x => _1;
+    debug n => _2;
+    let mut _0: u16;
+    scope 1 (inlined <u16 as Step>::forward) {
+        debug start => _1;
+        debug n => _2;
+        let mut _8: u16;
+        scope 2 {
+        }
+        scope 3 (inlined <u16 as Step>::forward_checked) {
+            scope 4 {
+                scope 6 (inlined core::num::<impl u16>::checked_add) {
+                    let mut _7: bool;
+                    scope 7 {
+                    }
+                    scope 8 (inlined core::num::<impl u16>::overflowing_add) {
+                        let mut _5: (u16, bool);
+                        let _6: bool;
+                        scope 9 {
+                        }
+                    }
+                }
+            }
+            scope 5 (inlined convert::num::ptr_try_from_impls::<impl TryFrom<usize> for u16>::try_from) {
+                let mut _3: bool;
+                let mut _4: u16;
+            }
+        }
+        scope 10 (inlined Option::<u16>::is_none) {
+            scope 11 (inlined Option::<u16>::is_some) {
+            }
+        }
+        scope 12 (inlined core::num::<impl u16>::wrapping_add) {
+        }
+    }
+
+    bb0: {
+        StorageLive(_4);
+        StorageLive(_3);
+        _3 = Gt(_2, const 65535_usize);
+        switchInt(move _3) -> [0: bb1, otherwise: bb5];
+    }
+
+    bb1: {
+        _4 = _2 as u16 (IntToInt);
+        StorageDead(_3);
+        StorageLive(_6);
+        StorageLive(_5);
+        _5 = CheckedAdd(_1, _4);
+        _6 = (_5.1: bool);
+        StorageDead(_5);
+        StorageLive(_7);
+        _7 = unlikely(move _6) -> [return: bb2, unwind unreachable];
+    }
+
+    bb2: {
+        switchInt(move _7) -> [0: bb3, otherwise: bb4];
+    }
+
+    bb3: {
+        StorageDead(_7);
+        StorageDead(_6);
+        goto -> bb7;
+    }
+
+    bb4: {
+        StorageDead(_7);
+        StorageDead(_6);
+        goto -> bb6;
+    }
+
+    bb5: {
+        StorageDead(_3);
+        goto -> bb6;
+    }
+
+    bb6: {
+        assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::<impl u16>::MAX, const 1_u16) -> [success: bb7, unwind unreachable];
+    }
+
+    bb7: {
+        StorageLive(_8);
+        _8 = _2 as u16 (IntToInt);
+        _0 = Add(_1, _8);
+        StorageDead(_8);
+        StorageDead(_4);
+        return;
+    }
+}
diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir
similarity index 66%
rename from tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir
rename to tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir
index abbd170b4b9c2..36cba172a1a37 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir
@@ -1,51 +1,51 @@
 // MIR for `step_forward` after PreCodegen
 
-fn step_forward(_1: u32, _2: usize) -> u32 {
+fn step_forward(_1: u16, _2: usize) -> u16 {
     debug x => _1;
     debug n => _2;
-    let mut _0: u32;
-    scope 1 (inlined <u32 as Step>::forward) {
+    let mut _0: u16;
+    scope 1 (inlined <u16 as Step>::forward) {
         debug start => _1;
         debug n => _2;
-        let mut _8: u32;
+        let mut _8: u16;
         scope 2 {
         }
-        scope 3 (inlined <u32 as Step>::forward_checked) {
+        scope 3 (inlined <u16 as Step>::forward_checked) {
             scope 4 {
-                scope 6 (inlined core::num::<impl u32>::checked_add) {
+                scope 6 (inlined core::num::<impl u16>::checked_add) {
                     let mut _7: bool;
                     scope 7 {
                     }
-                    scope 8 (inlined core::num::<impl u32>::overflowing_add) {
-                        let mut _5: (u32, bool);
+                    scope 8 (inlined core::num::<impl u16>::overflowing_add) {
+                        let mut _5: (u16, bool);
                         let _6: bool;
                         scope 9 {
                         }
                     }
                 }
             }
-            scope 5 (inlined convert::num::ptr_try_from_impls::<impl TryFrom<usize> for u32>::try_from) {
+            scope 5 (inlined convert::num::ptr_try_from_impls::<impl TryFrom<usize> for u16>::try_from) {
                 let mut _3: bool;
-                let mut _4: u32;
+                let mut _4: u16;
             }
         }
-        scope 10 (inlined Option::<u32>::is_none) {
-            scope 11 (inlined Option::<u32>::is_some) {
+        scope 10 (inlined Option::<u16>::is_none) {
+            scope 11 (inlined Option::<u16>::is_some) {
             }
         }
-        scope 12 (inlined core::num::<impl u32>::wrapping_add) {
+        scope 12 (inlined core::num::<impl u16>::wrapping_add) {
         }
     }
 
     bb0: {
         StorageLive(_4);
         StorageLive(_3);
-        _3 = Gt(_2, const 4294967295_usize);
+        _3 = Gt(_2, const 65535_usize);
         switchInt(move _3) -> [0: bb1, otherwise: bb5];
     }
 
     bb1: {
-        _4 = _2 as u32 (IntToInt);
+        _4 = _2 as u16 (IntToInt);
         StorageDead(_3);
         StorageLive(_6);
         StorageLive(_5);
@@ -78,12 +78,12 @@ fn step_forward(_1: u32, _2: usize) -> u32 {
     }
 
     bb6: {
-        assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::<impl u32>::MAX, const 1_u32) -> [success: bb7, unwind continue];
+        assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::<impl u16>::MAX, const 1_u16) -> [success: bb7, unwind continue];
     }
 
     bb7: {
         StorageLive(_8);
-        _8 = _2 as u32 (IntToInt);
+        _8 = _2 as u16 (IntToInt);
         _0 = Add(_1, _8);
         StorageDead(_8);
         StorageDead(_4);

From 90b4c86335f625f64e6238614d4c7cfd0dbbb37a Mon Sep 17 00:00:00 2001
From: Scott McMurray <scottmcm@users.noreply.github.com>
Date: Wed, 17 Apr 2024 18:14:16 -0700
Subject: [PATCH 3/5] Ensure `[rust] debuginfo-level-std` doesn't change core's
 MIR

---
 compiler/rustc_mir_transform/src/inline.rs    | 12 ++-
 compiler/rustc_session/src/options.rs         |  3 +
 src/bootstrap/src/core/builder.rs             |  8 ++
 ...ine_coroutine.main.Inline.panic-abort.diff |  1 +
 ...ne_coroutine.main.Inline.panic-unwind.diff |  1 +
 ...ecked_shl.PreCodegen.after.panic-abort.mir |  6 ++
 ...cked_shl.PreCodegen.after.panic-unwind.mir |  6 ++
 ...p_forward.PreCodegen.after.panic-abort.mir | 79 +------------------
 ..._forward.PreCodegen.after.panic-unwind.mir | 79 +------------------
 9 files changed, 38 insertions(+), 157 deletions(-)

diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs
index 1182a73840280..625d8f53939ff 100644
--- a/compiler/rustc_mir_transform/src/inline.rs
+++ b/compiler/rustc_mir_transform/src/inline.rs
@@ -699,7 +699,17 @@ impl<'tcx> Inliner<'tcx> {
         // Insert all of the (mapped) parts of the callee body into the caller.
         caller_body.local_decls.extend(callee_body.drain_vars_and_temps());
         caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
-        if self.tcx.sess.opts.debuginfo != DebugInfo::None {
+        if self
+            .tcx
+            .sess
+            .opts
+            .unstable_opts
+            .inline_mir_preserve_debug
+            .unwrap_or(self.tcx.sess.opts.debuginfo != DebugInfo::None)
+        {
+            // Note that we need to preserve these in the standard library so that
+            // people working on rust can build with or without debuginfo while
+            // still getting consistent results from the mir-opt tests.
             caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
         }
         caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index c4d802a222b3d..6a2975263cf86 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -1717,6 +1717,9 @@ options! {
         "enable MIR inlining (default: no)"),
     inline_mir_hint_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
         "inlining threshold for functions with inline hint (default: 100)"),
+    inline_mir_preserve_debug: Option<bool> = (None, parse_opt_bool, [TRACKED],
+        "when MIR inlining, whether to preserve debug info for callee variables \
+        (default: preserve for debuginfo != None, otherwise remove)"),
     inline_mir_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
         "a default MIR inlining threshold (default: 50)"),
     input_stats: bool = (false, parse_bool, [UNTRACKED],
diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
index 499a74be6b151..80c38b80e774c 100644
--- a/src/bootstrap/src/core/builder.rs
+++ b/src/bootstrap/src/core/builder.rs
@@ -2102,6 +2102,14 @@ impl<'a> Builder<'a> {
             // break when incremental compilation is enabled. So this overrides the "no inlining
             // during incremental builds" heuristic for the standard library.
             rustflags.arg("-Zinline-mir");
+
+            // always pass this after the next `#[cfg(bootstrap)]` update.
+            if compiler.stage != 0 {
+                // Similarly, we need to keep debug info for functions inlined into other std functions,
+                // even if we're not going to output debuginfo for the crate we're currently building,
+                // so that it'll be available when downstream consumers of std try to use it.
+                rustflags.arg("-Zinline-mir-preserve-debug");
+            }
         }
 
         if self.config.rustc_parallel
diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff
index fcfa5953fc2c6..859082c311190 100644
--- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff
+++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff
@@ -16,6 +16,7 @@
 +     scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
 +         debug pointer => _3;
 +         scope 4 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
++             debug pointer => _3;
 +         }
 +     }
 +     scope 5 (inlined g::{closure#0}) {
diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff
index 69c632a9043da..44b06c34972af 100644
--- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff
+++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff
@@ -16,6 +16,7 @@
 +     scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
 +         debug pointer => _3;
 +         scope 4 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
++             debug pointer => _3;
 +         }
 +     }
 +     scope 5 (inlined g::{closure#0}) {
diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir
index cadebcdf1f875..845673601b2fb 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir
@@ -13,11 +13,17 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
             debug b => _5;
         }
         scope 3 (inlined core::num::<impl u32>::overflowing_shl) {
+            debug self => _1;
+            debug rhs => _2;
             let mut _4: u32;
             let mut _5: bool;
             scope 4 (inlined core::num::<impl u32>::wrapping_shl) {
+                debug self => _1;
+                debug rhs => _2;
                 let mut _3: u32;
                 scope 5 (inlined core::num::<impl u32>::unchecked_shl) {
+                    debug self => _1;
+                    debug rhs => _3;
                 }
             }
         }
diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir
index cadebcdf1f875..845673601b2fb 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir
@@ -13,11 +13,17 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
             debug b => _5;
         }
         scope 3 (inlined core::num::<impl u32>::overflowing_shl) {
+            debug self => _1;
+            debug rhs => _2;
             let mut _4: u32;
             let mut _5: bool;
             scope 4 (inlined core::num::<impl u32>::wrapping_shl) {
+                debug self => _1;
+                debug rhs => _2;
                 let mut _3: u32;
                 scope 5 (inlined core::num::<impl u32>::unchecked_shl) {
+                    debug self => _1;
+                    debug rhs => _3;
                 }
             }
         }
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 9ff61d35fc51e..cfb9134a1f13c 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
@@ -4,89 +4,12 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
     debug x => _1;
     debug n => _2;
     let mut _0: u16;
-    scope 1 (inlined <u16 as Step>::forward) {
-        debug start => _1;
-        debug n => _2;
-        let mut _8: u16;
-        scope 2 {
-        }
-        scope 3 (inlined <u16 as Step>::forward_checked) {
-            scope 4 {
-                scope 6 (inlined core::num::<impl u16>::checked_add) {
-                    let mut _7: bool;
-                    scope 7 {
-                    }
-                    scope 8 (inlined core::num::<impl u16>::overflowing_add) {
-                        let mut _5: (u16, bool);
-                        let _6: bool;
-                        scope 9 {
-                        }
-                    }
-                }
-            }
-            scope 5 (inlined convert::num::ptr_try_from_impls::<impl TryFrom<usize> for u16>::try_from) {
-                let mut _3: bool;
-                let mut _4: u16;
-            }
-        }
-        scope 10 (inlined Option::<u16>::is_none) {
-            scope 11 (inlined Option::<u16>::is_some) {
-            }
-        }
-        scope 12 (inlined core::num::<impl u16>::wrapping_add) {
-        }
-    }
 
     bb0: {
-        StorageLive(_4);
-        StorageLive(_3);
-        _3 = Gt(_2, const 65535_usize);
-        switchInt(move _3) -> [0: bb1, otherwise: bb5];
+        _0 = <u16 as Step>::forward(move _1, move _2) -> [return: bb1, unwind unreachable];
     }
 
     bb1: {
-        _4 = _2 as u16 (IntToInt);
-        StorageDead(_3);
-        StorageLive(_6);
-        StorageLive(_5);
-        _5 = CheckedAdd(_1, _4);
-        _6 = (_5.1: bool);
-        StorageDead(_5);
-        StorageLive(_7);
-        _7 = unlikely(move _6) -> [return: bb2, unwind unreachable];
-    }
-
-    bb2: {
-        switchInt(move _7) -> [0: bb3, otherwise: bb4];
-    }
-
-    bb3: {
-        StorageDead(_7);
-        StorageDead(_6);
-        goto -> bb7;
-    }
-
-    bb4: {
-        StorageDead(_7);
-        StorageDead(_6);
-        goto -> bb6;
-    }
-
-    bb5: {
-        StorageDead(_3);
-        goto -> bb6;
-    }
-
-    bb6: {
-        assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::<impl u16>::MAX, const 1_u16) -> [success: bb7, unwind unreachable];
-    }
-
-    bb7: {
-        StorageLive(_8);
-        _8 = _2 as u16 (IntToInt);
-        _0 = Add(_1, _8);
-        StorageDead(_8);
-        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 36cba172a1a37..cacc1224aba47 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
@@ -4,89 +4,12 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
     debug x => _1;
     debug n => _2;
     let mut _0: u16;
-    scope 1 (inlined <u16 as Step>::forward) {
-        debug start => _1;
-        debug n => _2;
-        let mut _8: u16;
-        scope 2 {
-        }
-        scope 3 (inlined <u16 as Step>::forward_checked) {
-            scope 4 {
-                scope 6 (inlined core::num::<impl u16>::checked_add) {
-                    let mut _7: bool;
-                    scope 7 {
-                    }
-                    scope 8 (inlined core::num::<impl u16>::overflowing_add) {
-                        let mut _5: (u16, bool);
-                        let _6: bool;
-                        scope 9 {
-                        }
-                    }
-                }
-            }
-            scope 5 (inlined convert::num::ptr_try_from_impls::<impl TryFrom<usize> for u16>::try_from) {
-                let mut _3: bool;
-                let mut _4: u16;
-            }
-        }
-        scope 10 (inlined Option::<u16>::is_none) {
-            scope 11 (inlined Option::<u16>::is_some) {
-            }
-        }
-        scope 12 (inlined core::num::<impl u16>::wrapping_add) {
-        }
-    }
 
     bb0: {
-        StorageLive(_4);
-        StorageLive(_3);
-        _3 = Gt(_2, const 65535_usize);
-        switchInt(move _3) -> [0: bb1, otherwise: bb5];
+        _0 = <u16 as Step>::forward(move _1, move _2) -> [return: bb1, unwind continue];
     }
 
     bb1: {
-        _4 = _2 as u16 (IntToInt);
-        StorageDead(_3);
-        StorageLive(_6);
-        StorageLive(_5);
-        _5 = CheckedAdd(_1, _4);
-        _6 = (_5.1: bool);
-        StorageDead(_5);
-        StorageLive(_7);
-        _7 = unlikely(move _6) -> [return: bb2, unwind unreachable];
-    }
-
-    bb2: {
-        switchInt(move _7) -> [0: bb3, otherwise: bb4];
-    }
-
-    bb3: {
-        StorageDead(_7);
-        StorageDead(_6);
-        goto -> bb7;
-    }
-
-    bb4: {
-        StorageDead(_7);
-        StorageDead(_6);
-        goto -> bb6;
-    }
-
-    bb5: {
-        StorageDead(_3);
-        goto -> bb6;
-    }
-
-    bb6: {
-        assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::<impl u16>::MAX, const 1_u16) -> [success: bb7, unwind continue];
-    }
-
-    bb7: {
-        StorageLive(_8);
-        _8 = _2 as u16 (IntToInt);
-        _0 = Add(_1, _8);
-        StorageDead(_8);
-        StorageDead(_4);
         return;
     }
 }

From b8ac5c0f91125cd962607826c50193c64bbc14ed Mon Sep 17 00:00:00 2001
From: scottmcm <scottmcm@users.noreply.github.com>
Date: Thu, 18 Apr 2024 06:04:59 +0000
Subject: [PATCH 4/5] Update src/bootstrap/src/core/builder.rs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Onur Özkan <onurozkan.dev@outlook.com>
---
 src/bootstrap/src/core/builder.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
index 80c38b80e774c..27ab6eac03a5a 100644
--- a/src/bootstrap/src/core/builder.rs
+++ b/src/bootstrap/src/core/builder.rs
@@ -2103,7 +2103,7 @@ impl<'a> Builder<'a> {
             // during incremental builds" heuristic for the standard library.
             rustflags.arg("-Zinline-mir");
 
-            // always pass this after the next `#[cfg(bootstrap)]` update.
+            // FIXME: always pass this after the next `#[cfg(bootstrap)]` update.
             if compiler.stage != 0 {
                 // Similarly, we need to keep debug info for functions inlined into other std functions,
                 // even if we're not going to output debuginfo for the crate we're currently building,

From 20cf59549f04271278099d9acfcd04d21dae8018 Mon Sep 17 00:00:00 2001
From: Scott McMurray <scottmcm@users.noreply.github.com>
Date: Thu, 18 Apr 2024 09:42:26 -0700
Subject: [PATCH 5/5] The ICE in 121127 needs debuginfo

---
 tests/crashes/121127.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/crashes/121127.rs b/tests/crashes/121127.rs
index 8bb63a74bc280..2e64bf68b82fb 100644
--- a/tests/crashes/121127.rs
+++ b/tests/crashes/121127.rs
@@ -1,5 +1,6 @@
 //@ known-bug: #121127
-//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes
+//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes -C debuginfo=2
+// Note that as of PR#123949 this only crashes with debuginfo enabled
 
 #![feature(specialization)]