Skip to content

Commit ccc3ac0

Browse files
committedAug 17, 2023
Auto merge of #114904 - cjgillot:no-ref-debuginfo, r=wesleywiser
Remove references in VarDebugInfo The codegen implementation is broken, and attempted to read uninitialized memory. Fixes #114488
·
1.87.01.73.0
2 parents 0768872 + 3798bca commit ccc3ac0

File tree

38 files changed

+787
-626
lines changed

38 files changed

+787
-626
lines changed
 

‎compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ pub struct PerLocalVarDebugInfo<'tcx, D> {
4242

4343
/// `.place.projection` from `mir::VarDebugInfo`.
4444
pub projection: &'tcx ty::List<mir::PlaceElem<'tcx>>,
45-
46-
/// `references` from `mir::VarDebugInfo`.
47-
pub references: u8,
4845
}
4946

5047
#[derive(Clone, Copy, Debug)]
@@ -323,7 +320,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
323320
dbg_var,
324321
fragment: None,
325322
projection: ty::List::empty(),
326-
references: 0,
327323
})
328324
}
329325
} else {
@@ -399,15 +395,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
399395
&self,
400396
bx: &mut Bx,
401397
local: mir::Local,
402-
mut base: PlaceRef<'tcx, Bx::Value>,
398+
base: PlaceRef<'tcx, Bx::Value>,
403399
var: PerLocalVarDebugInfo<'tcx, Bx::DIVariable>,
404400
) {
405401
let Some(dbg_var) = var.dbg_var else { return };
406402
let Some(dbg_loc) = self.dbg_loc(var.source_info) else { return };
407403

408-
let DebugInfoOffset { mut direct_offset, indirect_offsets, result: _ } =
404+
let DebugInfoOffset { direct_offset, indirect_offsets, result: _ } =
409405
calculate_debuginfo_offset(bx, local, &var, base.layout);
410-
let mut indirect_offsets = &indirect_offsets[..];
411406

412407
// When targeting MSVC, create extra allocas for arguments instead of pointing multiple
413408
// dbg_var_addr() calls into the same alloca with offsets. MSVC uses CodeView records
@@ -421,45 +416,29 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
421416
// LLVM can handle simple things but anything more complex than just a direct
422417
// offset or one indirect offset of 0 is too complex for it to generate CV records
423418
// correctly.
424-
&& (direct_offset != Size::ZERO || !matches!(indirect_offsets, [Size::ZERO] | []));
419+
&& (direct_offset != Size::ZERO || !matches!(&indirect_offsets[..], [Size::ZERO] | []));
420+
421+
if should_create_individual_allocas {
422+
let DebugInfoOffset { direct_offset: _, indirect_offsets: _, result: place } =
423+
calculate_debuginfo_offset(bx, local, &var, base);
425424

426-
let create_alloca = |bx: &mut Bx, place: PlaceRef<'tcx, Bx::Value>, refcount| {
427425
// Create a variable which will be a pointer to the actual value
428426
let ptr_ty = Ty::new_ptr(
429427
bx.tcx(),
430428
ty::TypeAndMut { mutbl: mir::Mutability::Mut, ty: place.layout.ty },
431429
);
432430
let ptr_layout = bx.layout_of(ptr_ty);
433431
let alloca = PlaceRef::alloca(bx, ptr_layout);
434-
bx.set_var_name(alloca.llval, &format!("{}.ref{}.dbg.spill", var.name, refcount));
432+
bx.set_var_name(alloca.llval, &(var.name.to_string() + ".dbg.spill"));
435433

436434
// Write the pointer to the variable
437435
bx.store(place.llval, alloca.llval, alloca.align);
438436

439437
// Point the debug info to `*alloca` for the current variable
440-
alloca
441-
};
442-
443-
if var.references > 0 {
444-
base = calculate_debuginfo_offset(bx, local, &var, base).result;
445-
446-
// Point the debug info to `&...&base == alloca` for the current variable
447-
for refcount in 0..var.references {
448-
base = create_alloca(bx, base, refcount);
449-
}
450-
451-
direct_offset = Size::ZERO;
452-
indirect_offsets = &[];
453-
} else if should_create_individual_allocas {
454-
let place = calculate_debuginfo_offset(bx, local, &var, base).result;
455-
456-
// Point the debug info to `*alloca` for the current variable
457-
base = create_alloca(bx, place, 0);
458-
direct_offset = Size::ZERO;
459-
indirect_offsets = &[Size::ZERO];
438+
bx.dbg_var_addr(dbg_var, dbg_loc, alloca.llval, Size::ZERO, &[Size::ZERO], None);
439+
} else {
440+
bx.dbg_var_addr(dbg_var, dbg_loc, base.llval, direct_offset, &indirect_offsets, None);
460441
}
461-
462-
bx.dbg_var_addr(dbg_var, dbg_loc, base.llval, direct_offset, indirect_offsets, None);
463442
}
464443

465444
pub fn debug_introduce_locals(&self, bx: &mut Bx) {
@@ -492,7 +471,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
492471
};
493472

494473
let dbg_var = dbg_scope_and_span.map(|(dbg_scope, _, span)| {
495-
let (mut var_ty, var_kind) = match var.value {
474+
let (var_ty, var_kind) = match var.value {
496475
mir::VarDebugInfoContents::Place(place) => {
497476
let var_ty = self.monomorphized_place_ty(place.as_ref());
498477
let var_kind = if let Some(arg_index) = var.argument_index
@@ -529,13 +508,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
529508
}
530509
};
531510

532-
for _ in 0..var.references {
533-
var_ty = Ty::new_ptr(
534-
bx.tcx(),
535-
ty::TypeAndMut { mutbl: mir::Mutability::Mut, ty: var_ty },
536-
);
537-
}
538-
539511
self.cx.create_dbg_var(var.name, var_ty, dbg_scope, var_kind, span)
540512
});
541513

@@ -547,7 +519,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
547519
dbg_var,
548520
fragment: None,
549521
projection: place.projection,
550-
references: var.references,
551522
});
552523
}
553524
mir::VarDebugInfoContents::Const(c) => {
@@ -601,7 +572,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
601572
Some(fragment_start..fragment_start + fragment_layout.size)
602573
},
603574
projection: place.projection,
604-
references: var.references,
605575
});
606576
}
607577
}

‎compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
701701
VarDebugInfoContents::Const(_) => {}
702702
VarDebugInfoContents::Place(place) => {
703703
check_place(self, place);
704-
if debuginfo.references != 0 && place.projection.last() == Some(&PlaceElem::Deref) {
705-
self.fail(
706-
START_BLOCK.start_location(),
707-
format!("debuginfo {debuginfo:?}, has both ref and deref"),
708-
);
709-
}
710704
}
711705
VarDebugInfoContents::Composite { ty, ref fragments } => {
712706
for f in fragments {

‎compiler/rustc_middle/src/mir/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,10 +1109,6 @@ pub struct VarDebugInfo<'tcx> {
11091109
/// originated from (starting from 1). Note, if MIR inlining is enabled, then this is the
11101110
/// argument number in the original function before it was inlined.
11111111
pub argument_index: Option<u16>,
1112-
1113-
/// The data represents `name` dereferenced `references` times,
1114-
/// and not the direct value.
1115-
pub references: u8,
11161112
}
11171113

11181114
///////////////////////////////////////////////////////////////////////////

‎compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,8 @@ fn write_scope_tree(
555555
}
556556

557557
let indented_debug_info = format!(
558-
"{0:1$}debug {2} => {3:&<4$}{5:?};",
559-
INDENT,
560-
indent,
561-
var_debug_info.name,
562-
"",
563-
var_debug_info.references as usize,
564-
var_debug_info.value,
558+
"{0:1$}debug {2} => {3:?};",
559+
INDENT, indent, var_debug_info.name, var_debug_info.value,
565560
);
566561

567562
if tcx.sess.opts.unstable_opts.mir_include_spans {

‎compiler/rustc_middle/src/mir/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,6 @@ macro_rules! make_mir_visitor {
840840
source_info,
841841
value,
842842
argument_index: _,
843-
references: _,
844843
} = var_debug_info;
845844

846845
self.visit_source_info(source_info);

‎compiler/rustc_middle/src/ty/structural_impls.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ CloneLiftImpls! {
438438
(),
439439
bool,
440440
usize,
441-
u8,
442441
u16,
443442
u32,
444443
u64,

‎compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
22422242
self.var_debug_info.push(VarDebugInfo {
22432243
name,
22442244
source_info: debug_source_info,
2245-
references: 0,
22462245
value: VarDebugInfoContents::Place(for_arm_body.into()),
22472246
argument_index: None,
22482247
});
@@ -2262,7 +2261,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
22622261
self.var_debug_info.push(VarDebugInfo {
22632262
name,
22642263
source_info: debug_source_info,
2265-
references: 0,
22662264
value: VarDebugInfoContents::Place(ref_for_guard.into()),
22672265
argument_index: None,
22682266
});

‎compiler/rustc_mir_build/src/build/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
820820
};
821821
self.var_debug_info.push(VarDebugInfo {
822822
name,
823-
references: 0,
824823
source_info: SourceInfo::outermost(captured_place.var_ident.span),
825824
value: VarDebugInfoContents::Place(use_place),
826825
argument_index: None,
@@ -851,7 +850,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
851850
self.var_debug_info.push(VarDebugInfo {
852851
name,
853852
source_info,
854-
references: 0,
855853
value: VarDebugInfoContents::Place(arg_local.into()),
856854
argument_index: Some(argument_index as u16 + 1),
857855
});

‎compiler/rustc_mir_transform/src/ref_prop.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ fn compute_replacement<'tcx>(
265265
targets,
266266
storage_to_remove,
267267
allowed_replacements,
268-
fully_replacable_locals,
269268
any_replacement: false,
270269
};
271270

@@ -346,7 +345,6 @@ struct Replacer<'tcx> {
346345
storage_to_remove: BitSet<Local>,
347346
allowed_replacements: FxHashSet<(Local, Location)>,
348347
any_replacement: bool,
349-
fully_replacable_locals: BitSet<Local>,
350348
}
351349

352350
impl<'tcx> MutVisitor<'tcx> for Replacer<'tcx> {
@@ -366,12 +364,6 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'tcx> {
366364
if let Some((&PlaceElem::Deref, rest)) = target.projection.split_last() {
367365
*place = Place::from(target.local).project_deeper(rest, self.tcx);
368366
self.any_replacement = true;
369-
} else if self.fully_replacable_locals.contains(place.local)
370-
&& let Some(references) = debuginfo.references.checked_add(1)
371-
{
372-
debuginfo.references = references;
373-
*place = target;
374-
self.any_replacement = true;
375367
} else {
376368
break
377369
}

‎compiler/rustc_type_ir/src/structural_impls.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ TrivialTypeTraversalImpls! {
2323
(),
2424
bool,
2525
usize,
26-
u8,
2726
u16,
2827
u32,
2928
u64,

‎tests/codegen/slice-ref-equality.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,48 +44,48 @@ pub fn is_zero_array(data: &[u8; 4]) -> bool {
4444
// equality for non-byte types also just emit a `bcmp`, not a loop.
4545

4646
// CHECK-LABEL: @eq_slice_of_nested_u8(
47-
// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1
48-
// CHECK-SAME: [[USIZE]] noundef %y.1
47+
// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
48+
// CHECK-SAME: [[USIZE]] noundef %3
4949
#[no_mangle]
5050
fn eq_slice_of_nested_u8(x: &[[u8; 3]], y: &[[u8; 3]]) -> bool {
51-
// CHECK: icmp eq [[USIZE]] %x.1, %y.1
52-
// CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %x.1, 3
51+
// CHECK: icmp eq [[USIZE]] %1, %3
52+
// CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %1, 3
5353
// CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
5454
// CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]])
5555
x == y
5656
}
5757

5858
// CHECK-LABEL: @eq_slice_of_i32(
59-
// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1
60-
// CHECK-SAME: [[USIZE]] noundef %y.1
59+
// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
60+
// CHECK-SAME: [[USIZE]] noundef %3
6161
#[no_mangle]
6262
fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool {
63-
// CHECK: icmp eq [[USIZE]] %x.1, %y.1
64-
// CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 2
63+
// CHECK: icmp eq [[USIZE]] %1, %3
64+
// CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2
6565
// CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
6666
// CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]])
6767
x == y
6868
}
6969

7070
// CHECK-LABEL: @eq_slice_of_nonzero(
71-
// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1
72-
// CHECK-SAME: [[USIZE]] noundef %y.1
71+
// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
72+
// CHECK-SAME: [[USIZE]] noundef %3
7373
#[no_mangle]
7474
fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool {
75-
// CHECK: icmp eq [[USIZE]] %x.1, %y.1
76-
// CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 2
75+
// CHECK: icmp eq [[USIZE]] %1, %3
76+
// CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2
7777
// CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
7878
// CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]])
7979
x == y
8080
}
8181

8282
// CHECK-LABEL: @eq_slice_of_option_of_nonzero(
83-
// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1
84-
// CHECK-SAME: [[USIZE]] noundef %y.1
83+
// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1
84+
// CHECK-SAME: [[USIZE]] noundef %3
8585
#[no_mangle]
8686
fn eq_slice_of_option_of_nonzero(x: &[Option<NonZeroI16>], y: &[Option<NonZeroI16>]) -> bool {
87-
// CHECK: icmp eq [[USIZE]] %x.1, %y.1
88-
// CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 1
87+
// CHECK: icmp eq [[USIZE]] %1, %3
88+
// CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 1
8989
// CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr
9090
// CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]])
9191
x == y

‎tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
let mut _2: std::option::Option<T>;
88
+ scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
99
+ debug self => _2;
10-
+ let mut _3: isize;
10+
+ let mut _3: &std::option::Option<T>;
11+
+ let mut _4: isize;
1112
+ scope 2 {
1213
+ debug val => _0;
1314
+ }
@@ -20,16 +21,17 @@
2021
+ }
2122
+ }
2223
+ scope 4 (inlined Option::<T>::is_some) {
23-
+ debug self => &_2;
24+
+ debug self => _3;
2425
+ }
2526
+ }
2627

2728
bb0: {
2829
StorageLive(_2);
2930
_2 = move _1;
3031
- _0 = Option::<T>::unwrap_unchecked(move _2) -> [return: bb1, unwind unreachable];
31-
+ _3 = discriminant(_2);
32-
+ switchInt(move _3) -> [1: bb2, otherwise: bb1];
32+
+ StorageLive(_3);
33+
+ _4 = discriminant(_2);
34+
+ switchInt(move _4) -> [1: bb2, otherwise: bb1];
3335
}
3436

3537
bb1: {
@@ -38,6 +40,7 @@
3840
+
3941
+ bb2: {
4042
+ _0 = move ((_2 as Some).0: T);
43+
+ StorageDead(_3);
4144
StorageDead(_2);
4245
return;
4346
}

‎tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
let mut _2: std::option::Option<T>;
88
+ scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
99
+ debug self => _2;
10-
+ let mut _3: isize;
10+
+ let mut _3: &std::option::Option<T>;
11+
+ let mut _4: isize;
1112
+ scope 2 {
1213
+ debug val => _0;
1314
+ }
@@ -20,16 +21,17 @@
2021
+ }
2122
+ }
2223
+ scope 4 (inlined Option::<T>::is_some) {
23-
+ debug self => &_2;
24+
+ debug self => _3;
2425
+ }
2526
+ }
2627

2728
bb0: {
2829
StorageLive(_2);
2930
_2 = move _1;
3031
- _0 = Option::<T>::unwrap_unchecked(move _2) -> [return: bb1, unwind: bb2];
31-
+ _3 = discriminant(_2);
32-
+ switchInt(move _3) -> [1: bb2, otherwise: bb1];
32+
+ StorageLive(_3);
33+
+ _4 = discriminant(_2);
34+
+ switchInt(move _4) -> [1: bb2, otherwise: bb1];
3335
}
3436

3537
bb1: {
@@ -42,6 +44,7 @@
4244
- resume;
4345
+ bb2: {
4446
+ _0 = move ((_2 as Some).0: T);
47+
+ StorageDead(_3);
4548
+ StorageDead(_2);
4649
+ return;
4750
}

‎tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
66
scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
77
debug self => _1;
88
let mut _2: isize;
9+
let mut _3: &std::option::Option<T>;
910
scope 2 {
1011
debug val => _0;
1112
}
@@ -18,17 +19,19 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
1819
}
1920
}
2021
scope 4 (inlined Option::<T>::is_some) {
21-
debug self => &_1;
22+
debug self => _3;
2223
}
2324
}
2425

2526
bb0: {
27+
StorageLive(_3);
2628
_2 = discriminant(_1);
2729
switchInt(move _2) -> [1: bb1, otherwise: bb2];
2830
}
2931

3032
bb1: {
3133
_0 = move ((_1 as Some).0: T);
34+
StorageDead(_3);
3235
return;
3336
}
3437

‎tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
66
scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
77
debug self => _1;
88
let mut _2: isize;
9+
let mut _3: &std::option::Option<T>;
910
scope 2 {
1011
debug val => _0;
1112
}
@@ -18,17 +19,19 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
1819
}
1920
}
2021
scope 4 (inlined Option::<T>::is_some) {
21-
debug self => &_1;
22+
debug self => _3;
2223
}
2324
}
2425

2526
bb0: {
27+
StorageLive(_3);
2628
_2 = discriminant(_1);
2729
switchInt(move _2) -> [1: bb1, otherwise: bb2];
2830
}
2931

3032
bb1: {
3133
_0 = move ((_1 as Some).0: T);
34+
StorageDead(_3);
3235
return;
3336
}
3437

‎tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
let mut _8: usize;
1414
let mut _9: usize;
1515
let mut _10: bool;
16-
let mut _11: !;
16+
let mut _14: !;
1717
scope 1 {
1818
debug v => _2;
19+
let _11: &T;
20+
let _12: &T;
21+
let _13: &T;
1922
scope 2 {
20-
debug v1 => &(*_2)[0 of 3];
21-
debug v2 => &(*_2)[1 of 3];
22-
debug v3 => &(*_2)[2 of 3];
23+
debug v1 => _11;
24+
debug v2 => _12;
25+
debug v3 => _13;
2326
}
2427
}
2528

@@ -39,10 +42,19 @@
3942
}
4043

4144
bb1: {
42-
_11 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable;
45+
_14 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable;
4346
}
4447

4548
bb2: {
49+
StorageLive(_11);
50+
_11 = &(*_2)[0 of 3];
51+
StorageLive(_12);
52+
_12 = &(*_2)[1 of 3];
53+
StorageLive(_13);
54+
_13 = &(*_2)[2 of 3];
55+
StorageDead(_13);
56+
StorageDead(_12);
57+
StorageDead(_11);
4658
StorageDead(_4);
4759
return;
4860
}

‎tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
let mut _8: usize;
1414
let mut _9: usize;
1515
let mut _10: bool;
16-
let mut _11: !;
16+
let mut _14: !;
1717
scope 1 {
1818
debug v => _2;
19+
let _11: &T;
20+
let _12: &T;
21+
let _13: &T;
1922
scope 2 {
20-
debug v1 => &(*_2)[0 of 3];
21-
debug v2 => &(*_2)[1 of 3];
22-
debug v3 => &(*_2)[2 of 3];
23+
debug v1 => _11;
24+
debug v2 => _12;
25+
debug v3 => _13;
2326
}
2427
}
2528

@@ -39,10 +42,19 @@
3942
}
4043

4144
bb1: {
42-
_11 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue;
45+
_14 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue;
4346
}
4447

4548
bb2: {
49+
StorageLive(_11);
50+
_11 = &(*_2)[0 of 3];
51+
StorageLive(_12);
52+
_12 = &(*_2)[1 of 3];
53+
StorageLive(_13);
54+
_13 = &(*_2)[2 of 3];
55+
StorageDead(_13);
56+
StorageDead(_12);
57+
StorageDead(_11);
4658
StorageDead(_4);
4759
return;
4860
}

‎tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ fn num_to_digit(_1: char) -> u32 {
88
debug self => _1;
99
debug radix => const 8_u32;
1010
let _2: std::option::Option<u32>;
11+
let mut _7: &std::option::Option<u32>;
1112
scope 2 (inlined Option::<u32>::is_some) {
12-
debug self => &_2;
13+
debug self => _7;
1314
let mut _3: isize;
1415
}
1516
}
@@ -23,12 +24,14 @@ fn num_to_digit(_1: char) -> u32 {
2324
}
2425

2526
bb0: {
27+
StorageLive(_7);
2628
StorageLive(_2);
2729
_2 = char::methods::<impl char>::to_digit(_1, const 8_u32) -> [return: bb1, unwind unreachable];
2830
}
2931

3032
bb1: {
3133
_3 = discriminant(_2);
34+
StorageDead(_7);
3235
StorageDead(_2);
3336
switchInt(move _3) -> [1: bb2, otherwise: bb7];
3437
}

‎tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ fn num_to_digit(_1: char) -> u32 {
88
debug self => _1;
99
debug radix => const 8_u32;
1010
let _2: std::option::Option<u32>;
11+
let mut _7: &std::option::Option<u32>;
1112
scope 2 (inlined Option::<u32>::is_some) {
12-
debug self => &_2;
13+
debug self => _7;
1314
let mut _3: isize;
1415
}
1516
}
@@ -23,12 +24,14 @@ fn num_to_digit(_1: char) -> u32 {
2324
}
2425

2526
bb0: {
27+
StorageLive(_7);
2628
StorageLive(_2);
2729
_2 = char::methods::<impl char>::to_digit(_1, const 8_u32) -> [return: bb1, unwind continue];
2830
}
2931

3032
bb1: {
3133
_3 = discriminant(_2);
34+
StorageDead(_7);
3235
StorageDead(_2);
3336
switchInt(move _3) -> [1: bb2, otherwise: bb7];
3437
}

‎tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ fn step_forward(_1: u32, _2: usize) -> u32 {
1010
let _3: std::option::Option<u32>;
1111
let mut _6: bool;
1212
let mut _7: u32;
13+
let mut _8: &std::option::Option<u32>;
1314
scope 2 {
1415
}
1516
scope 3 (inlined Option::<u32>::is_none) {
16-
debug self => &_3;
17+
debug self => _8;
1718
let mut _5: bool;
1819
scope 4 (inlined Option::<u32>::is_some) {
19-
debug self => &_3;
20+
debug self => _8;
2021
let mut _4: isize;
2122
}
2223
}
@@ -28,6 +29,7 @@ fn step_forward(_1: u32, _2: usize) -> u32 {
2829

2930
bb0: {
3031
StorageLive(_6);
32+
StorageLive(_8);
3133
StorageLive(_3);
3234
_3 = <u32 as Step>::forward_checked(_1, _2) -> [return: bb1, unwind continue];
3335
}
@@ -39,6 +41,7 @@ fn step_forward(_1: u32, _2: usize) -> u32 {
3941
_6 = Not(move _5);
4042
StorageDead(_5);
4143
StorageDead(_3);
44+
StorageDead(_8);
4245
switchInt(move _6) -> [0: bb3, otherwise: bb2];
4346
}
4447

‎tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ fn filter_mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> Option<U>) -> ()
1010
let mut _8: std::option::Option<U>;
1111
let mut _9: isize;
1212
let _11: ();
13+
let mut _12: &mut std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>;
1314
scope 1 {
1415
debug iter => _5;
1516
let _10: U;
1617
scope 2 {
1718
debug x => _10;
1819
}
1920
scope 4 (inlined <FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>> as Iterator>::next) {
20-
debug self => &_5;
21+
debug self => _12;
2122
let mut _6: &mut impl Iterator<Item = T>;
2223
let mut _7: &mut impl Fn(T) -> Option<U>;
2324
}

‎tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,95 +4,108 @@ fn int_range(_1: usize, _2: usize) -> () {
44
debug start => _1;
55
debug end => _2;
66
let mut _0: ();
7-
let mut _3: usize;
8-
let mut _6: std::option::Option<usize>;
9-
let mut _9: isize;
10-
let _11: ();
7+
let mut _3: std::ops::Range<usize>;
8+
let mut _4: std::ops::Range<usize>;
9+
let mut _8: std::option::Option<usize>;
10+
let mut _11: isize;
11+
let _13: ();
12+
let mut _14: &mut std::ops::Range<usize>;
1113
scope 1 {
12-
debug iter => std::ops::Range<usize>{ .0 => _3, .1 => _2, };
13-
let _10: usize;
14+
debug iter => _4;
15+
let _12: usize;
1416
scope 2 {
15-
debug i => _10;
17+
debug i => _12;
1618
}
1719
scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
18-
debug self => &std::ops::Range<usize>{ .0 => _3, .1 => _2, };
20+
debug self => _14;
1921
scope 5 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
20-
debug self => &std::ops::Range<usize>{ .0 => _3, .1 => _2, };
21-
let mut _5: bool;
22-
let _7: usize;
23-
let mut _8: usize;
22+
debug self => _14;
23+
let mut _7: bool;
24+
let _9: usize;
25+
let mut _10: usize;
26+
let mut _15: &usize;
27+
let mut _16: &usize;
2428
scope 6 {
25-
debug old => _7;
29+
debug old => _9;
2630
scope 7 {
2731
}
2832
}
2933
scope 8 (inlined cmp::impls::<impl PartialOrd for usize>::lt) {
30-
debug self => &_3;
31-
debug other => &_2;
32-
let mut _4: usize;
34+
debug self => _15;
35+
debug other => _16;
36+
let mut _5: usize;
37+
let mut _6: usize;
3338
}
3439
}
3540
}
3641
}
3742
scope 3 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) {
38-
debug self => std::ops::Range<usize>{ .0 => _1, .1 => _2, };
43+
debug self => _3;
3944
}
4045

4146
bb0: {
42-
StorageLive(_3);
43-
_3 = _1;
47+
_3 = std::ops::Range::<usize> { start: _1, end: _2 };
48+
StorageLive(_4);
49+
_4 = move _3;
4450
goto -> bb1;
4551
}
4652

4753
bb1: {
48-
StorageLive(_6);
54+
StorageLive(_8);
55+
StorageLive(_9);
4956
StorageLive(_7);
57+
StorageLive(_15);
58+
StorageLive(_16);
5059
StorageLive(_5);
51-
StorageLive(_4);
52-
_4 = _3;
53-
_5 = Lt(move _4, _2);
54-
StorageDead(_4);
55-
switchInt(move _5) -> [0: bb2, otherwise: bb3];
60+
_5 = (_4.0: usize);
61+
StorageLive(_6);
62+
_6 = (_4.1: usize);
63+
_7 = Lt(move _5, move _6);
64+
StorageDead(_6);
65+
StorageDead(_5);
66+
StorageDead(_16);
67+
StorageDead(_15);
68+
switchInt(move _7) -> [0: bb2, otherwise: bb3];
5669
}
5770

5871
bb2: {
59-
_6 = Option::<usize>::None;
72+
_8 = Option::<usize>::None;
6073
goto -> bb5;
6174
}
6275

6376
bb3: {
64-
_7 = _3;
65-
StorageLive(_8);
66-
_8 = <usize as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb4, unwind continue];
77+
_9 = (_4.0: usize);
78+
StorageLive(_10);
79+
_10 = <usize as Step>::forward_unchecked(_9, const 1_usize) -> [return: bb4, unwind continue];
6780
}
6881

6982
bb4: {
70-
_3 = move _8;
71-
StorageDead(_8);
72-
_6 = Option::<usize>::Some(_7);
83+
(_4.0: usize) = move _10;
84+
StorageDead(_10);
85+
_8 = Option::<usize>::Some(_9);
7386
goto -> bb5;
7487
}
7588

7689
bb5: {
77-
StorageDead(_5);
7890
StorageDead(_7);
79-
_9 = discriminant(_6);
80-
switchInt(move _9) -> [0: bb6, 1: bb7, otherwise: bb9];
91+
StorageDead(_9);
92+
_11 = discriminant(_8);
93+
switchInt(move _11) -> [0: bb6, 1: bb7, otherwise: bb9];
8194
}
8295

8396
bb6: {
84-
StorageDead(_6);
85-
StorageDead(_3);
97+
StorageDead(_8);
98+
StorageDead(_4);
8699
return;
87100
}
88101

89102
bb7: {
90-
_10 = ((_6 as Some).0: usize);
91-
_11 = opaque::<usize>(move _10) -> [return: bb8, unwind continue];
103+
_12 = ((_8 as Some).0: usize);
104+
_13 = opaque::<usize>(move _12) -> [return: bb8, unwind continue];
92105
}
93106

94107
bb8: {
95-
StorageDead(_6);
108+
StorageDead(_8);
96109
goto -> bb1;
97110
}
98111

‎tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,87 +5,100 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
55
debug end => _2;
66
debug f => _3;
77
let mut _0: ();
8-
let mut _4: u32;
9-
let mut _7: std::option::Option<u32>;
10-
let mut _10: isize;
11-
let mut _12: &impl Fn(u32);
12-
let mut _13: (u32,);
13-
let _14: ();
8+
let mut _4: std::ops::Range<u32>;
9+
let mut _5: std::ops::Range<u32>;
10+
let mut _9: std::option::Option<u32>;
11+
let mut _12: isize;
12+
let mut _14: &impl Fn(u32);
13+
let mut _15: (u32,);
14+
let _16: ();
15+
let mut _17: &mut std::ops::Range<u32>;
1416
scope 1 {
15-
debug iter => std::ops::Range<u32>{ .0 => _4, .1 => _2, };
16-
let _11: u32;
17+
debug iter => _5;
18+
let _13: u32;
1719
scope 2 {
18-
debug x => _11;
20+
debug x => _13;
1921
}
2022
scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
21-
debug self => &std::ops::Range<u32>{ .0 => _4, .1 => _2, };
23+
debug self => _17;
2224
scope 5 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) {
23-
debug self => &std::ops::Range<u32>{ .0 => _4, .1 => _2, };
24-
let mut _6: bool;
25-
let _8: u32;
26-
let mut _9: u32;
25+
debug self => _17;
26+
let mut _8: bool;
27+
let _10: u32;
28+
let mut _11: u32;
29+
let mut _18: &u32;
30+
let mut _19: &u32;
2731
scope 6 {
28-
debug old => _8;
32+
debug old => _10;
2933
scope 7 {
3034
}
3135
}
3236
scope 8 (inlined cmp::impls::<impl PartialOrd for u32>::lt) {
33-
debug self => &_4;
34-
debug other => &_2;
35-
let mut _5: u32;
37+
debug self => _18;
38+
debug other => _19;
39+
let mut _6: u32;
40+
let mut _7: u32;
3641
}
3742
}
3843
}
3944
}
4045
scope 3 (inlined <std::ops::Range<u32> as IntoIterator>::into_iter) {
41-
debug self => std::ops::Range<u32>{ .0 => _1, .1 => _2, };
46+
debug self => _4;
4247
}
4348

4449
bb0: {
45-
StorageLive(_4);
46-
_4 = _1;
50+
_4 = std::ops::Range::<u32> { start: _1, end: _2 };
51+
StorageLive(_5);
52+
_5 = move _4;
4753
goto -> bb1;
4854
}
4955

5056
bb1: {
51-
StorageLive(_7);
57+
StorageLive(_9);
58+
StorageLive(_10);
5259
StorageLive(_8);
60+
StorageLive(_18);
61+
StorageLive(_19);
5362
StorageLive(_6);
54-
StorageLive(_5);
55-
_5 = _4;
56-
_6 = Lt(move _5, _2);
57-
StorageDead(_5);
58-
switchInt(move _6) -> [0: bb2, otherwise: bb3];
63+
_6 = (_5.0: u32);
64+
StorageLive(_7);
65+
_7 = (_5.1: u32);
66+
_8 = Lt(move _6, move _7);
67+
StorageDead(_7);
68+
StorageDead(_6);
69+
StorageDead(_19);
70+
StorageDead(_18);
71+
switchInt(move _8) -> [0: bb2, otherwise: bb3];
5972
}
6073

6174
bb2: {
62-
_7 = Option::<u32>::None;
75+
_9 = Option::<u32>::None;
6376
goto -> bb5;
6477
}
6578

6679
bb3: {
67-
_8 = _4;
68-
StorageLive(_9);
69-
_9 = <u32 as Step>::forward_unchecked(_8, const 1_usize) -> [return: bb4, unwind unreachable];
80+
_10 = (_5.0: u32);
81+
StorageLive(_11);
82+
_11 = <u32 as Step>::forward_unchecked(_10, const 1_usize) -> [return: bb4, unwind unreachable];
7083
}
7184

7285
bb4: {
73-
_4 = move _9;
74-
StorageDead(_9);
75-
_7 = Option::<u32>::Some(_8);
86+
(_5.0: u32) = move _11;
87+
StorageDead(_11);
88+
_9 = Option::<u32>::Some(_10);
7689
goto -> bb5;
7790
}
7891

7992
bb5: {
80-
StorageDead(_6);
8193
StorageDead(_8);
82-
_10 = discriminant(_7);
83-
switchInt(move _10) -> [0: bb6, 1: bb8, otherwise: bb10];
94+
StorageDead(_10);
95+
_12 = discriminant(_9);
96+
switchInt(move _12) -> [0: bb6, 1: bb8, otherwise: bb10];
8497
}
8598

8699
bb6: {
87-
StorageDead(_7);
88-
StorageDead(_4);
100+
StorageDead(_9);
101+
StorageDead(_5);
89102
drop(_3) -> [return: bb7, unwind unreachable];
90103
}
91104

@@ -94,18 +107,18 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
94107
}
95108

96109
bb8: {
97-
_11 = ((_7 as Some).0: u32);
98-
StorageLive(_12);
99-
_12 = &_3;
100-
StorageLive(_13);
101-
_13 = (_11,);
102-
_14 = <impl Fn(u32) as Fn<(u32,)>>::call(move _12, move _13) -> [return: bb9, unwind unreachable];
110+
_13 = ((_9 as Some).0: u32);
111+
StorageLive(_14);
112+
_14 = &_3;
113+
StorageLive(_15);
114+
_15 = (_13,);
115+
_16 = <impl Fn(u32) as Fn<(u32,)>>::call(move _14, move _15) -> [return: bb9, unwind unreachable];
103116
}
104117

105118
bb9: {
106-
StorageDead(_13);
107-
StorageDead(_12);
108-
StorageDead(_7);
119+
StorageDead(_15);
120+
StorageDead(_14);
121+
StorageDead(_9);
109122
goto -> bb1;
110123
}
111124

‎tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,87 +5,100 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
55
debug end => _2;
66
debug f => _3;
77
let mut _0: ();
8-
let mut _4: u32;
9-
let mut _7: std::option::Option<u32>;
10-
let mut _10: isize;
11-
let mut _12: &impl Fn(u32);
12-
let mut _13: (u32,);
13-
let _14: ();
8+
let mut _4: std::ops::Range<u32>;
9+
let mut _5: std::ops::Range<u32>;
10+
let mut _9: std::option::Option<u32>;
11+
let mut _12: isize;
12+
let mut _14: &impl Fn(u32);
13+
let mut _15: (u32,);
14+
let _16: ();
15+
let mut _17: &mut std::ops::Range<u32>;
1416
scope 1 {
15-
debug iter => std::ops::Range<u32>{ .0 => _4, .1 => _2, };
16-
let _11: u32;
17+
debug iter => _5;
18+
let _13: u32;
1719
scope 2 {
18-
debug x => _11;
20+
debug x => _13;
1921
}
2022
scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
21-
debug self => &std::ops::Range<u32>{ .0 => _4, .1 => _2, };
23+
debug self => _17;
2224
scope 5 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) {
23-
debug self => &std::ops::Range<u32>{ .0 => _4, .1 => _2, };
24-
let mut _6: bool;
25-
let _8: u32;
26-
let mut _9: u32;
25+
debug self => _17;
26+
let mut _8: bool;
27+
let _10: u32;
28+
let mut _11: u32;
29+
let mut _18: &u32;
30+
let mut _19: &u32;
2731
scope 6 {
28-
debug old => _8;
32+
debug old => _10;
2933
scope 7 {
3034
}
3135
}
3236
scope 8 (inlined cmp::impls::<impl PartialOrd for u32>::lt) {
33-
debug self => &_4;
34-
debug other => &_2;
35-
let mut _5: u32;
37+
debug self => _18;
38+
debug other => _19;
39+
let mut _6: u32;
40+
let mut _7: u32;
3641
}
3742
}
3843
}
3944
}
4045
scope 3 (inlined <std::ops::Range<u32> as IntoIterator>::into_iter) {
41-
debug self => std::ops::Range<u32>{ .0 => _1, .1 => _2, };
46+
debug self => _4;
4247
}
4348

4449
bb0: {
45-
StorageLive(_4);
46-
_4 = _1;
50+
_4 = std::ops::Range::<u32> { start: _1, end: _2 };
51+
StorageLive(_5);
52+
_5 = move _4;
4753
goto -> bb1;
4854
}
4955

5056
bb1: {
51-
StorageLive(_7);
57+
StorageLive(_9);
58+
StorageLive(_10);
5259
StorageLive(_8);
60+
StorageLive(_18);
61+
StorageLive(_19);
5362
StorageLive(_6);
54-
StorageLive(_5);
55-
_5 = _4;
56-
_6 = Lt(move _5, _2);
57-
StorageDead(_5);
58-
switchInt(move _6) -> [0: bb2, otherwise: bb3];
63+
_6 = (_5.0: u32);
64+
StorageLive(_7);
65+
_7 = (_5.1: u32);
66+
_8 = Lt(move _6, move _7);
67+
StorageDead(_7);
68+
StorageDead(_6);
69+
StorageDead(_19);
70+
StorageDead(_18);
71+
switchInt(move _8) -> [0: bb2, otherwise: bb3];
5972
}
6073

6174
bb2: {
62-
_7 = Option::<u32>::None;
75+
_9 = Option::<u32>::None;
6376
goto -> bb5;
6477
}
6578

6679
bb3: {
67-
_8 = _4;
68-
StorageLive(_9);
69-
_9 = <u32 as Step>::forward_unchecked(_8, const 1_usize) -> [return: bb4, unwind: bb11];
80+
_10 = (_5.0: u32);
81+
StorageLive(_11);
82+
_11 = <u32 as Step>::forward_unchecked(_10, const 1_usize) -> [return: bb4, unwind: bb11];
7083
}
7184

7285
bb4: {
73-
_4 = move _9;
74-
StorageDead(_9);
75-
_7 = Option::<u32>::Some(_8);
86+
(_5.0: u32) = move _11;
87+
StorageDead(_11);
88+
_9 = Option::<u32>::Some(_10);
7689
goto -> bb5;
7790
}
7891

7992
bb5: {
80-
StorageDead(_6);
8193
StorageDead(_8);
82-
_10 = discriminant(_7);
83-
switchInt(move _10) -> [0: bb6, 1: bb8, otherwise: bb10];
94+
StorageDead(_10);
95+
_12 = discriminant(_9);
96+
switchInt(move _12) -> [0: bb6, 1: bb8, otherwise: bb10];
8497
}
8598

8699
bb6: {
87-
StorageDead(_7);
88-
StorageDead(_4);
100+
StorageDead(_9);
101+
StorageDead(_5);
89102
drop(_3) -> [return: bb7, unwind continue];
90103
}
91104

@@ -94,18 +107,18 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
94107
}
95108

96109
bb8: {
97-
_11 = ((_7 as Some).0: u32);
98-
StorageLive(_12);
99-
_12 = &_3;
100-
StorageLive(_13);
101-
_13 = (_11,);
102-
_14 = <impl Fn(u32) as Fn<(u32,)>>::call(move _12, move _13) -> [return: bb9, unwind: bb11];
110+
_13 = ((_9 as Some).0: u32);
111+
StorageLive(_14);
112+
_14 = &_3;
113+
StorageLive(_15);
114+
_15 = (_13,);
115+
_16 = <impl Fn(u32) as Fn<(u32,)>>::call(move _14, move _15) -> [return: bb9, unwind: bb11];
103116
}
104117

105118
bb9: {
106-
StorageDead(_13);
107-
StorageDead(_12);
108-
StorageDead(_7);
119+
StorageDead(_15);
120+
StorageDead(_14);
121+
StorageDead(_9);
109122
goto -> bb1;
110123
}
111124

‎tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> {
1010
let mut _4: bool;
1111
let _5: u32;
1212
let mut _6: u32;
13+
let mut _7: &u32;
14+
let mut _8: &u32;
1315
scope 3 {
1416
debug old => _5;
1517
scope 4 {
1618
}
1719
}
1820
scope 5 (inlined cmp::impls::<impl PartialOrd for u32>::lt) {
19-
debug self => &((*_1).0: u32);
20-
debug other => &((*_1).1: u32);
21+
debug self => _7;
22+
debug other => _8;
2123
let mut _2: u32;
2224
let mut _3: u32;
2325
}
@@ -27,13 +29,17 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> {
2729
bb0: {
2830
StorageLive(_5);
2931
StorageLive(_4);
32+
StorageLive(_7);
33+
StorageLive(_8);
3034
StorageLive(_2);
3135
_2 = ((*_1).0: u32);
3236
StorageLive(_3);
3337
_3 = ((*_1).1: u32);
3438
_4 = Lt(move _2, move _3);
3539
StorageDead(_3);
3640
StorageDead(_2);
41+
StorageDead(_8);
42+
StorageDead(_7);
3743
switchInt(move _4) -> [0: bb1, otherwise: bb2];
3844
}
3945

‎tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> {
1010
let mut _4: bool;
1111
let _5: u32;
1212
let mut _6: u32;
13+
let mut _7: &u32;
14+
let mut _8: &u32;
1315
scope 3 {
1416
debug old => _5;
1517
scope 4 {
1618
}
1719
}
1820
scope 5 (inlined cmp::impls::<impl PartialOrd for u32>::lt) {
19-
debug self => &((*_1).0: u32);
20-
debug other => &((*_1).1: u32);
21+
debug self => _7;
22+
debug other => _8;
2123
let mut _2: u32;
2224
let mut _3: u32;
2325
}
@@ -27,13 +29,17 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> {
2729
bb0: {
2830
StorageLive(_5);
2931
StorageLive(_4);
32+
StorageLive(_7);
33+
StorageLive(_8);
3034
StorageLive(_2);
3135
_2 = ((*_1).0: u32);
3236
StorageLive(_3);
3337
_3 = ((*_1).1: u32);
3438
_4 = Lt(move _2, move _3);
3539
StorageDead(_3);
3640
StorageDead(_2);
41+
StorageDead(_8);
42+
StorageDead(_7);
3743
switchInt(move _4) -> [0: bb1, otherwise: bb2];
3844
}
3945

‎tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir

Lines changed: 153 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,138 +3,206 @@
33
fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2: &&(usize, usize, usize, usize)) -> bool {
44
let mut _0: bool;
55
let mut _3: &(usize, usize, usize, usize);
6-
let mut _4: &(usize, usize, usize, usize);
6+
let _4: &usize;
77
let mut _5: &(usize, usize, usize, usize);
8-
let mut _6: &(usize, usize, usize, usize);
9-
let mut _9: bool;
10-
let mut _10: bool;
11-
let mut _13: bool;
8+
let _6: &usize;
9+
let mut _7: &(usize, usize, usize, usize);
10+
let _8: &usize;
11+
let mut _9: &(usize, usize, usize, usize);
12+
let _10: &usize;
13+
let _11: &usize;
1214
let mut _16: bool;
1315
let mut _17: bool;
14-
let mut _20: bool;
16+
let _18: &usize;
17+
let mut _23: bool;
18+
let _24: &usize;
19+
let mut _29: bool;
20+
let mut _30: bool;
21+
let _31: &usize;
22+
let mut _36: bool;
23+
let mut _37: &&usize;
24+
let mut _38: &&usize;
25+
let mut _39: &&usize;
26+
let mut _40: &&usize;
27+
let mut _41: &&usize;
28+
let mut _42: &&usize;
29+
let mut _43: &&usize;
30+
let mut _44: &&usize;
1531
scope 1 {
16-
debug a => &((*_3).0: usize);
17-
debug b => &((*_4).1: usize);
18-
debug c => &((*_5).2: usize);
19-
debug d => &((*_6).3: usize);
32+
debug a => _4;
33+
debug b => _6;
34+
debug c => _8;
35+
debug d => _10;
2036
scope 2 (inlined cmp::impls::<impl PartialOrd for &usize>::le) {
21-
debug self => &&((*_3).0: usize);
22-
debug other => &&((*_5).2: usize);
37+
debug self => _37;
38+
debug other => _38;
39+
let mut _12: &usize;
40+
let mut _13: &usize;
2341
scope 3 (inlined cmp::impls::<impl PartialOrd for usize>::le) {
24-
debug self => &((*_3).0: usize);
25-
debug other => &((*_5).2: usize);
26-
let mut _7: usize;
27-
let mut _8: usize;
42+
debug self => _12;
43+
debug other => _13;
44+
let mut _14: usize;
45+
let mut _15: usize;
2846
}
2947
}
3048
scope 4 (inlined cmp::impls::<impl PartialOrd for &usize>::le) {
31-
debug self => &&((*_5).2: usize);
32-
debug other => &&((*_3).0: usize);
49+
debug self => _41;
50+
debug other => _42;
51+
let mut _25: &usize;
52+
let mut _26: &usize;
3353
scope 5 (inlined cmp::impls::<impl PartialOrd for usize>::le) {
34-
debug self => &((*_5).2: usize);
35-
debug other => &((*_3).0: usize);
36-
let mut _14: usize;
37-
let mut _15: usize;
54+
debug self => _25;
55+
debug other => _26;
56+
let mut _27: usize;
57+
let mut _28: usize;
3858
}
3959
}
4060
scope 6 (inlined cmp::impls::<impl PartialOrd for &usize>::le) {
41-
debug self => &&((*_6).3: usize);
42-
debug other => &&((*_4).1: usize);
61+
debug self => _39;
62+
debug other => _40;
63+
let mut _19: &usize;
64+
let mut _20: &usize;
4365
scope 7 (inlined cmp::impls::<impl PartialOrd for usize>::le) {
44-
debug self => &((*_6).3: usize);
45-
debug other => &((*_4).1: usize);
46-
let mut _11: usize;
47-
let mut _12: usize;
66+
debug self => _19;
67+
debug other => _20;
68+
let mut _21: usize;
69+
let mut _22: usize;
4870
}
4971
}
5072
scope 8 (inlined cmp::impls::<impl PartialOrd for &usize>::le) {
51-
debug self => &&((*_4).1: usize);
52-
debug other => &&((*_6).3: usize);
73+
debug self => _43;
74+
debug other => _44;
75+
let mut _32: &usize;
76+
let mut _33: &usize;
5377
scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::le) {
54-
debug self => &((*_4).1: usize);
55-
debug other => &((*_6).3: usize);
56-
let mut _18: usize;
57-
let mut _19: usize;
78+
debug self => _32;
79+
debug other => _33;
80+
let mut _34: usize;
81+
let mut _35: usize;
5882
}
5983
}
6084
}
6185

6286
bb0: {
87+
StorageLive(_4);
6388
_3 = deref_copy (*_2);
64-
_4 = deref_copy (*_2);
89+
_4 = &((*_3).0: usize);
90+
StorageLive(_6);
6591
_5 = deref_copy (*_2);
66-
_6 = deref_copy (*_2);
67-
StorageLive(_10);
68-
StorageLive(_9);
69-
StorageLive(_7);
70-
_7 = ((*_3).0: usize);
92+
_6 = &((*_5).1: usize);
7193
StorageLive(_8);
72-
_8 = ((*_5).2: usize);
73-
_9 = Le(move _7, move _8);
74-
StorageDead(_8);
75-
StorageDead(_7);
76-
switchInt(move _9) -> [0: bb1, otherwise: bb2];
94+
_7 = deref_copy (*_2);
95+
_8 = &((*_7).2: usize);
96+
StorageLive(_10);
97+
_9 = deref_copy (*_2);
98+
_10 = &((*_9).3: usize);
99+
StorageLive(_17);
100+
StorageLive(_16);
101+
StorageLive(_37);
102+
StorageLive(_38);
103+
StorageLive(_11);
104+
_11 = _8;
105+
_12 = deref_copy _4;
106+
_13 = deref_copy _11;
107+
StorageLive(_14);
108+
_14 = (*_12);
109+
StorageLive(_15);
110+
_15 = (*_13);
111+
_16 = Le(move _14, move _15);
112+
StorageDead(_15);
113+
StorageDead(_14);
114+
StorageDead(_11);
115+
StorageDead(_38);
116+
StorageDead(_37);
117+
switchInt(move _16) -> [0: bb1, otherwise: bb2];
77118
}
78119

79120
bb1: {
80-
_10 = const false;
121+
_17 = const false;
81122
goto -> bb3;
82123
}
83124

84125
bb2: {
85-
StorageLive(_13);
86-
StorageLive(_11);
87-
_11 = ((*_6).3: usize);
88-
StorageLive(_12);
89-
_12 = ((*_4).1: usize);
90-
_13 = Le(move _11, move _12);
91-
StorageDead(_12);
92-
StorageDead(_11);
93-
_10 = move _13;
126+
StorageLive(_23);
127+
StorageLive(_39);
128+
StorageLive(_40);
129+
StorageLive(_18);
130+
_18 = _6;
131+
_19 = deref_copy _10;
132+
_20 = deref_copy _18;
133+
StorageLive(_21);
134+
_21 = (*_19);
135+
StorageLive(_22);
136+
_22 = (*_20);
137+
_23 = Le(move _21, move _22);
138+
StorageDead(_22);
139+
StorageDead(_21);
140+
StorageDead(_18);
141+
StorageDead(_40);
142+
StorageDead(_39);
143+
_17 = move _23;
94144
goto -> bb3;
95145
}
96146

97147
bb3: {
98-
StorageDead(_13);
99-
StorageDead(_9);
100-
switchInt(move _10) -> [0: bb4, otherwise: bb8];
148+
StorageDead(_23);
149+
StorageDead(_16);
150+
switchInt(move _17) -> [0: bb4, otherwise: bb8];
101151
}
102152

103153
bb4: {
104-
StorageLive(_17);
105-
StorageLive(_16);
106-
StorageLive(_14);
107-
_14 = ((*_5).2: usize);
108-
StorageLive(_15);
109-
_15 = ((*_3).0: usize);
110-
_16 = Le(move _14, move _15);
111-
StorageDead(_15);
112-
StorageDead(_14);
113-
switchInt(move _16) -> [0: bb5, otherwise: bb6];
154+
StorageLive(_30);
155+
StorageLive(_29);
156+
StorageLive(_41);
157+
StorageLive(_42);
158+
StorageLive(_24);
159+
_24 = _4;
160+
_25 = deref_copy _8;
161+
_26 = deref_copy _24;
162+
StorageLive(_27);
163+
_27 = (*_25);
164+
StorageLive(_28);
165+
_28 = (*_26);
166+
_29 = Le(move _27, move _28);
167+
StorageDead(_28);
168+
StorageDead(_27);
169+
StorageDead(_24);
170+
StorageDead(_42);
171+
StorageDead(_41);
172+
switchInt(move _29) -> [0: bb5, otherwise: bb6];
114173
}
115174

116175
bb5: {
117-
_17 = const false;
176+
_30 = const false;
118177
goto -> bb7;
119178
}
120179

121180
bb6: {
122-
StorageLive(_20);
123-
StorageLive(_18);
124-
_18 = ((*_4).1: usize);
125-
StorageLive(_19);
126-
_19 = ((*_6).3: usize);
127-
_20 = Le(move _18, move _19);
128-
StorageDead(_19);
129-
StorageDead(_18);
130-
_17 = move _20;
181+
StorageLive(_36);
182+
StorageLive(_43);
183+
StorageLive(_44);
184+
StorageLive(_31);
185+
_31 = _10;
186+
_32 = deref_copy _6;
187+
_33 = deref_copy _31;
188+
StorageLive(_34);
189+
_34 = (*_32);
190+
StorageLive(_35);
191+
_35 = (*_33);
192+
_36 = Le(move _34, move _35);
193+
StorageDead(_35);
194+
StorageDead(_34);
195+
StorageDead(_31);
196+
StorageDead(_44);
197+
StorageDead(_43);
198+
_30 = move _36;
131199
goto -> bb7;
132200
}
133201

134202
bb7: {
135-
StorageDead(_20);
136-
StorageDead(_16);
137-
_0 = move _17;
203+
StorageDead(_36);
204+
StorageDead(_29);
205+
_0 = move _30;
138206
goto -> bb9;
139207
}
140208

@@ -144,8 +212,12 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2
144212
}
145213

146214
bb9: {
215+
StorageDead(_30);
147216
StorageDead(_17);
148217
StorageDead(_10);
218+
StorageDead(_8);
219+
StorageDead(_6);
220+
StorageDead(_4);
149221
return;
150222
}
151223
}

‎tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir

Lines changed: 71 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,95 +5,109 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
55
debug f => _2;
66
let mut _0: ();
77
let mut _3: usize;
8-
let mut _4: usize;
9-
let mut _7: std::option::Option<usize>;
10-
let mut _10: isize;
11-
let mut _12: usize;
12-
let mut _13: bool;
13-
let mut _15: &impl Fn(usize, &T);
14-
let mut _16: (usize, &T);
15-
let _17: ();
16-
let mut _18: usize;
8+
let mut _4: std::ops::Range<usize>;
9+
let mut _5: std::ops::Range<usize>;
10+
let mut _9: std::option::Option<usize>;
11+
let mut _12: isize;
12+
let mut _14: usize;
13+
let mut _15: bool;
14+
let mut _17: &impl Fn(usize, &T);
15+
let mut _18: (usize, &T);
16+
let _19: ();
17+
let mut _20: &mut std::ops::Range<usize>;
1718
scope 1 {
18-
debug iter => std::ops::Range<usize>{ .0 => _4, .1 => _3, };
19-
let _11: usize;
19+
debug iter => _5;
20+
let _13: usize;
2021
scope 2 {
21-
debug i => _11;
22-
let _14: &T;
22+
debug i => _13;
23+
let _16: &T;
2324
scope 3 {
24-
debug x => _14;
25+
debug x => _16;
2526
}
2627
}
2728
scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
28-
debug self => &std::ops::Range<usize>{ .0 => _4, .1 => _3, };
29+
debug self => _20;
2930
scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
30-
debug self => &std::ops::Range<usize>{ .0 => _4, .1 => _3, };
31-
let mut _6: bool;
32-
let _8: usize;
33-
let mut _9: usize;
31+
debug self => _20;
32+
let mut _8: bool;
33+
let _10: usize;
34+
let mut _11: usize;
35+
let mut _21: &usize;
36+
let mut _22: &usize;
3437
scope 7 {
35-
debug old => _8;
38+
debug old => _10;
3639
scope 8 {
3740
}
3841
}
3942
scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::lt) {
40-
debug self => &_4;
41-
debug other => &_3;
42-
let mut _5: usize;
43+
debug self => _21;
44+
debug other => _22;
45+
let mut _6: usize;
46+
let mut _7: usize;
4347
}
4448
}
4549
}
4650
}
4751
scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) {
48-
debug self => std::ops::Range<usize>{ .0 => _18, .1 => _3, };
52+
debug self => _4;
4953
}
5054

5155
bb0: {
56+
StorageLive(_3);
5257
_3 = Len((*_1));
53-
StorageLive(_4);
54-
_4 = const 0_usize;
58+
_4 = std::ops::Range::<usize> { start: const 0_usize, end: move _3 };
59+
StorageDead(_3);
60+
StorageLive(_5);
61+
_5 = move _4;
5562
goto -> bb1;
5663
}
5764

5865
bb1: {
59-
StorageLive(_7);
66+
StorageLive(_9);
67+
StorageLive(_10);
6068
StorageLive(_8);
69+
StorageLive(_21);
70+
StorageLive(_22);
6171
StorageLive(_6);
62-
StorageLive(_5);
63-
_5 = _4;
64-
_6 = Lt(move _5, _3);
65-
StorageDead(_5);
66-
switchInt(move _6) -> [0: bb2, otherwise: bb3];
72+
_6 = (_5.0: usize);
73+
StorageLive(_7);
74+
_7 = (_5.1: usize);
75+
_8 = Lt(move _6, move _7);
76+
StorageDead(_7);
77+
StorageDead(_6);
78+
StorageDead(_22);
79+
StorageDead(_21);
80+
switchInt(move _8) -> [0: bb2, otherwise: bb3];
6781
}
6882

6983
bb2: {
70-
_7 = Option::<usize>::None;
84+
_9 = Option::<usize>::None;
7185
goto -> bb5;
7286
}
7387

7488
bb3: {
75-
_8 = _4;
76-
StorageLive(_9);
77-
_9 = <usize as Step>::forward_unchecked(_8, const 1_usize) -> [return: bb4, unwind unreachable];
89+
_10 = (_5.0: usize);
90+
StorageLive(_11);
91+
_11 = <usize as Step>::forward_unchecked(_10, const 1_usize) -> [return: bb4, unwind unreachable];
7892
}
7993

8094
bb4: {
81-
_4 = move _9;
82-
StorageDead(_9);
83-
_7 = Option::<usize>::Some(_8);
95+
(_5.0: usize) = move _11;
96+
StorageDead(_11);
97+
_9 = Option::<usize>::Some(_10);
8498
goto -> bb5;
8599
}
86100

87101
bb5: {
88-
StorageDead(_6);
89102
StorageDead(_8);
90-
_10 = discriminant(_7);
91-
switchInt(move _10) -> [0: bb6, 1: bb8, otherwise: bb11];
103+
StorageDead(_10);
104+
_12 = discriminant(_9);
105+
switchInt(move _12) -> [0: bb6, 1: bb8, otherwise: bb11];
92106
}
93107

94108
bb6: {
95-
StorageDead(_7);
96-
StorageDead(_4);
109+
StorageDead(_9);
110+
StorageDead(_5);
97111
drop(_2) -> [return: bb7, unwind unreachable];
98112
}
99113

@@ -102,25 +116,25 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
102116
}
103117

104118
bb8: {
105-
_11 = ((_7 as Some).0: usize);
106-
_12 = Len((*_1));
107-
_13 = Lt(_11, _12);
108-
assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb9, unwind unreachable];
119+
_13 = ((_9 as Some).0: usize);
120+
_14 = Len((*_1));
121+
_15 = Lt(_13, _14);
122+
assert(move _15, "index out of bounds: the length is {} but the index is {}", move _14, _13) -> [success: bb9, unwind unreachable];
109123
}
110124

111125
bb9: {
112-
_14 = &(*_1)[_11];
113-
StorageLive(_15);
114-
_15 = &_2;
115-
StorageLive(_16);
116-
_16 = (_11, _14);
117-
_17 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _15, move _16) -> [return: bb10, unwind unreachable];
126+
_16 = &(*_1)[_13];
127+
StorageLive(_17);
128+
_17 = &_2;
129+
StorageLive(_18);
130+
_18 = (_13, _16);
131+
_19 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _17, move _18) -> [return: bb10, unwind unreachable];
118132
}
119133

120134
bb10: {
121-
StorageDead(_16);
122-
StorageDead(_15);
123-
StorageDead(_7);
135+
StorageDead(_18);
136+
StorageDead(_17);
137+
StorageDead(_9);
124138
goto -> bb1;
125139
}
126140

‎tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir

Lines changed: 71 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,95 +5,109 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
55
debug f => _2;
66
let mut _0: ();
77
let mut _3: usize;
8-
let mut _4: usize;
9-
let mut _7: std::option::Option<usize>;
10-
let mut _10: isize;
11-
let mut _12: usize;
12-
let mut _13: bool;
13-
let mut _15: &impl Fn(usize, &T);
14-
let mut _16: (usize, &T);
15-
let _17: ();
16-
let mut _18: usize;
8+
let mut _4: std::ops::Range<usize>;
9+
let mut _5: std::ops::Range<usize>;
10+
let mut _9: std::option::Option<usize>;
11+
let mut _12: isize;
12+
let mut _14: usize;
13+
let mut _15: bool;
14+
let mut _17: &impl Fn(usize, &T);
15+
let mut _18: (usize, &T);
16+
let _19: ();
17+
let mut _20: &mut std::ops::Range<usize>;
1718
scope 1 {
18-
debug iter => std::ops::Range<usize>{ .0 => _4, .1 => _3, };
19-
let _11: usize;
19+
debug iter => _5;
20+
let _13: usize;
2021
scope 2 {
21-
debug i => _11;
22-
let _14: &T;
22+
debug i => _13;
23+
let _16: &T;
2324
scope 3 {
24-
debug x => _14;
25+
debug x => _16;
2526
}
2627
}
2728
scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
28-
debug self => &std::ops::Range<usize>{ .0 => _4, .1 => _3, };
29+
debug self => _20;
2930
scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
30-
debug self => &std::ops::Range<usize>{ .0 => _4, .1 => _3, };
31-
let mut _6: bool;
32-
let _8: usize;
33-
let mut _9: usize;
31+
debug self => _20;
32+
let mut _8: bool;
33+
let _10: usize;
34+
let mut _11: usize;
35+
let mut _21: &usize;
36+
let mut _22: &usize;
3437
scope 7 {
35-
debug old => _8;
38+
debug old => _10;
3639
scope 8 {
3740
}
3841
}
3942
scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::lt) {
40-
debug self => &_4;
41-
debug other => &_3;
42-
let mut _5: usize;
43+
debug self => _21;
44+
debug other => _22;
45+
let mut _6: usize;
46+
let mut _7: usize;
4347
}
4448
}
4549
}
4650
}
4751
scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) {
48-
debug self => std::ops::Range<usize>{ .0 => _18, .1 => _3, };
52+
debug self => _4;
4953
}
5054

5155
bb0: {
56+
StorageLive(_3);
5257
_3 = Len((*_1));
53-
StorageLive(_4);
54-
_4 = const 0_usize;
58+
_4 = std::ops::Range::<usize> { start: const 0_usize, end: move _3 };
59+
StorageDead(_3);
60+
StorageLive(_5);
61+
_5 = move _4;
5562
goto -> bb1;
5663
}
5764

5865
bb1: {
59-
StorageLive(_7);
66+
StorageLive(_9);
67+
StorageLive(_10);
6068
StorageLive(_8);
69+
StorageLive(_21);
70+
StorageLive(_22);
6171
StorageLive(_6);
62-
StorageLive(_5);
63-
_5 = _4;
64-
_6 = Lt(move _5, _3);
65-
StorageDead(_5);
66-
switchInt(move _6) -> [0: bb2, otherwise: bb3];
72+
_6 = (_5.0: usize);
73+
StorageLive(_7);
74+
_7 = (_5.1: usize);
75+
_8 = Lt(move _6, move _7);
76+
StorageDead(_7);
77+
StorageDead(_6);
78+
StorageDead(_22);
79+
StorageDead(_21);
80+
switchInt(move _8) -> [0: bb2, otherwise: bb3];
6781
}
6882

6983
bb2: {
70-
_7 = Option::<usize>::None;
84+
_9 = Option::<usize>::None;
7185
goto -> bb5;
7286
}
7387

7488
bb3: {
75-
_8 = _4;
76-
StorageLive(_9);
77-
_9 = <usize as Step>::forward_unchecked(_8, const 1_usize) -> [return: bb4, unwind: bb12];
89+
_10 = (_5.0: usize);
90+
StorageLive(_11);
91+
_11 = <usize as Step>::forward_unchecked(_10, const 1_usize) -> [return: bb4, unwind: bb12];
7892
}
7993

8094
bb4: {
81-
_4 = move _9;
82-
StorageDead(_9);
83-
_7 = Option::<usize>::Some(_8);
95+
(_5.0: usize) = move _11;
96+
StorageDead(_11);
97+
_9 = Option::<usize>::Some(_10);
8498
goto -> bb5;
8599
}
86100

87101
bb5: {
88-
StorageDead(_6);
89102
StorageDead(_8);
90-
_10 = discriminant(_7);
91-
switchInt(move _10) -> [0: bb6, 1: bb8, otherwise: bb11];
103+
StorageDead(_10);
104+
_12 = discriminant(_9);
105+
switchInt(move _12) -> [0: bb6, 1: bb8, otherwise: bb11];
92106
}
93107

94108
bb6: {
95-
StorageDead(_7);
96-
StorageDead(_4);
109+
StorageDead(_9);
110+
StorageDead(_5);
97111
drop(_2) -> [return: bb7, unwind continue];
98112
}
99113

@@ -102,25 +116,25 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
102116
}
103117

104118
bb8: {
105-
_11 = ((_7 as Some).0: usize);
106-
_12 = Len((*_1));
107-
_13 = Lt(_11, _12);
108-
assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb9, unwind: bb12];
119+
_13 = ((_9 as Some).0: usize);
120+
_14 = Len((*_1));
121+
_15 = Lt(_13, _14);
122+
assert(move _15, "index out of bounds: the length is {} but the index is {}", move _14, _13) -> [success: bb9, unwind: bb12];
109123
}
110124

111125
bb9: {
112-
_14 = &(*_1)[_11];
113-
StorageLive(_15);
114-
_15 = &_2;
115-
StorageLive(_16);
116-
_16 = (_11, _14);
117-
_17 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _15, move _16) -> [return: bb10, unwind: bb12];
126+
_16 = &(*_1)[_13];
127+
StorageLive(_17);
128+
_17 = &_2;
129+
StorageLive(_18);
130+
_18 = (_13, _16);
131+
_19 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _17, move _18) -> [return: bb10, unwind: bb12];
118132
}
119133

120134
bb10: {
121-
StorageDead(_16);
122-
StorageDead(_15);
123-
StorageDead(_7);
135+
StorageDead(_18);
136+
StorageDead(_17);
137+
StorageDead(_9);
124138
goto -> bb1;
125139
}
126140

‎tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
1212
let mut _20: &impl Fn(&T);
1313
let mut _21: (&T,);
1414
let _22: ();
15+
let mut _23: &mut std::iter::Rev<std::slice::Iter<'_, T>>;
1516
scope 1 {
1617
debug iter => _15;
1718
let _19: &T;
1819
scope 2 {
1920
debug x => _19;
2021
}
2122
scope 25 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
22-
debug self => &_15;
23+
debug self => _23;
2324
let mut _16: &mut std::slice::Iter<'_, T>;
2425
}
2526
}
@@ -48,15 +49,15 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
4849
debug ptr => _9;
4950
scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) {
5051
debug self => _9;
51-
let mut _23: *mut u8;
52+
let mut _24: *mut u8;
5253
scope 17 {
5354
scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
54-
debug ptr => _23;
55+
debug ptr => _24;
5556
scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
56-
debug self => _23;
57+
debug self => _24;
5758
scope 20 {
5859
scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
59-
debug self => _23;
60+
debug self => _24;
6061
}
6162
}
6263
}
@@ -131,10 +132,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
131132
StorageLive(_9);
132133
_9 = _4 as *mut T (PtrToPtr);
133134
StorageLive(_10);
134-
StorageLive(_23);
135+
StorageLive(_24);
135136
_10 = _9 as *const T (PointerCoercion(MutToConstPointer));
136137
_11 = NonNull::<T> { pointer: _10 };
137-
StorageDead(_23);
138+
StorageDead(_24);
138139
StorageDead(_10);
139140
StorageDead(_9);
140141
StorageLive(_12);

‎tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
1212
let mut _20: &impl Fn(&T);
1313
let mut _21: (&T,);
1414
let _22: ();
15+
let mut _23: &mut std::iter::Rev<std::slice::Iter<'_, T>>;
1516
scope 1 {
1617
debug iter => _15;
1718
let _19: &T;
1819
scope 2 {
1920
debug x => _19;
2021
}
2122
scope 25 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
22-
debug self => &_15;
23+
debug self => _23;
2324
let mut _16: &mut std::slice::Iter<'_, T>;
2425
}
2526
}
@@ -48,15 +49,15 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
4849
debug ptr => _9;
4950
scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) {
5051
debug self => _9;
51-
let mut _23: *mut u8;
52+
let mut _24: *mut u8;
5253
scope 17 {
5354
scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
54-
debug ptr => _23;
55+
debug ptr => _24;
5556
scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
56-
debug self => _23;
57+
debug self => _24;
5758
scope 20 {
5859
scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
59-
debug self => _23;
60+
debug self => _24;
6061
}
6162
}
6263
}
@@ -131,10 +132,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
131132
StorageLive(_9);
132133
_9 = _4 as *mut T (PtrToPtr);
133134
StorageLive(_10);
134-
StorageLive(_23);
135+
StorageLive(_24);
135136
_10 = _9 as *const T (PointerCoercion(MutToConstPointer));
136137
_11 = NonNull::<T> { pointer: _10 };
137-
StorageDead(_23);
138+
StorageDead(_24);
138139
StorageDead(_10);
139140
StorageDead(_9);
140141
StorageLive(_12);

‎tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,23 @@
2222
let _24: &mut u8;
2323
let mut _25: debuginfo::T;
2424
scope 1 {
25-
- debug ref_mut_u8 => _1;
26-
+ debug ref_mut_u8 => &_2;
25+
debug ref_mut_u8 => _1;
2726
let _3: &u8;
2827
let mut _28: &debuginfo::T;
2928
scope 2 {
30-
- debug field => _3;
31-
+ debug field => &((*_28).0: u8);
29+
debug field => _3;
3230
let _5: &u8;
3331
scope 3 {
3432
- debug reborrow => _5;
35-
+ debug reborrow => &_2;
33+
+ debug reborrow => _1;
3634
let _9: &i32;
3735
let _22: &&&mut u8;
3836
let mut _27: &std::option::Option<i32>;
3937
scope 4 {
40-
- debug variant_field => _9;
41-
+ debug variant_field => &(((*_27) as Some).0: i32);
38+
debug variant_field => _9;
4239
}
4340
scope 5 {
44-
- debug constant_index => _19;
45-
+ debug constant_index => &(*_11)[1 of 3];
41+
debug constant_index => _19;
4642
debug subslice => _20;
4743
debug constant_index_from_end => _21;
4844
let _19: &i32;
@@ -51,21 +47,20 @@
5147
let mut _26: &[i32; 10];
5248
}
5349
scope 6 {
54-
- debug multiple_borrow => _22;
55-
+ debug multiple_borrow => &&&(_25.0: u8);
50+
debug multiple_borrow => _22;
5651
}
5752
}
5853
}
5954
}
6055

6156
bb0: {
62-
- StorageLive(_1);
57+
StorageLive(_1);
6358
StorageLive(_2);
6459
_2 = const 5_u8;
65-
- _1 = &mut _2;
66-
- StorageLive(_3);
60+
_1 = &mut _2;
61+
StorageLive(_3);
6762
_28 = const _;
68-
- _3 = &((*_28).0: u8);
63+
_3 = &((*_28).0: u8);
6964
- StorageLive(_5);
7065
- _5 = &(*_1);
7166
- StorageLive(_6);
@@ -76,11 +71,11 @@
7671
}
7772

7873
bb1: {
79-
- StorageLive(_9);
74+
StorageLive(_9);
8075
_27 = const _;
81-
- _9 = &(((*_27) as Some).0: i32);
76+
_9 = &(((*_27) as Some).0: i32);
8277
- _6 = const ();
83-
- StorageDead(_9);
78+
StorageDead(_9);
8479
goto -> bb4;
8580
}
8681

@@ -118,16 +113,16 @@
118113
}
119114

120115
bb6: {
121-
- StorageLive(_19);
122-
- _19 = &(*_11)[1 of 3];
116+
StorageLive(_19);
117+
_19 = &(*_11)[1 of 3];
123118
StorageLive(_20);
124119
_20 = &(*_11)[2:-1];
125120
StorageLive(_21);
126121
_21 = &(*_11)[-1 of 3];
127122
- _10 = const ();
128123
StorageDead(_21);
129124
StorageDead(_20);
130-
- StorageDead(_19);
125+
StorageDead(_19);
131126
goto -> bb8;
132127
}
133128

@@ -140,23 +135,23 @@
140135
StorageDead(_12);
141136
StorageDead(_11);
142137
- StorageDead(_10);
143-
- StorageLive(_22);
144-
- StorageLive(_23);
145-
- StorageLive(_24);
138+
StorageLive(_22);
139+
StorageLive(_23);
140+
StorageLive(_24);
146141
StorageLive(_25);
147142
_25 = T(const 6_u8);
148-
- _24 = &mut (_25.0: u8);
149-
- _23 = &_24;
150-
- _22 = &_23;
143+
_24 = &mut (_25.0: u8);
144+
_23 = &_24;
145+
_22 = &_23;
151146
_0 = const ();
152147
StorageDead(_25);
153-
- StorageDead(_24);
154-
- StorageDead(_23);
155-
- StorageDead(_22);
148+
StorageDead(_24);
149+
StorageDead(_23);
150+
StorageDead(_22);
156151
- StorageDead(_5);
157-
- StorageDead(_3);
152+
StorageDead(_3);
158153
StorageDead(_2);
159-
- StorageDead(_1);
154+
StorageDead(_1);
160155
return;
161156
}
162157
}

‎tests/mir-opt/reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
debug x => _1;
1414
let _2: &mut i32;
1515
scope 2 {
16-
- debug xref => _2;
17-
+ debug xref => &_1;
16+
debug xref => _2;
1817
let _3: *mut i32;
1918
scope 3 {
2019
- debug xraw => _3;
21-
+ debug xraw => &_1;
20+
+ debug xraw => _2;
2221
let _6: &i32;
2322
scope 4 {
2423
- debug xshr => _6;
25-
+ debug xshr => &_1;
24+
+ debug xshr => _2;
2625
let _7: i32;
2726
scope 5 {
2827
debug a => _7;
@@ -38,7 +37,7 @@
3837
StorageLive(_1);
3938
_1 = const 2_i32;
4039
- StorageLive(_2);
41-
- _2 = &mut _1;
40+
_2 = &mut _1;
4241
- StorageLive(_3);
4342
- StorageLive(_4);
4443
- StorageLive(_5);

‎tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
debug a => _4;
5353
let _5: &usize;
5454
scope 2 {
55-
- debug b => _5;
56-
+ debug b => &_4;
55+
debug b => _5;
5756
let _6: usize;
5857
scope 3 {
5958
debug c => _6;
@@ -158,12 +157,10 @@
158157
debug a => _60;
159158
let _61: &usize;
160159
scope 30 {
161-
- debug b => _61;
162-
+ debug b => &_60;
160+
debug b => _61;
163161
let _62: &&usize;
164162
scope 31 {
165-
- debug d => _62;
166-
+ debug d => &&_60;
163+
debug d => _62;
167164
let _63: usize;
168165
scope 32 {
169166
debug c => _63;
@@ -175,12 +172,10 @@
175172
debug a => _66;
176173
let mut _67: &usize;
177174
scope 34 {
178-
- debug b => _67;
179-
+ debug b => &_66;
175+
debug b => _67;
180176
let _68: &mut &usize;
181177
scope 35 {
182-
- debug d => _68;
183-
+ debug d => &&_66;
178+
debug d => _68;
184179
let _69: usize;
185180
scope 36 {
186181
debug c => _69;
@@ -193,8 +188,8 @@
193188
- StorageLive(_3);
194189
StorageLive(_4);
195190
_4 = const 5_usize;
196-
- StorageLive(_5);
197-
- _5 = &_4;
191+
StorageLive(_5);
192+
_5 = &_4;
198193
StorageLive(_6);
199194
- _6 = (*_5);
200195
+ _6 = _4;
@@ -209,7 +204,7 @@
209204
StorageDead(_7);
210205
- _3 = const ();
211206
StorageDead(_6);
212-
- StorageDead(_5);
207+
StorageDead(_5);
213208
StorageDead(_4);
214209
- StorageDead(_3);
215210
- StorageLive(_9);
@@ -394,13 +389,12 @@
394389
- StorageLive(_59);
395390
StorageLive(_60);
396391
_60 = const 5_usize;
397-
- StorageLive(_61);
398-
- _61 = &_60;
399-
- StorageLive(_62);
400-
- _62 = &_61;
392+
StorageLive(_61);
393+
_61 = &_60;
394+
StorageLive(_62);
395+
_62 = &_61;
401396
StorageLive(_63);
402-
- _63 = (*_61);
403-
+ _63 = _60;
397+
_63 = (*_61);
404398
StorageLive(_64);
405399
StorageLive(_65);
406400
_65 = ();
@@ -412,19 +406,18 @@
412406
StorageDead(_64);
413407
- _59 = const ();
414408
StorageDead(_63);
415-
- StorageDead(_62);
416-
- StorageDead(_61);
409+
StorageDead(_62);
410+
StorageDead(_61);
417411
StorageDead(_60);
418412
- StorageDead(_59);
419413
StorageLive(_66);
420414
_66 = const 5_usize;
421-
- StorageLive(_67);
422-
- _67 = &_66;
423-
- StorageLive(_68);
424-
- _68 = &mut _67;
415+
StorageLive(_67);
416+
_67 = &_66;
417+
StorageLive(_68);
418+
_68 = &mut _67;
425419
StorageLive(_69);
426-
- _69 = (*_67);
427-
+ _69 = _66;
420+
_69 = (*_67);
428421
StorageLive(_70);
429422
StorageLive(_71);
430423
_71 = ();
@@ -436,8 +429,8 @@
436429
StorageDead(_70);
437430
_0 = const ();
438431
StorageDead(_69);
439-
- StorageDead(_68);
440-
- StorageDead(_67);
432+
StorageDead(_68);
433+
StorageDead(_67);
441434
StorageDead(_66);
442435
return;
443436
}

‎tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
debug a => _4;
4646
let _5: *const usize;
4747
scope 3 {
48-
- debug b => _5;
49-
+ debug b => &_4;
48+
debug b => _5;
5049
let _6: usize;
5150
scope 4 {
5251
debug c => _6;
@@ -175,12 +174,10 @@
175174
debug a => _58;
176175
let _59: *const usize;
177176
scope 39 {
178-
- debug b => _59;
179-
+ debug b => &_58;
177+
debug b => _59;
180178
let _60: *const usize;
181179
scope 40 {
182-
- debug c => _60;
183-
+ debug c => &_58;
180+
debug c => _60;
184181
let _61: usize;
185182
scope 41 {
186183
debug e => _61;
@@ -195,12 +192,10 @@
195192
debug a => _65;
196193
let _66: *const usize;
197194
scope 44 {
198-
- debug b => _66;
199-
+ debug b => &_65;
195+
debug b => _66;
200196
let _67: &*const usize;
201197
scope 45 {
202-
- debug d => _67;
203-
+ debug d => &&_65;
198+
debug d => _67;
204199
let _68: usize;
205200
scope 46 {
206201
debug c => _68;
@@ -215,12 +210,10 @@
215210
debug a => _71;
216211
let mut _72: *const usize;
217212
scope 49 {
218-
- debug b => _72;
219-
+ debug b => &_71;
213+
debug b => _72;
220214
let _73: &mut *const usize;
221215
scope 50 {
222-
- debug d => _73;
223-
+ debug d => &&_71;
216+
debug d => _73;
224217
let _74: usize;
225218
scope 51 {
226219
debug c => _74;
@@ -234,8 +227,8 @@
234227
- StorageLive(_3);
235228
StorageLive(_4);
236229
_4 = const 5_usize;
237-
- StorageLive(_5);
238-
- _5 = &raw const _4;
230+
StorageLive(_5);
231+
_5 = &raw const _4;
239232
StorageLive(_6);
240233
- _6 = (*_5);
241234
+ _6 = _4;
@@ -250,7 +243,7 @@
250243
StorageDead(_7);
251244
- _3 = const ();
252245
StorageDead(_6);
253-
- StorageDead(_5);
246+
StorageDead(_5);
254247
StorageDead(_4);
255248
- StorageDead(_3);
256249
- StorageLive(_9);
@@ -427,10 +420,11 @@
427420
- StorageLive(_57);
428421
StorageLive(_58);
429422
_58 = const 13_usize;
430-
- StorageLive(_59);
431-
- _59 = &raw const _58;
432-
- StorageLive(_60);
423+
StorageLive(_59);
424+
_59 = &raw const _58;
425+
StorageLive(_60);
433426
- _60 = &raw const (*_59);
427+
+ _60 = &raw const _58;
434428
StorageLive(_61);
435429
- _61 = (*_60);
436430
+ _61 = _58;
@@ -445,20 +439,19 @@
445439
StorageDead(_62);
446440
- _57 = const ();
447441
StorageDead(_61);
448-
- StorageDead(_60);
449-
- StorageDead(_59);
442+
StorageDead(_60);
443+
StorageDead(_59);
450444
StorageDead(_58);
451445
- StorageDead(_57);
452446
- StorageLive(_64);
453447
StorageLive(_65);
454448
_65 = const 5_usize;
455-
- StorageLive(_66);
456-
- _66 = &raw const _65;
457-
- StorageLive(_67);
458-
- _67 = &_66;
449+
StorageLive(_66);
450+
_66 = &raw const _65;
451+
StorageLive(_67);
452+
_67 = &_66;
459453
StorageLive(_68);
460-
- _68 = (*_66);
461-
+ _68 = _65;
454+
_68 = (*_66);
462455
StorageLive(_69);
463456
StorageLive(_70);
464457
_70 = ();
@@ -470,19 +463,18 @@
470463
StorageDead(_69);
471464
- _64 = const ();
472465
StorageDead(_68);
473-
- StorageDead(_67);
474-
- StorageDead(_66);
466+
StorageDead(_67);
467+
StorageDead(_66);
475468
StorageDead(_65);
476469
- StorageDead(_64);
477470
StorageLive(_71);
478471
_71 = const 5_usize;
479-
- StorageLive(_72);
480-
- _72 = &raw const _71;
481-
- StorageLive(_73);
482-
- _73 = &mut _72;
472+
StorageLive(_72);
473+
_72 = &raw const _71;
474+
StorageLive(_73);
475+
_73 = &mut _72;
483476
StorageLive(_74);
484-
- _74 = (*_72);
485-
+ _74 = _71;
477+
_74 = (*_72);
486478
StorageLive(_75);
487479
StorageLive(_76);
488480
_76 = ();
@@ -494,8 +486,8 @@
494486
StorageDead(_75);
495487
_0 = const ();
496488
StorageDead(_74);
497-
- StorageDead(_73);
498-
- StorageDead(_72);
489+
StorageDead(_73);
490+
StorageDead(_72);
499491
StorageDead(_71);
500492
return;
501493
}

‎tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
debug a => _4;
5353
let _5: &mut usize;
5454
scope 2 {
55-
- debug b => _5;
56-
+ debug b => &_4;
55+
debug b => _5;
5756
let _6: usize;
5857
scope 3 {
5958
debug c => _6;
@@ -158,12 +157,10 @@
158157
debug a => _60;
159158
let _61: &mut usize;
160159
scope 30 {
161-
- debug b => _61;
162-
+ debug b => &_60;
160+
debug b => _61;
163161
let _62: &&mut usize;
164162
scope 31 {
165-
- debug d => _62;
166-
+ debug d => &&_60;
163+
debug d => _62;
167164
let _63: usize;
168165
scope 32 {
169166
debug c => _63;
@@ -175,12 +172,10 @@
175172
debug a => _66;
176173
let mut _67: &mut usize;
177174
scope 34 {
178-
- debug b => _67;
179-
+ debug b => &_66;
175+
debug b => _67;
180176
let _68: &mut &mut usize;
181177
scope 35 {
182-
- debug d => _68;
183-
+ debug d => &&_66;
178+
debug d => _68;
184179
let _69: usize;
185180
scope 36 {
186181
debug c => _69;
@@ -193,8 +188,8 @@
193188
- StorageLive(_3);
194189
StorageLive(_4);
195190
_4 = const 5_usize;
196-
- StorageLive(_5);
197-
- _5 = &mut _4;
191+
StorageLive(_5);
192+
_5 = &mut _4;
198193
StorageLive(_6);
199194
- _6 = (*_5);
200195
+ _6 = _4;
@@ -209,7 +204,7 @@
209204
StorageDead(_7);
210205
- _3 = const ();
211206
StorageDead(_6);
212-
- StorageDead(_5);
207+
StorageDead(_5);
213208
StorageDead(_4);
214209
- StorageDead(_3);
215210
- StorageLive(_9);
@@ -391,13 +386,12 @@
391386
- StorageLive(_59);
392387
StorageLive(_60);
393388
_60 = const 5_usize;
394-
- StorageLive(_61);
395-
- _61 = &mut _60;
396-
- StorageLive(_62);
397-
- _62 = &_61;
389+
StorageLive(_61);
390+
_61 = &mut _60;
391+
StorageLive(_62);
392+
_62 = &_61;
398393
StorageLive(_63);
399-
- _63 = (*_61);
400-
+ _63 = _60;
394+
_63 = (*_61);
401395
StorageLive(_64);
402396
StorageLive(_65);
403397
_65 = ();
@@ -409,19 +403,18 @@
409403
StorageDead(_64);
410404
- _59 = const ();
411405
StorageDead(_63);
412-
- StorageDead(_62);
413-
- StorageDead(_61);
406+
StorageDead(_62);
407+
StorageDead(_61);
414408
StorageDead(_60);
415409
- StorageDead(_59);
416410
StorageLive(_66);
417411
_66 = const 5_usize;
418-
- StorageLive(_67);
419-
- _67 = &mut _66;
420-
- StorageLive(_68);
421-
- _68 = &mut _67;
412+
StorageLive(_67);
413+
_67 = &mut _66;
414+
StorageLive(_68);
415+
_68 = &mut _67;
422416
StorageLive(_69);
423-
- _69 = (*_67);
424-
+ _69 = _66;
417+
_69 = (*_67);
425418
StorageLive(_70);
426419
StorageLive(_71);
427420
_71 = ();
@@ -433,8 +426,8 @@
433426
StorageDead(_70);
434427
_0 = const ();
435428
StorageDead(_69);
436-
- StorageDead(_68);
437-
- StorageDead(_67);
429+
StorageDead(_68);
430+
StorageDead(_67);
438431
StorageDead(_66);
439432
return;
440433
}

‎tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
debug a => _4;
4343
let _5: *mut usize;
4444
scope 3 {
45-
- debug b => _5;
46-
+ debug b => &_4;
45+
debug b => _5;
4746
let _6: usize;
4847
scope 4 {
4948
debug c => _6;
@@ -172,12 +171,10 @@
172171
debug a => _58;
173172
let _59: *mut usize;
174173
scope 39 {
175-
- debug b => _59;
176-
+ debug b => &_58;
174+
debug b => _59;
177175
let _60: &*mut usize;
178176
scope 40 {
179-
- debug d => _60;
180-
+ debug d => &&_58;
177+
debug d => _60;
181178
let _61: usize;
182179
scope 41 {
183180
debug c => _61;
@@ -192,12 +189,10 @@
192189
debug a => _64;
193190
let mut _65: *mut usize;
194191
scope 44 {
195-
- debug b => _65;
196-
+ debug b => &_64;
192+
debug b => _65;
197193
let _66: &mut *mut usize;
198194
scope 45 {
199-
- debug d => _66;
200-
+ debug d => &&_64;
195+
debug d => _66;
201196
let _67: usize;
202197
scope 46 {
203198
debug c => _67;
@@ -211,8 +206,8 @@
211206
- StorageLive(_3);
212207
StorageLive(_4);
213208
_4 = const 5_usize;
214-
- StorageLive(_5);
215-
- _5 = &raw mut _4;
209+
StorageLive(_5);
210+
_5 = &raw mut _4;
216211
StorageLive(_6);
217212
- _6 = (*_5);
218213
+ _6 = _4;
@@ -227,7 +222,7 @@
227222
StorageDead(_7);
228223
- _3 = const ();
229224
StorageDead(_6);
230-
- StorageDead(_5);
225+
StorageDead(_5);
231226
StorageDead(_4);
232227
- StorageDead(_3);
233228
- StorageLive(_9);
@@ -401,13 +396,12 @@
401396
- StorageLive(_57);
402397
StorageLive(_58);
403398
_58 = const 5_usize;
404-
- StorageLive(_59);
405-
- _59 = &raw mut _58;
406-
- StorageLive(_60);
407-
- _60 = &_59;
399+
StorageLive(_59);
400+
_59 = &raw mut _58;
401+
StorageLive(_60);
402+
_60 = &_59;
408403
StorageLive(_61);
409-
- _61 = (*_59);
410-
+ _61 = _58;
404+
_61 = (*_59);
411405
StorageLive(_62);
412406
StorageLive(_63);
413407
_63 = ();
@@ -419,19 +413,18 @@
419413
StorageDead(_62);
420414
- _57 = const ();
421415
StorageDead(_61);
422-
- StorageDead(_60);
423-
- StorageDead(_59);
416+
StorageDead(_60);
417+
StorageDead(_59);
424418
StorageDead(_58);
425419
- StorageDead(_57);
426420
StorageLive(_64);
427421
_64 = const 5_usize;
428-
- StorageLive(_65);
429-
- _65 = &raw mut _64;
430-
- StorageLive(_66);
431-
- _66 = &mut _65;
422+
StorageLive(_65);
423+
_65 = &raw mut _64;
424+
StorageLive(_66);
425+
_66 = &mut _65;
432426
StorageLive(_67);
433-
- _67 = (*_65);
434-
+ _67 = _64;
427+
_67 = (*_65);
435428
StorageLive(_68);
436429
StorageLive(_69);
437430
_69 = ();
@@ -443,8 +436,8 @@
443436
StorageDead(_68);
444437
_0 = const ();
445438
StorageDead(_67);
446-
- StorageDead(_66);
447-
- StorageDead(_65);
439+
StorageDead(_66);
440+
StorageDead(_65);
448441
StorageDead(_64);
449442
return;
450443
}

‎tests/ui/mir/debug-ref-undef.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// run-pass
2+
// compile-flags: -g -O -Zmir-opt-level=0 -Zinline-mir=y -Zmir-enable-passes=+ReferencePropagation
3+
4+
#![allow(dead_code)]
5+
6+
use std::marker::PhantomData;
7+
8+
struct RawTable<T> {
9+
marker: PhantomData<T>,
10+
}
11+
12+
impl<T> RawTable<T> {
13+
fn iter(&self) -> RawIter<T> {
14+
RawIter { marker: PhantomData }
15+
}
16+
}
17+
18+
struct RawIter<T> {
19+
marker: PhantomData<T>,
20+
}
21+
22+
impl<T> Iterator for RawIter<T> {
23+
type Item = ();
24+
fn next(&mut self) -> Option<()> {
25+
None
26+
}
27+
}
28+
29+
struct HashMap<T> {
30+
table: RawTable<T>,
31+
}
32+
33+
struct Iter<T> {
34+
inner: RawIter<T>, // Removing this breaks the reproducer
35+
}
36+
37+
impl<T> IntoIterator for &HashMap<T> {
38+
type Item = T;
39+
type IntoIter = Iter<T>;
40+
fn into_iter(self) -> Iter<T> {
41+
Iter { inner: self.table.iter() }
42+
}
43+
}
44+
45+
impl<T> Iterator for Iter<T> {
46+
type Item = T;
47+
fn next(&mut self) -> Option<T> {
48+
None
49+
}
50+
}
51+
52+
pub fn main() {
53+
let maybe_hash_set: Option<HashMap<()>> = None;
54+
for _ in maybe_hash_set.as_ref().unwrap_or(&HashMap { table: RawTable { marker: PhantomData } })
55+
{
56+
}
57+
}

0 commit comments

Comments
 (0)
Please sign in to comment.