summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/pre-codegen
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/pre-codegen')
-rw-r--r--tests/mir-opt/pre-codegen/chained_comparison.bitand.PreCodegen.after.mir84
-rw-r--r--tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir136
-rw-r--r--tests/mir-opt/pre-codegen/chained_comparison.returning.PreCodegen.after.mir126
-rw-r--r--tests/mir-opt/pre-codegen/chained_comparison.rs51
-rw-r--r--tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir84
-rw-r--r--tests/mir-opt/pre-codegen/checked_ops.rs17
-rw-r--r--tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir61
-rw-r--r--tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir20
-rw-r--r--tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir25
-rw-r--r--tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir17
-rw-r--r--tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir93
-rw-r--r--tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir118
-rw-r--r--tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir82
-rw-r--r--tests/mir-opt/pre-codegen/loops.rs37
-rw-r--r--tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir74
-rw-r--r--tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir14
-rw-r--r--tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir66
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.diff59
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff59
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff59
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.diff59
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff59
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff59
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-abort.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-unwind.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-abort.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-unwind.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff71
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff71
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff71
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff71
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff71
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff71
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir18
-rw-r--r--tests/mir-opt/pre-codegen/optimizes_into_variable.rs2
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir91
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir131
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir139
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.mir95
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir81
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir89
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.mir20
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir17
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir17
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir20
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir71
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir71
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.rs1
-rw-r--r--tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir66
-rw-r--r--tests/mir-opt/pre-codegen/slice_filter.rs15
-rw-r--r--tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir231
-rw-r--r--tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir95
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.rs1
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir105
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir102
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir102
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir134
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir103
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir103
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.mir26
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir23
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir23
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.mir20
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-abort.mir20
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-unwind.mir20
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir197
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir205
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir203
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir184
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir192
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir147
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir155
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir220
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir201
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir209
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.rs16
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir17
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir14
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir14
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.mir17
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir14
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir14
-rw-r--r--tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir19
-rw-r--r--tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir19
-rw-r--r--tests/mir-opt/pre-codegen/spans.rs16
-rw-r--r--tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir68
-rw-r--r--tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir34
94 files changed, 4851 insertions, 1459 deletions
diff --git a/tests/mir-opt/pre-codegen/chained_comparison.bitand.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/chained_comparison.bitand.PreCodegen.after.mir
new file mode 100644
index 000000000..99ca659c6
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/chained_comparison.bitand.PreCodegen.after.mir
@@ -0,0 +1,84 @@
+// MIR for `bitand` after PreCodegen
+
+fn bitand(_1: &Blueprint, _2: &Blueprint) -> bool {
+ debug a => _1;
+ debug b => _2;
+ let mut _0: bool;
+ let mut _3: u32;
+ let mut _4: u32;
+ let mut _5: bool;
+ let mut _6: u32;
+ let mut _7: u32;
+ let mut _8: bool;
+ let mut _9: bool;
+ let mut _10: u32;
+ let mut _11: u32;
+ let mut _12: bool;
+ let mut _13: bool;
+ let mut _14: u32;
+ let mut _15: u32;
+ let mut _16: bool;
+ let mut _17: bool;
+ let mut _18: u32;
+ let mut _19: u32;
+ let mut _20: bool;
+
+ bb0: {
+ StorageLive(_17);
+ StorageLive(_13);
+ StorageLive(_9);
+ StorageLive(_5);
+ StorageLive(_3);
+ _3 = ((*_1).0: u32);
+ StorageLive(_4);
+ _4 = ((*_2).0: u32);
+ _5 = Eq(move _3, move _4);
+ StorageDead(_4);
+ StorageDead(_3);
+ StorageLive(_8);
+ StorageLive(_6);
+ _6 = ((*_1).1: u32);
+ StorageLive(_7);
+ _7 = ((*_2).1: u32);
+ _8 = Eq(move _6, move _7);
+ StorageDead(_7);
+ StorageDead(_6);
+ _9 = BitAnd(move _5, move _8);
+ StorageDead(_8);
+ StorageDead(_5);
+ StorageLive(_12);
+ StorageLive(_10);
+ _10 = ((*_1).2: u32);
+ StorageLive(_11);
+ _11 = ((*_2).2: u32);
+ _12 = Eq(move _10, move _11);
+ StorageDead(_11);
+ StorageDead(_10);
+ _13 = BitAnd(move _9, move _12);
+ StorageDead(_12);
+ StorageDead(_9);
+ StorageLive(_16);
+ StorageLive(_14);
+ _14 = ((*_1).3: u32);
+ StorageLive(_15);
+ _15 = ((*_2).3: u32);
+ _16 = Eq(move _14, move _15);
+ StorageDead(_15);
+ StorageDead(_14);
+ _17 = BitAnd(move _13, move _16);
+ StorageDead(_16);
+ StorageDead(_13);
+ StorageLive(_20);
+ StorageLive(_18);
+ _18 = ((*_1).4: u32);
+ StorageLive(_19);
+ _19 = ((*_2).4: u32);
+ _20 = Eq(move _18, move _19);
+ StorageDead(_19);
+ StorageDead(_18);
+ _0 = BitAnd(move _17, move _20);
+ StorageDead(_20);
+ StorageDead(_17);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir
new file mode 100644
index 000000000..c7fd397fc
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir
@@ -0,0 +1,136 @@
+// MIR for `naive` after PreCodegen
+
+fn naive(_1: &Blueprint, _2: &Blueprint) -> bool {
+ debug a => _1;
+ debug b => _2;
+ let mut _0: bool;
+ let mut _3: u32;
+ let mut _4: u32;
+ let mut _5: bool;
+ let mut _6: bool;
+ let mut _7: u32;
+ let mut _8: u32;
+ let mut _9: bool;
+ let mut _10: bool;
+ let mut _11: u32;
+ let mut _12: u32;
+ let mut _13: bool;
+ let mut _14: bool;
+ let mut _15: u32;
+ let mut _16: u32;
+ let mut _17: bool;
+ let mut _18: u32;
+ let mut _19: u32;
+ let mut _20: bool;
+
+ bb0: {
+ StorageLive(_14);
+ StorageLive(_10);
+ StorageLive(_6);
+ StorageLive(_5);
+ StorageLive(_3);
+ _3 = ((*_1).0: u32);
+ StorageLive(_4);
+ _4 = ((*_2).0: u32);
+ _5 = Eq(move _3, move _4);
+ StorageDead(_4);
+ StorageDead(_3);
+ switchInt(move _5) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _6 = const false;
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_9);
+ StorageLive(_7);
+ _7 = ((*_1).1: u32);
+ StorageLive(_8);
+ _8 = ((*_2).1: u32);
+ _9 = Eq(move _7, move _8);
+ StorageDead(_8);
+ StorageDead(_7);
+ _6 = move _9;
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_9);
+ StorageDead(_5);
+ switchInt(move _6) -> [0: bb4, otherwise: bb5];
+ }
+
+ bb4: {
+ _10 = const false;
+ goto -> bb6;
+ }
+
+ bb5: {
+ StorageLive(_13);
+ StorageLive(_11);
+ _11 = ((*_1).2: u32);
+ StorageLive(_12);
+ _12 = ((*_2).2: u32);
+ _13 = Eq(move _11, move _12);
+ StorageDead(_12);
+ StorageDead(_11);
+ _10 = move _13;
+ goto -> bb6;
+ }
+
+ bb6: {
+ StorageDead(_13);
+ StorageDead(_6);
+ switchInt(move _10) -> [0: bb7, otherwise: bb8];
+ }
+
+ bb7: {
+ _14 = const false;
+ goto -> bb9;
+ }
+
+ bb8: {
+ StorageLive(_17);
+ StorageLive(_15);
+ _15 = ((*_1).3: u32);
+ StorageLive(_16);
+ _16 = ((*_2).3: u32);
+ _17 = Eq(move _15, move _16);
+ StorageDead(_16);
+ StorageDead(_15);
+ _14 = move _17;
+ goto -> bb9;
+ }
+
+ bb9: {
+ StorageDead(_17);
+ StorageDead(_10);
+ switchInt(move _14) -> [0: bb10, otherwise: bb11];
+ }
+
+ bb10: {
+ _0 = const false;
+ goto -> bb12;
+ }
+
+ bb11: {
+ StorageLive(_20);
+ StorageLive(_18);
+ _18 = ((*_1).4: u32);
+ StorageLive(_19);
+ _19 = ((*_2).4: u32);
+ _20 = Eq(move _18, move _19);
+ StorageDead(_19);
+ StorageDead(_18);
+ _0 = move _20;
+ goto -> bb12;
+ }
+
+ bb12: {
+ StorageDead(_20);
+ StorageDead(_14);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/chained_comparison.returning.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/chained_comparison.returning.PreCodegen.after.mir
new file mode 100644
index 000000000..1e619bc97
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/chained_comparison.returning.PreCodegen.after.mir
@@ -0,0 +1,126 @@
+// MIR for `returning` after PreCodegen
+
+fn returning(_1: &Blueprint, _2: &Blueprint) -> bool {
+ debug a => _1;
+ debug b => _2;
+ let mut _0: bool;
+ let mut _3: u32;
+ let mut _4: u32;
+ let mut _5: bool;
+ let mut _6: u32;
+ let mut _7: u32;
+ let mut _8: bool;
+ let mut _9: u32;
+ let mut _10: u32;
+ let mut _11: bool;
+ let mut _12: u32;
+ let mut _13: u32;
+ let mut _14: bool;
+ let mut _15: u32;
+ let mut _16: u32;
+ let mut _17: bool;
+
+ bb0: {
+ StorageLive(_5);
+ StorageLive(_3);
+ _3 = ((*_1).0: u32);
+ StorageLive(_4);
+ _4 = ((*_2).0: u32);
+ _5 = Ne(move _3, move _4);
+ StorageDead(_4);
+ StorageDead(_3);
+ switchInt(move _5) -> [0: bb1, otherwise: bb10];
+ }
+
+ bb1: {
+ StorageDead(_5);
+ StorageLive(_8);
+ StorageLive(_6);
+ _6 = ((*_1).1: u32);
+ StorageLive(_7);
+ _7 = ((*_2).1: u32);
+ _8 = Ne(move _6, move _7);
+ StorageDead(_7);
+ StorageDead(_6);
+ switchInt(move _8) -> [0: bb2, otherwise: bb9];
+ }
+
+ bb2: {
+ StorageDead(_8);
+ StorageLive(_11);
+ StorageLive(_9);
+ _9 = ((*_1).2: u32);
+ StorageLive(_10);
+ _10 = ((*_2).2: u32);
+ _11 = Ne(move _9, move _10);
+ StorageDead(_10);
+ StorageDead(_9);
+ switchInt(move _11) -> [0: bb3, otherwise: bb8];
+ }
+
+ bb3: {
+ StorageDead(_11);
+ StorageLive(_14);
+ StorageLive(_12);
+ _12 = ((*_1).3: u32);
+ StorageLive(_13);
+ _13 = ((*_2).3: u32);
+ _14 = Ne(move _12, move _13);
+ StorageDead(_13);
+ StorageDead(_12);
+ switchInt(move _14) -> [0: bb4, otherwise: bb7];
+ }
+
+ bb4: {
+ StorageDead(_14);
+ StorageLive(_17);
+ StorageLive(_15);
+ _15 = ((*_1).4: u32);
+ StorageLive(_16);
+ _16 = ((*_2).4: u32);
+ _17 = Ne(move _15, move _16);
+ StorageDead(_16);
+ StorageDead(_15);
+ switchInt(move _17) -> [0: bb5, otherwise: bb6];
+ }
+
+ bb5: {
+ StorageDead(_17);
+ _0 = const true;
+ goto -> bb11;
+ }
+
+ bb6: {
+ _0 = const false;
+ StorageDead(_17);
+ goto -> bb11;
+ }
+
+ bb7: {
+ _0 = const false;
+ StorageDead(_14);
+ goto -> bb11;
+ }
+
+ bb8: {
+ _0 = const false;
+ StorageDead(_11);
+ goto -> bb11;
+ }
+
+ bb9: {
+ _0 = const false;
+ StorageDead(_8);
+ goto -> bb11;
+ }
+
+ bb10: {
+ _0 = const false;
+ StorageDead(_5);
+ goto -> bb11;
+ }
+
+ bb11: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/chained_comparison.rs b/tests/mir-opt/pre-codegen/chained_comparison.rs
new file mode 100644
index 000000000..f7879140f
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/chained_comparison.rs
@@ -0,0 +1,51 @@
+// compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2
+// ignore-debug
+
+#![crate_type = "lib"]
+
+pub struct Blueprint {
+ pub fuel_tank_size: u32,
+ pub payload: u32,
+ pub wheel_diameter: u32,
+ pub wheel_width: u32,
+ pub storage: u32,
+}
+
+pub fn naive(a: &Blueprint, b: &Blueprint) -> bool {
+ (a.fuel_tank_size == b.fuel_tank_size)
+ && (a.payload == b.payload)
+ && (a.wheel_diameter == b.wheel_diameter)
+ && (a.wheel_width == b.wheel_width)
+ && (a.storage == b.storage)
+}
+
+pub fn bitand(a: &Blueprint, b: &Blueprint) -> bool {
+ (a.fuel_tank_size == b.fuel_tank_size)
+ & (a.payload == b.payload)
+ & (a.wheel_diameter == b.wheel_diameter)
+ & (a.wheel_width == b.wheel_width)
+ & (a.storage == b.storage)
+}
+
+pub fn returning(a: &Blueprint, b: &Blueprint) -> bool {
+ if a.fuel_tank_size != b.fuel_tank_size {
+ return false;
+ }
+ if a.payload != b.payload {
+ return false;
+ }
+ if a.wheel_diameter != b.wheel_diameter {
+ return false;
+ }
+ if a.wheel_width != b.wheel_width {
+ return false;
+ }
+ if a.storage != b.storage {
+ return false;
+ }
+ true
+}
+
+// EMIT_MIR chained_comparison.naive.PreCodegen.after.mir
+// EMIT_MIR chained_comparison.bitand.PreCodegen.after.mir
+// EMIT_MIR chained_comparison.returning.PreCodegen.after.mir
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
new file mode 100644
index 000000000..70461b445
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir
@@ -0,0 +1,84 @@
+// 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 _7: (u32, bool);
+ let _8: u32;
+ let _9: bool;
+ let mut _10: bool;
+ scope 2 {
+ debug a => _8;
+ debug b => _9;
+ }
+ scope 3 (inlined core::num::<impl u32>::overflowing_shl) {
+ debug self => _1;
+ debug rhs => _2;
+ let mut _5: u32;
+ let mut _6: bool;
+ scope 4 (inlined core::num::<impl u32>::wrapping_shl) {
+ debug self => _1;
+ debug rhs => _2;
+ let mut _3: u32;
+ let mut _4: u32;
+ scope 5 {
+ scope 6 (inlined core::num::<impl u32>::unchecked_shl) {
+ debug self => _1;
+ debug rhs => _4;
+ scope 7 {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_8);
+ StorageLive(_9);
+ StorageLive(_7);
+ StorageLive(_5);
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = const 31_u32;
+ _4 = BitAnd(_2, move _3);
+ StorageDead(_3);
+ _5 = ShlUnchecked(_1, _4);
+ StorageDead(_4);
+ StorageLive(_6);
+ _6 = Ge(_2, const _);
+ _7 = (move _5, move _6);
+ StorageDead(_6);
+ StorageDead(_5);
+ _8 = (_7.0: u32);
+ _9 = (_7.1: bool);
+ StorageDead(_7);
+ StorageLive(_10);
+ _10 = unlikely(_9) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ switchInt(move _10) -> [0: bb2, otherwise: bb3];
+ }
+
+ bb2: {
+ _0 = Option::<u32>::Some(_8);
+ goto -> bb4;
+ }
+
+ bb3: {
+ _0 = Option::<u32>::None;
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_8);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/checked_ops.rs b/tests/mir-opt/pre-codegen/checked_ops.rs
new file mode 100644
index 000000000..dee43b0c6
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/checked_ops.rs
@@ -0,0 +1,17 @@
+// compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2
+// needs-unwind
+// ignore-debug
+// only-x86_64
+
+#![crate_type = "lib"]
+#![feature(step_trait)]
+
+// EMIT_MIR checked_ops.step_forward.PreCodegen.after.mir
+pub fn step_forward(x: u32, n: usize) -> u32 {
+ std::iter::Step::forward(x, n)
+}
+
+// EMIT_MIR checked_ops.checked_shl.PreCodegen.after.mir
+pub fn checked_shl(x: u32, rhs: u32) -> Option<u32> {
+ x.checked_shl(rhs)
+}
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
new file mode 100644
index 000000000..98c267e8e
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir
@@ -0,0 +1,61 @@
+// MIR for `step_forward` after PreCodegen
+
+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 _3: std::option::Option<u32>;
+ let mut _4: &std::option::Option<u32>;
+ let mut _7: bool;
+ let mut _8: u32;
+ scope 2 {
+ }
+ scope 3 (inlined Option::<u32>::is_none) {
+ debug self => _4;
+ let mut _6: bool;
+ scope 4 (inlined Option::<u32>::is_some) {
+ debug self => _4;
+ let mut _5: isize;
+ }
+ }
+ scope 5 (inlined core::num::<impl u32>::wrapping_add) {
+ debug self => _1;
+ debug rhs => _8;
+ }
+ }
+
+ bb0: {
+ StorageLive(_7);
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = <u32 as Step>::forward_checked(_1, _2) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ _4 = &_3;
+ StorageLive(_6);
+ _5 = discriminant((*_4));
+ _6 = Eq(_5, const 1_isize);
+ _7 = Not(move _6);
+ StorageDead(_6);
+ StorageDead(_3);
+ StorageDead(_4);
+ switchInt(move _7) -> [0: bb3, otherwise: bb2];
+ }
+
+ bb2: {
+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const _, const 1_u32) -> [success: bb3, unwind continue];
+ }
+
+ bb3: {
+ StorageDead(_7);
+ StorageLive(_8);
+ _8 = _2 as u32 (IntToInt);
+ _0 = Add(_1, _8);
+ StorageDead(_8);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir
index 0e885cf94..65d71199a 100644
--- a/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir
@@ -1,27 +1,27 @@
// MIR for `ub_if_b` after PreCodegen
fn ub_if_b(_1: Thing) -> Thing {
- debug t => _1; // in scope 0 at $DIR/duplicate_switch_targets.rs:+0:23: +0:24
- let mut _0: Thing; // return place in scope 0 at $DIR/duplicate_switch_targets.rs:+0:36: +0:41
- let mut _2: isize; // in scope 0 at $DIR/duplicate_switch_targets.rs:+2:9: +2:17
- scope 1 (inlined unreachable_unchecked) { // at $DIR/duplicate_switch_targets.rs:15:21: 15:55
+ debug t => _1;
+ let mut _0: Thing;
+ let mut _2: isize;
+ scope 1 (inlined unreachable_unchecked) {
scope 2 {
- scope 3 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
+ scope 3 (inlined unreachable_unchecked::runtime) {
}
}
}
bb0: {
- _2 = discriminant(_1); // scope 0 at $DIR/duplicate_switch_targets.rs:+1:11: +1:12
- switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/duplicate_switch_targets.rs:+1:5: +1:12
+ _2 = discriminant(_1);
+ switchInt(move _2) -> [0: bb1, otherwise: bb2];
}
bb1: {
- unreachable; // scope 2 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
+ _0 = move _1;
+ return;
}
bb2: {
- _0 = move _1; // scope 0 at $DIR/duplicate_switch_targets.rs:+2:21: +2:22
- return; // scope 0 at $DIR/duplicate_switch_targets.rs:+5:2: +5:2
+ unreachable;
}
}
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 76e1fea2f..66acbbbb2 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
@@ -1,26 +1,23 @@
// MIR for `f_u64` after PreCodegen
fn f_u64() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/intrinsics.rs:+0:16: +0:16
- let mut _1: u64; // in scope 0 at $DIR/intrinsics.rs:+1:5: +1:21
- scope 1 (inlined f_dispatch::<u64>) { // at $DIR/intrinsics.rs:19:5: 19:21
- debug t => const 0_u64; // in scope 1 at $DIR/intrinsics.rs:23:22: 23:23
- let _2: (); // in scope 1 at $DIR/intrinsics.rs:27:9: 27:21
- scope 2 (inlined std::mem::size_of::<u64>) { // at $DIR/intrinsics.rs:24:8: 24:32
+ let mut _0: ();
+ let mut _1: u64;
+ scope 1 (inlined f_dispatch::<u64>) {
+ debug t => const 0_u64;
+ let _2: ();
+ scope 2 (inlined std::mem::size_of::<u64>) {
}
}
bb0: {
- StorageLive(_1); // scope 0 at $DIR/intrinsics.rs:+1:5: +1:21
- _1 = const 0_u64; // scope 0 at $DIR/intrinsics.rs:+1:5: +1:21
- _2 = f_non_zst::<u64>(move _1) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/intrinsics.rs:27:9: 27:21
- // mir::Constant
- // + span: $DIR/intrinsics.rs:27:9: 27:18
- // + literal: Const { ty: fn(u64) {f_non_zst::<u64>}, val: Value(<ZST>) }
+ StorageLive(_1);
+ _1 = const 0_u64;
+ _2 = f_non_zst::<u64>(move _1) -> [return: bb1, unwind unreachable];
}
bb1: {
- StorageDead(_1); // scope 0 at $DIR/intrinsics.rs:+1:5: +1:21
- return; // scope 0 at $DIR/intrinsics.rs:+2:2: +2:2
+ StorageDead(_1);
+ return;
}
}
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 3d416de34..578cb2d70 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
@@ -1,22 +1,19 @@
// MIR for `f_unit` after PreCodegen
fn f_unit() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/intrinsics.rs:+0:17: +0:17
- scope 1 (inlined f_dispatch::<()>) { // at $DIR/intrinsics.rs:13:5: 13:19
- debug t => const (); // in scope 1 at $DIR/intrinsics.rs:23:22: 23:23
- let _1: (); // in scope 1 at $DIR/intrinsics.rs:25:9: 25:17
- scope 2 (inlined std::mem::size_of::<()>) { // at $DIR/intrinsics.rs:24:8: 24:32
+ let mut _0: ();
+ scope 1 (inlined f_dispatch::<()>) {
+ debug t => const ();
+ let _1: ();
+ scope 2 (inlined std::mem::size_of::<()>) {
}
}
bb0: {
- _1 = f_zst::<()>(const ()) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/intrinsics.rs:25:9: 25:17
- // mir::Constant
- // + span: $DIR/intrinsics.rs:25:9: 25:14
- // + literal: Const { ty: fn(()) {f_zst::<()>}, val: Value(<ZST>) }
+ _1 = f_zst::<()>(const ()) -> [return: bb1, unwind unreachable];
}
bb1: {
- return; // scope 0 at $DIR/intrinsics.rs:+2:2: +2:2
+ return;
}
}
diff --git a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir
new file mode 100644
index 000000000..3b49cb711
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir
@@ -0,0 +1,93 @@
+// MIR for `filter_mapped` after PreCodegen
+
+fn filter_mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> Option<U>) -> () {
+ debug iter => _1;
+ debug f => _2;
+ let mut _0: ();
+ let mut _3: std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>;
+ let mut _4: std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>;
+ let mut _5: std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>;
+ let mut _6: &mut std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>;
+ let mut _9: std::option::Option<U>;
+ let mut _10: isize;
+ let _12: ();
+ scope 1 {
+ debug iter => _5;
+ let _11: U;
+ scope 2 {
+ debug x => _11;
+ }
+ scope 4 (inlined <FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>> as Iterator>::next) {
+ debug self => _6;
+ let mut _7: &mut impl Iterator<Item = T>;
+ let mut _8: &mut impl Fn(T) -> Option<U>;
+ }
+ }
+ scope 3 (inlined <FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>> as IntoIterator>::into_iter) {
+ debug self => _3;
+ }
+
+ bb0: {
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = <impl Iterator<Item = T> as Iterator>::filter_map::<U, impl Fn(T) -> Option<U>>(move _1, move _2) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ _4 = move _3;
+ StorageDead(_3);
+ StorageLive(_5);
+ _5 = move _4;
+ goto -> bb2;
+ }
+
+ bb2: {
+ StorageLive(_9);
+ _6 = &mut _5;
+ StorageLive(_7);
+ _7 = &mut ((*_6).0: impl Iterator<Item = T>);
+ StorageLive(_8);
+ _8 = &mut ((*_6).1: impl Fn(T) -> Option<U>);
+ _9 = <impl Iterator<Item = T> as Iterator>::find_map::<U, &mut impl Fn(T) -> Option<U>>(move _7, move _8) -> [return: bb3, unwind: bb9];
+ }
+
+ bb3: {
+ StorageDead(_8);
+ StorageDead(_7);
+ _10 = discriminant(_9);
+ switchInt(move _10) -> [0: bb4, 1: bb6, otherwise: bb8];
+ }
+
+ bb4: {
+ StorageDead(_9);
+ drop(_5) -> [return: bb5, unwind continue];
+ }
+
+ bb5: {
+ StorageDead(_5);
+ StorageDead(_4);
+ return;
+ }
+
+ bb6: {
+ _11 = move ((_9 as Some).0: U);
+ _12 = opaque::<U>(move _11) -> [return: bb7, unwind: bb9];
+ }
+
+ bb7: {
+ StorageDead(_9);
+ goto -> bb2;
+ }
+
+ bb8: {
+ unreachable;
+ }
+
+ bb9 (cleanup): {
+ drop(_5) -> [return: bb10, unwind terminate];
+ }
+
+ bb10 (cleanup): {
+ resume;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir
new file mode 100644
index 000000000..40bb3a37c
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir
@@ -0,0 +1,118 @@
+// MIR for `int_range` after PreCodegen
+
+fn int_range(_1: usize, _2: usize) -> () {
+ debug start => _1;
+ debug end => _2;
+ let mut _0: ();
+ let mut _3: std::ops::Range<usize>;
+ let mut _4: std::ops::Range<usize>;
+ let mut _5: &mut std::ops::Range<usize>;
+ let mut _11: std::option::Option<usize>;
+ let mut _14: isize;
+ let _16: ();
+ scope 1 {
+ debug iter => _4;
+ let _15: usize;
+ scope 2 {
+ debug i => _15;
+ }
+ scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
+ debug self => _5;
+ scope 5 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
+ debug self => _5;
+ let mut _6: &usize;
+ let mut _7: &usize;
+ let mut _10: bool;
+ let _12: usize;
+ let mut _13: usize;
+ scope 6 {
+ debug old => _12;
+ scope 7 {
+ }
+ }
+ scope 8 (inlined cmp::impls::<impl PartialOrd for usize>::lt) {
+ debug self => _6;
+ debug other => _7;
+ let mut _8: usize;
+ let mut _9: usize;
+ }
+ }
+ }
+ }
+ scope 3 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) {
+ debug self => _3;
+ }
+
+ bb0: {
+ _3 = std::ops::Range::<usize> { start: _1, end: _2 };
+ StorageLive(_4);
+ _4 = move _3;
+ goto -> bb1;
+ }
+
+ bb1: {
+ StorageLive(_11);
+ _5 = &mut _4;
+ StorageLive(_12);
+ StorageLive(_10);
+ StorageLive(_6);
+ _6 = &((*_5).0: usize);
+ StorageLive(_7);
+ _7 = &((*_5).1: usize);
+ StorageLive(_8);
+ _8 = (*_6);
+ StorageLive(_9);
+ _9 = (*_7);
+ _10 = Lt(move _8, move _9);
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_7);
+ StorageDead(_6);
+ switchInt(move _10) -> [0: bb2, otherwise: bb3];
+ }
+
+ bb2: {
+ _11 = Option::<usize>::None;
+ goto -> bb5;
+ }
+
+ bb3: {
+ _12 = ((*_5).0: usize);
+ StorageLive(_13);
+ _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb4, unwind continue];
+ }
+
+ bb4: {
+ ((*_5).0: usize) = move _13;
+ StorageDead(_13);
+ _11 = Option::<usize>::Some(_12);
+ goto -> bb5;
+ }
+
+ bb5: {
+ StorageDead(_10);
+ StorageDead(_12);
+ _14 = discriminant(_11);
+ switchInt(move _14) -> [0: bb6, 1: bb7, otherwise: bb9];
+ }
+
+ bb6: {
+ StorageDead(_11);
+ StorageDead(_4);
+ return;
+ }
+
+ bb7: {
+ _15 = ((_11 as Some).0: usize);
+ _16 = opaque::<usize>(_15) -> [return: bb8, unwind continue];
+ }
+
+ bb8: {
+ StorageDead(_11);
+ goto -> bb1;
+ }
+
+ bb9: {
+ unreachable;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir
new file mode 100644
index 000000000..e4e1d052e
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir
@@ -0,0 +1,82 @@
+// MIR for `mapped` after PreCodegen
+
+fn mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> U) -> () {
+ debug iter => _1;
+ debug f => _2;
+ let mut _0: ();
+ let mut _3: std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>;
+ let mut _4: std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>;
+ let mut _5: std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>;
+ let mut _6: &mut std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>;
+ let mut _7: std::option::Option<U>;
+ let mut _8: isize;
+ let _10: ();
+ scope 1 {
+ debug iter => _5;
+ let _9: U;
+ scope 2 {
+ debug x => _9;
+ }
+ }
+ scope 3 (inlined <Map<impl Iterator<Item = T>, impl Fn(T) -> U> as IntoIterator>::into_iter) {
+ debug self => _3;
+ }
+
+ bb0: {
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = <impl Iterator<Item = T> as Iterator>::map::<U, impl Fn(T) -> U>(move _1, move _2) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ _4 = move _3;
+ StorageDead(_3);
+ StorageLive(_5);
+ _5 = move _4;
+ goto -> bb2;
+ }
+
+ bb2: {
+ StorageLive(_7);
+ _6 = &mut _5;
+ _7 = <Map<impl Iterator<Item = T>, impl Fn(T) -> U> as Iterator>::next(_6) -> [return: bb3, unwind: bb9];
+ }
+
+ bb3: {
+ _8 = discriminant(_7);
+ switchInt(move _8) -> [0: bb4, 1: bb6, otherwise: bb8];
+ }
+
+ bb4: {
+ StorageDead(_7);
+ drop(_5) -> [return: bb5, unwind continue];
+ }
+
+ bb5: {
+ StorageDead(_5);
+ StorageDead(_4);
+ return;
+ }
+
+ bb6: {
+ _9 = move ((_7 as Some).0: U);
+ _10 = opaque::<U>(move _9) -> [return: bb7, unwind: bb9];
+ }
+
+ bb7: {
+ StorageDead(_7);
+ goto -> bb2;
+ }
+
+ bb8: {
+ unreachable;
+ }
+
+ bb9 (cleanup): {
+ drop(_5) -> [return: bb10, unwind terminate];
+ }
+
+ bb10 (cleanup): {
+ resume;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/loops.rs b/tests/mir-opt/pre-codegen/loops.rs
new file mode 100644
index 000000000..67f549a51
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/loops.rs
@@ -0,0 +1,37 @@
+// compile-flags: -O -Zmir-opt-level=2 -g
+// needs-unwind
+// ignore-debug
+
+#![crate_type = "lib"]
+
+pub fn int_range(start: usize, end: usize) {
+ for i in start..end {
+ opaque(i)
+ }
+}
+
+pub fn mapped<T, U>(iter: impl Iterator<Item = T>, f: impl Fn(T) -> U) {
+ for x in iter.map(f) {
+ opaque(x)
+ }
+}
+
+pub fn filter_mapped<T, U>(iter: impl Iterator<Item = T>, f: impl Fn(T) -> Option<U>) {
+ for x in iter.filter_map(f) {
+ opaque(x)
+ }
+}
+
+pub fn vec_move(mut v: Vec<impl Sized>) {
+ for x in v {
+ opaque(x)
+ }
+}
+
+#[inline(never)]
+fn opaque(_: impl Sized) {}
+
+// EMIT_MIR loops.int_range.PreCodegen.after.mir
+// EMIT_MIR loops.mapped.PreCodegen.after.mir
+// EMIT_MIR loops.filter_mapped.PreCodegen.after.mir
+// EMIT_MIR loops.vec_move.PreCodegen.after.mir
diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir
new file mode 100644
index 000000000..1b5f2a088
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir
@@ -0,0 +1,74 @@
+// MIR for `vec_move` after PreCodegen
+
+fn vec_move(_1: Vec<impl Sized>) -> () {
+ debug v => _1;
+ let mut _0: ();
+ let mut _2: std::vec::IntoIter<impl Sized>;
+ let mut _3: std::vec::IntoIter<impl Sized>;
+ let mut _4: &mut std::vec::IntoIter<impl Sized>;
+ let mut _5: std::option::Option<impl Sized>;
+ let mut _6: isize;
+ let _8: ();
+ scope 1 {
+ debug iter => _3;
+ let _7: impl Sized;
+ scope 2 {
+ debug x => _7;
+ }
+ }
+
+ bb0: {
+ StorageLive(_2);
+ _2 = <Vec<impl Sized> as IntoIterator>::into_iter(move _1) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageLive(_3);
+ _3 = move _2;
+ goto -> bb2;
+ }
+
+ bb2: {
+ StorageLive(_5);
+ _4 = &mut _3;
+ _5 = <std::vec::IntoIter<impl Sized> as Iterator>::next(_4) -> [return: bb3, unwind: bb9];
+ }
+
+ bb3: {
+ _6 = discriminant(_5);
+ switchInt(move _6) -> [0: bb4, 1: bb6, otherwise: bb8];
+ }
+
+ bb4: {
+ StorageDead(_5);
+ drop(_3) -> [return: bb5, unwind continue];
+ }
+
+ bb5: {
+ StorageDead(_3);
+ StorageDead(_2);
+ return;
+ }
+
+ bb6: {
+ _7 = move ((_5 as Some).0: impl Sized);
+ _8 = opaque::<impl Sized>(move _7) -> [return: bb7, unwind: bb9];
+ }
+
+ bb7: {
+ StorageDead(_5);
+ goto -> bb2;
+ }
+
+ bb8: {
+ unreachable;
+ }
+
+ bb9 (cleanup): {
+ drop(_3) -> [return: bb10, unwind terminate];
+ }
+
+ bb10 (cleanup): {
+ resume;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir
index 1d2387102..3ca24e152 100644
--- a/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir
@@ -1,16 +1,16 @@
// MIR for `manual_replace` after PreCodegen
fn manual_replace(_1: &mut u32, _2: u32) -> u32 {
- debug r => _1; // in scope 0 at $DIR/mem_replace.rs:+0:23: +0:24
- debug v => _2; // in scope 0 at $DIR/mem_replace.rs:+0:36: +0:37
- let mut _0: u32; // return place in scope 0 at $DIR/mem_replace.rs:+0:47: +0:50
+ debug r => _1;
+ debug v => _2;
+ let mut _0: u32;
scope 1 {
- debug temp => _0; // in scope 1 at $DIR/mem_replace.rs:+1:9: +1:13
+ debug temp => _0;
}
bb0: {
- _0 = (*_1); // scope 0 at $DIR/mem_replace.rs:+1:16: +1:18
- (*_1) = _2; // scope 1 at $DIR/mem_replace.rs:+2:5: +2:11
- return; // scope 0 at $DIR/mem_replace.rs:+4:2: +4:2
+ _0 = (*_1);
+ (*_1) = _2;
+ return;
}
}
diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir
index 50e0538c1..f8f4f5b99 100644
--- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir
@@ -1,34 +1,34 @@
// MIR for `mem_replace` after PreCodegen
fn mem_replace(_1: &mut u32, _2: u32) -> u32 {
- debug r => _1; // in scope 0 at $DIR/mem_replace.rs:+0:20: +0:21
- debug v => _2; // in scope 0 at $DIR/mem_replace.rs:+0:33: +0:34
- let mut _0: u32; // return place in scope 0 at $DIR/mem_replace.rs:+0:44: +0:47
- scope 1 (inlined std::mem::replace::<u32>) { // at $DIR/mem_replace.rs:16:5: 16:28
- debug dest => _1; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- debug src => _2; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- let mut _3: *const u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- let mut _4: *mut u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
+ debug r => _1;
+ debug v => _2;
+ let mut _0: u32;
+ scope 1 (inlined std::mem::replace::<u32>) {
+ debug dest => _1;
+ debug src => _2;
+ let mut _3: *const u32;
+ let mut _4: *mut u32;
scope 2 {
scope 3 {
- debug result => _0; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- scope 7 (inlined std::ptr::write::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- debug dst => _4; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- debug src => _2; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- let mut _6: *mut u32; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
+ debug result => _0;
+ scope 7 (inlined std::ptr::write::<u32>) {
+ debug dst => _4;
+ debug src => _2;
+ let mut _6: *mut u32;
scope 8 {
- scope 9 (inlined std::ptr::write::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- debug dst => _6; // in scope 9 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
+ scope 9 (inlined std::ptr::write::runtime::<u32>) {
+ debug dst => _6;
}
}
}
}
- scope 4 (inlined std::ptr::read::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- debug src => _3; // in scope 4 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- let mut _5: *const u32; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
+ scope 4 (inlined std::ptr::read::<u32>) {
+ debug src => _3;
+ let mut _5: *const u32;
scope 5 {
- scope 6 (inlined std::ptr::read::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- debug src => _5; // in scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
+ scope 6 (inlined std::ptr::read::runtime::<u32>) {
+ debug src => _5;
}
}
}
@@ -36,18 +36,18 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 {
}
bb0: {
- StorageLive(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- _3 = &raw const (*_1); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- StorageLive(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- _0 = (*_3); // scope 5 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- StorageDead(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- StorageDead(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- StorageLive(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- _4 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- StorageLive(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- (*_4) = _2; // scope 8 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- StorageDead(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- StorageDead(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
- return; // scope 0 at $DIR/mem_replace.rs:+2:2: +2:2
+ StorageLive(_3);
+ _3 = &raw const (*_1);
+ StorageLive(_5);
+ _0 = (*_3);
+ StorageDead(_5);
+ StorageDead(_3);
+ StorageLive(_4);
+ _4 = &raw mut (*_1);
+ StorageLive(_6);
+ (*_4) = _2;
+ StorageDead(_6);
+ StorageDead(_4);
+ return;
}
}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.diff
deleted file mode 100644
index 691aa01a5..000000000
--- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.diff
+++ /dev/null
@@ -1,59 +0,0 @@
-- // MIR for `main` before ConstProp
-+ // MIR for `main` after ConstProp
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
- let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- let mut _2: (i32, bool); // in scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- let mut _4: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- let mut _9: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- scope 1 {
- debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- scope 2 {
- debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- scope 3 {
- debug z => _9; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- }
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
-- _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
-- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
-+ _2 = const (4_i32, false); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
-+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- }
-
- bb1: {
-- _1 = move (_2.0: i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
-+ _1 = const 4_i32; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- StorageLive(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- StorageLive(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- StorageLive(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- _5 = const 3_usize; // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- _6 = const 6_usize; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-- _7 = Lt(_5, _6); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-+ _7 = const true; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> bb2; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- }
-
- bb2: {
-- _3 = _4[_5]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-+ _3 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
- StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
- _9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
- }
- }
-
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff
new file mode 100644
index 000000000..2c607b4c0
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff
@@ -0,0 +1,59 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _2: (i32, bool);
+ let mut _4: [i32; 6];
+ let _5: usize;
+ let mut _6: usize;
+ let mut _7: bool;
+ let mut _9: u32;
+ scope 1 {
+ debug x => _1;
+ let _3: i32;
+ scope 2 {
+ debug y => _3;
+ let _8: u32;
+ scope 3 {
+ debug z => _9;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _2 = CheckedAdd(const 2_i32, const 2_i32);
+- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable];
++ _2 = const (4_i32, false);
++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = move (_2.0: i32);
++ _1 = const 4_i32;
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
+ StorageLive(_5);
+ _5 = const 3_usize;
+ _6 = const 6_usize;
+- _7 = Lt(_5, _6);
+- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind unreachable];
++ _7 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind unreachable];
+ }
+
+ bb2: {
+- _3 = _4[_5];
++ _3 = const 3_i32;
+ StorageDead(_5);
+ StorageDead(_4);
+ _9 = const 42_u32;
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff
new file mode 100644
index 000000000..b6929f3f9
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff
@@ -0,0 +1,59 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _2: (i32, bool);
+ let mut _4: [i32; 6];
+ let _5: usize;
+ let mut _6: usize;
+ let mut _7: bool;
+ let mut _9: u32;
+ scope 1 {
+ debug x => _1;
+ let _3: i32;
+ scope 2 {
+ debug y => _3;
+ let _8: u32;
+ scope 3 {
+ debug z => _9;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _2 = CheckedAdd(const 2_i32, const 2_i32);
+- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue];
++ _2 = const (4_i32, false);
++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = move (_2.0: i32);
++ _1 = const 4_i32;
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
+ StorageLive(_5);
+ _5 = const 3_usize;
+ _6 = const 6_usize;
+- _7 = Lt(_5, _6);
+- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue];
++ _7 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind continue];
+ }
+
+ bb2: {
+- _3 = _4[_5];
++ _3 = const 3_i32;
+ StorageDead(_5);
+ StorageDead(_4);
+ _9 = const 42_u32;
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.diff
deleted file mode 100644
index 691aa01a5..000000000
--- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.diff
+++ /dev/null
@@ -1,59 +0,0 @@
-- // MIR for `main` before ConstProp
-+ // MIR for `main` after ConstProp
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
- let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- let mut _2: (i32, bool); // in scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- let mut _4: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- let mut _9: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- scope 1 {
- debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- scope 2 {
- debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- scope 3 {
- debug z => _9; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- }
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
-- _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
-- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
-+ _2 = const (4_i32, false); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
-+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- }
-
- bb1: {
-- _1 = move (_2.0: i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
-+ _1 = const 4_i32; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- StorageLive(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- StorageLive(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- StorageLive(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- _5 = const 3_usize; // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- _6 = const 6_usize; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-- _7 = Lt(_5, _6); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-+ _7 = const true; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> bb2; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- }
-
- bb2: {
-- _3 = _4[_5]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
-+ _3 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
- StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
- _9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
- }
- }
-
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff
new file mode 100644
index 000000000..2c607b4c0
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff
@@ -0,0 +1,59 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _2: (i32, bool);
+ let mut _4: [i32; 6];
+ let _5: usize;
+ let mut _6: usize;
+ let mut _7: bool;
+ let mut _9: u32;
+ scope 1 {
+ debug x => _1;
+ let _3: i32;
+ scope 2 {
+ debug y => _3;
+ let _8: u32;
+ scope 3 {
+ debug z => _9;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _2 = CheckedAdd(const 2_i32, const 2_i32);
+- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable];
++ _2 = const (4_i32, false);
++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = move (_2.0: i32);
++ _1 = const 4_i32;
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
+ StorageLive(_5);
+ _5 = const 3_usize;
+ _6 = const 6_usize;
+- _7 = Lt(_5, _6);
+- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind unreachable];
++ _7 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind unreachable];
+ }
+
+ bb2: {
+- _3 = _4[_5];
++ _3 = const 3_i32;
+ StorageDead(_5);
+ StorageDead(_4);
+ _9 = const 42_u32;
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff
new file mode 100644
index 000000000..b6929f3f9
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff
@@ -0,0 +1,59 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _2: (i32, bool);
+ let mut _4: [i32; 6];
+ let _5: usize;
+ let mut _6: usize;
+ let mut _7: bool;
+ let mut _9: u32;
+ scope 1 {
+ debug x => _1;
+ let _3: i32;
+ scope 2 {
+ debug y => _3;
+ let _8: u32;
+ scope 3 {
+ debug z => _9;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _2 = CheckedAdd(const 2_i32, const 2_i32);
+- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue];
++ _2 = const (4_i32, false);
++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = move (_2.0: i32);
++ _1 = const 4_i32;
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
+ StorageLive(_5);
+ _5 = const 3_usize;
+ _6 = const 6_usize;
+- _7 = Lt(_5, _6);
+- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue];
++ _7 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind continue];
+ }
+
+ bb2: {
+- _3 = _4[_5];
++ _3 = const 3_i32;
+ StorageDead(_5);
+ StorageDead(_4);
+ _9 = const 42_u32;
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.mir
deleted file mode 100644
index 7886bf19e..000000000
--- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.mir
+++ /dev/null
@@ -1,18 +0,0 @@
-// MIR for `main` after PreCodegen
-
-fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
- scope 1 {
- debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- scope 2 {
- debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- scope 3 {
- debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- }
- }
- }
-
- bb0: {
- return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
- }
-}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-abort.mir
new file mode 100644
index 000000000..681dadff3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-abort.mir
@@ -0,0 +1,18 @@
+// MIR for `main` after PreCodegen
+
+fn main() -> () {
+ let mut _0: ();
+ scope 1 {
+ debug x => const 4_i32;
+ scope 2 {
+ debug y => const 3_i32;
+ scope 3 {
+ debug z => const 42_u32;
+ }
+ }
+ }
+
+ bb0: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-unwind.mir
new file mode 100644
index 000000000..681dadff3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-unwind.mir
@@ -0,0 +1,18 @@
+// MIR for `main` after PreCodegen
+
+fn main() -> () {
+ let mut _0: ();
+ scope 1 {
+ debug x => const 4_i32;
+ scope 2 {
+ debug y => const 3_i32;
+ scope 3 {
+ debug z => const 42_u32;
+ }
+ }
+ }
+
+ bb0: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.mir
deleted file mode 100644
index 7886bf19e..000000000
--- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.mir
+++ /dev/null
@@ -1,18 +0,0 @@
-// MIR for `main` after PreCodegen
-
-fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
- scope 1 {
- debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- scope 2 {
- debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- scope 3 {
- debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- }
- }
- }
-
- bb0: {
- return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
- }
-}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-abort.mir
new file mode 100644
index 000000000..681dadff3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-abort.mir
@@ -0,0 +1,18 @@
+// MIR for `main` after PreCodegen
+
+fn main() -> () {
+ let mut _0: ();
+ scope 1 {
+ debug x => const 4_i32;
+ scope 2 {
+ debug y => const 3_i32;
+ scope 3 {
+ debug z => const 42_u32;
+ }
+ }
+ }
+
+ bb0: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-unwind.mir
new file mode 100644
index 000000000..681dadff3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-unwind.mir
@@ -0,0 +1,18 @@
+// MIR for `main` after PreCodegen
+
+fn main() -> () {
+ let mut _0: ();
+ scope 1 {
+ debug x => const 4_i32;
+ scope 2 {
+ debug y => const 3_i32;
+ scope 3 {
+ debug z => const 42_u32;
+ }
+ }
+ }
+
+ bb0: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff
deleted file mode 100644
index 98cd020da..000000000
--- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff
+++ /dev/null
@@ -1,71 +0,0 @@
-- // MIR for `main` before ScalarReplacementOfAggregates
-+ // MIR for `main` after ScalarReplacementOfAggregates
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
- let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- let mut _2: (i32, bool); // in scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- let mut _4: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ let mut _11: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- scope 1 {
- debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- scope 2 {
- debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- scope 3 {
- debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- }
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- }
-
- bb1: {
- _1 = move (_2.0: i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- StorageLive(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- StorageLive(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- StorageLive(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- _5 = const 3_usize; // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- _6 = Len(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- _7 = Lt(_5, _6); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- }
-
- bb2: {
- _3 = _4[_5]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
- StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
- StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
-- StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-- _9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
-- StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
-+ StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
-+ StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
-+ StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
-+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
- nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2
- StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
- }
- }
-
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff
new file mode 100644
index 000000000..6e681b4f9
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff
@@ -0,0 +1,71 @@
+- // MIR for `main` before ScalarReplacementOfAggregates
++ // MIR for `main` after ScalarReplacementOfAggregates
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _2: (i32, bool);
+ let mut _4: [i32; 6];
+ let _5: usize;
+ let mut _6: usize;
+ let mut _7: bool;
+ let mut _9: Point;
++ let mut _10: u32;
++ let mut _11: u32;
+ scope 1 {
+ debug x => _1;
+ let _3: i32;
+ scope 2 {
+ debug y => _3;
+ let _8: u32;
+ scope 3 {
+ debug z => _8;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _2 = CheckedAdd(const 2_i32, const 2_i32);
+ assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ _1 = move (_2.0: i32);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
+ StorageLive(_5);
+ _5 = const 3_usize;
+ _6 = Len(_4);
+ _7 = Lt(_5, _6);
+ assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind unreachable];
+ }
+
+ bb2: {
+ _3 = _4[_5];
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageLive(_8);
+- StorageLive(_9);
+- _9 = Point { x: const 12_u32, y: const 42_u32 };
+- _8 = (_9.1: u32);
+- StorageDead(_9);
++ StorageLive(_10);
++ StorageLive(_11);
++ nop;
++ _10 = const 12_u32;
++ _11 = const 42_u32;
++ nop;
++ _8 = _11;
++ StorageDead(_10);
++ StorageDead(_11);
++ nop;
+ nop;
+ StorageDead(_8);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff
new file mode 100644
index 000000000..e987969d3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff
@@ -0,0 +1,71 @@
+- // MIR for `main` before ScalarReplacementOfAggregates
++ // MIR for `main` after ScalarReplacementOfAggregates
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _2: (i32, bool);
+ let mut _4: [i32; 6];
+ let _5: usize;
+ let mut _6: usize;
+ let mut _7: bool;
+ let mut _9: Point;
++ let mut _10: u32;
++ let mut _11: u32;
+ scope 1 {
+ debug x => _1;
+ let _3: i32;
+ scope 2 {
+ debug y => _3;
+ let _8: u32;
+ scope 3 {
+ debug z => _8;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _2 = CheckedAdd(const 2_i32, const 2_i32);
+ assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+ _1 = move (_2.0: i32);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
+ StorageLive(_5);
+ _5 = const 3_usize;
+ _6 = Len(_4);
+ _7 = Lt(_5, _6);
+ assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue];
+ }
+
+ bb2: {
+ _3 = _4[_5];
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageLive(_8);
+- StorageLive(_9);
+- _9 = Point { x: const 12_u32, y: const 42_u32 };
+- _8 = (_9.1: u32);
+- StorageDead(_9);
++ StorageLive(_10);
++ StorageLive(_11);
++ nop;
++ _10 = const 12_u32;
++ _11 = const 42_u32;
++ nop;
++ _8 = _11;
++ StorageDead(_10);
++ StorageDead(_11);
++ nop;
+ nop;
+ StorageDead(_8);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff
deleted file mode 100644
index 98cd020da..000000000
--- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff
+++ /dev/null
@@ -1,71 +0,0 @@
-- // MIR for `main` before ScalarReplacementOfAggregates
-+ // MIR for `main` after ScalarReplacementOfAggregates
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
- let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- let mut _2: (i32, bool); // in scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- let mut _4: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ let mut _11: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- scope 1 {
- debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- scope 2 {
- debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- scope 3 {
- debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- }
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- }
-
- bb1: {
- _1 = move (_2.0: i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18
- StorageLive(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- StorageLive(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31
- StorageLive(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- _5 = const 3_usize; // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
- _6 = Len(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- _7 = Lt(_5, _6); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- }
-
- bb2: {
- _3 = _4[_5]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
- StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
- StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
- StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
-- StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-- _9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
-- StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
-+ StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
-+ _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
-+ StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
-+ StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
-+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
- nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2
- StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
- return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
- }
- }
-
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff
new file mode 100644
index 000000000..6e681b4f9
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff
@@ -0,0 +1,71 @@
+- // MIR for `main` before ScalarReplacementOfAggregates
++ // MIR for `main` after ScalarReplacementOfAggregates
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _2: (i32, bool);
+ let mut _4: [i32; 6];
+ let _5: usize;
+ let mut _6: usize;
+ let mut _7: bool;
+ let mut _9: Point;
++ let mut _10: u32;
++ let mut _11: u32;
+ scope 1 {
+ debug x => _1;
+ let _3: i32;
+ scope 2 {
+ debug y => _3;
+ let _8: u32;
+ scope 3 {
+ debug z => _8;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _2 = CheckedAdd(const 2_i32, const 2_i32);
+ assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ _1 = move (_2.0: i32);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
+ StorageLive(_5);
+ _5 = const 3_usize;
+ _6 = Len(_4);
+ _7 = Lt(_5, _6);
+ assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind unreachable];
+ }
+
+ bb2: {
+ _3 = _4[_5];
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageLive(_8);
+- StorageLive(_9);
+- _9 = Point { x: const 12_u32, y: const 42_u32 };
+- _8 = (_9.1: u32);
+- StorageDead(_9);
++ StorageLive(_10);
++ StorageLive(_11);
++ nop;
++ _10 = const 12_u32;
++ _11 = const 42_u32;
++ nop;
++ _8 = _11;
++ StorageDead(_10);
++ StorageDead(_11);
++ nop;
+ nop;
+ StorageDead(_8);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff
new file mode 100644
index 000000000..e987969d3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff
@@ -0,0 +1,71 @@
+- // MIR for `main` before ScalarReplacementOfAggregates
++ // MIR for `main` after ScalarReplacementOfAggregates
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _2: (i32, bool);
+ let mut _4: [i32; 6];
+ let _5: usize;
+ let mut _6: usize;
+ let mut _7: bool;
+ let mut _9: Point;
++ let mut _10: u32;
++ let mut _11: u32;
+ scope 1 {
+ debug x => _1;
+ let _3: i32;
+ scope 2 {
+ debug y => _3;
+ let _8: u32;
+ scope 3 {
+ debug z => _8;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _2 = CheckedAdd(const 2_i32, const 2_i32);
+ assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+ _1 = move (_2.0: i32);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
+ StorageLive(_5);
+ _5 = const 3_usize;
+ _6 = Len(_4);
+ _7 = Lt(_5, _6);
+ assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue];
+ }
+
+ bb2: {
+ _3 = _4[_5];
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageLive(_8);
+- StorageLive(_9);
+- _9 = Point { x: const 12_u32, y: const 42_u32 };
+- _8 = (_9.1: u32);
+- StorageDead(_9);
++ StorageLive(_10);
++ StorageLive(_11);
++ nop;
++ _10 = const 12_u32;
++ _11 = const 42_u32;
++ nop;
++ _8 = _11;
++ StorageDead(_10);
++ StorageDead(_11);
++ nop;
+ nop;
+ StorageDead(_8);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir
deleted file mode 100644
index 5bea94c7f..000000000
--- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir
+++ /dev/null
@@ -1,18 +0,0 @@
-// MIR for `main` after SimplifyLocals-final
-
-fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
- scope 1 {
- debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- scope 2 {
- debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- scope 3 {
- debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- }
- }
- }
-
- bb0: {
- return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
- }
-}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir
new file mode 100644
index 000000000..425b95db3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir
@@ -0,0 +1,18 @@
+// MIR for `main` after SimplifyLocals-final
+
+fn main() -> () {
+ let mut _0: ();
+ scope 1 {
+ debug x => const 4_i32;
+ scope 2 {
+ debug y => const 3_i32;
+ scope 3 {
+ debug z => const 42_u32;
+ }
+ }
+ }
+
+ bb0: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir
new file mode 100644
index 000000000..425b95db3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir
@@ -0,0 +1,18 @@
+// MIR for `main` after SimplifyLocals-final
+
+fn main() -> () {
+ let mut _0: ();
+ scope 1 {
+ debug x => const 4_i32;
+ scope 2 {
+ debug y => const 3_i32;
+ scope 3 {
+ debug z => const 42_u32;
+ }
+ }
+ }
+
+ bb0: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir
deleted file mode 100644
index 5bea94c7f..000000000
--- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir
+++ /dev/null
@@ -1,18 +0,0 @@
-// MIR for `main` after SimplifyLocals-final
-
-fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
- scope 1 {
- debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
- scope 2 {
- debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
- scope 3 {
- debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
- }
- }
- }
-
- bb0: {
- return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
- }
-}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir
new file mode 100644
index 000000000..425b95db3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir
@@ -0,0 +1,18 @@
+// MIR for `main` after SimplifyLocals-final
+
+fn main() -> () {
+ let mut _0: ();
+ scope 1 {
+ debug x => const 4_i32;
+ scope 2 {
+ debug y => const 3_i32;
+ scope 3 {
+ debug z => const 42_u32;
+ }
+ }
+ }
+
+ bb0: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir
new file mode 100644
index 000000000..425b95db3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir
@@ -0,0 +1,18 @@
+// MIR for `main` after SimplifyLocals-final
+
+fn main() -> () {
+ let mut _0: ();
+ scope 1 {
+ debug x => const 4_i32;
+ scope 2 {
+ debug y => const 3_i32;
+ scope 3 {
+ debug z => const 42_u32;
+ }
+ }
+ }
+
+ bb0: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.rs b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs
index bb32cd3af..704f8f887 100644
--- a/tests/mir-opt/pre-codegen/optimizes_into_variable.rs
+++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs
@@ -1,4 +1,4 @@
-// ignore-wasm32 compiled with panic=abort by default
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -C overflow-checks=on
struct Point {
diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir
deleted file mode 100644
index 343a4a5a6..000000000
--- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir
+++ /dev/null
@@ -1,91 +0,0 @@
-// MIR for `forward_loop` after PreCodegen
-
-fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
- debug start => _1; // in scope 0 at $DIR/range_iter.rs:+0:21: +0:26
- debug end => _2; // in scope 0 at $DIR/range_iter.rs:+0:33: +0:36
- debug f => _3; // in scope 0 at $DIR/range_iter.rs:+0:43: +0:44
- let mut _0: (); // return place in scope 0 at $DIR/range_iter.rs:+0:60: +0:60
- let mut _4: std::ops::Range<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24
- let mut _5: std::ops::Range<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24
- let _6: (); // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24
- let mut _7: std::option::Option<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24
- let mut _8: &mut std::ops::Range<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24
- let mut _9: isize; // in scope 0 at $DIR/range_iter.rs:+1:5: +3:6
- let mut _11: &impl Fn(u32); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:10
- let mut _12: (u32,); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:13
- scope 1 {
- debug iter => _5; // in scope 1 at $DIR/range_iter.rs:+1:14: +1:24
- let _10: u32; // in scope 1 at $DIR/range_iter.rs:+1:9: +1:10
- scope 2 {
- debug x => _10; // in scope 2 at $DIR/range_iter.rs:+1:9: +1:10
- }
- scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { // at $DIR/range_iter.rs:21:14: 21:24
- debug self => _8; // in scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL
- }
- }
- scope 3 (inlined <std::ops::Range<u32> as IntoIterator>::into_iter) { // at $DIR/range_iter.rs:21:14: 21:24
- debug self => _4; // in scope 3 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- }
-
- bb0: {
- _4 = std::ops::Range::<u32> { start: _1, end: _2 }; // scope 0 at $DIR/range_iter.rs:+1:14: +1:24
- StorageLive(_5); // scope 0 at $DIR/range_iter.rs:+1:14: +1:24
- _5 = move _4; // scope 0 at $DIR/range_iter.rs:+1:14: +1:24
- goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6
- }
-
- bb1: {
- StorageLive(_7); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24
- _8 = &mut _5; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24
- _7 = <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next(_8) -> [return: bb9, unwind: bb7]; // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL
- // mir::Constant
- // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL
- // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<u32>) -> Option<<std::ops::Range<u32> as iter::range::RangeIteratorImpl>::Item> {<std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next}, val: Value(<ZST>) }
- }
-
- bb2: {
- _10 = ((_7 as Some).0: u32); // scope 1 at $DIR/range_iter.rs:+1:9: +1:10
- StorageLive(_11); // scope 2 at $DIR/range_iter.rs:+2:9: +2:10
- _11 = &_3; // scope 2 at $DIR/range_iter.rs:+2:9: +2:10
- StorageLive(_12); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13
- _12 = (_10,); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13
- _6 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb5, unwind: bb7]; // scope 2 at $DIR/range_iter.rs:+2:9: +2:13
- // mir::Constant
- // + span: $DIR/range_iter.rs:22:9: 22:10
- // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(u32), (u32,)) -> <impl Fn(u32) as FnOnce<(u32,)>>::Output {<impl Fn(u32) as Fn<(u32,)>>::call}, val: Value(<ZST>) }
- }
-
- bb3: {
- unreachable; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24
- }
-
- bb4: {
- StorageDead(_7); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6
- StorageDead(_5); // scope 0 at $DIR/range_iter.rs:+3:5: +3:6
- drop(_3) -> bb6; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2
- }
-
- bb5: {
- StorageDead(_12); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13
- StorageDead(_11); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13
- StorageDead(_7); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6
- goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6
- }
-
- bb6: {
- return; // scope 0 at $DIR/range_iter.rs:+4:2: +4:2
- }
-
- bb7 (cleanup): {
- drop(_3) -> [return: bb8, unwind terminate]; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2
- }
-
- bb8 (cleanup): {
- resume; // scope 0 at $DIR/range_iter.rs:+0:1: +4:2
- }
-
- bb9: {
- _9 = discriminant(_7); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24
- switchInt(move _9) -> [0: bb4, 1: bb2, otherwise: bb3]; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24
- }
-}
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
new file mode 100644
index 000000000..2344a3c0f
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,131 @@
+// MIR for `forward_loop` after PreCodegen
+
+fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
+ debug start => _1;
+ 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 _12: std::option::Option<u32>;
+ let mut _15: isize;
+ let mut _17: &impl Fn(u32);
+ let mut _18: (u32,);
+ let _19: ();
+ scope 1 {
+ debug iter => _5;
+ let _16: u32;
+ scope 2 {
+ debug x => _16;
+ }
+ 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 _13: u32;
+ let mut _14: u32;
+ scope 6 {
+ debug old => _13;
+ scope 7 {
+ }
+ }
+ scope 8 (inlined cmp::impls::<impl PartialOrd for u32>::lt) {
+ debug self => _7;
+ debug other => _8;
+ let mut _9: u32;
+ let mut _10: 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 = move _4;
+ goto -> bb1;
+ }
+
+ bb1: {
+ StorageLive(_12);
+ _6 = &mut _5;
+ StorageLive(_13);
+ StorageLive(_11);
+ StorageLive(_7);
+ _7 = &((*_6).0: u32);
+ StorageLive(_8);
+ _8 = &((*_6).1: u32);
+ StorageLive(_9);
+ _9 = (*_7);
+ StorageLive(_10);
+ _10 = (*_8);
+ _11 = Lt(move _9, move _10);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_7);
+ switchInt(move _11) -> [0: bb2, otherwise: bb3];
+ }
+
+ bb2: {
+ _12 = Option::<u32>::None;
+ goto -> bb5;
+ }
+
+ bb3: {
+ _13 = ((*_6).0: u32);
+ StorageLive(_14);
+ _14 = <u32 as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind unreachable];
+ }
+
+ bb4: {
+ ((*_6).0: u32) = move _14;
+ StorageDead(_14);
+ _12 = Option::<u32>::Some(_13);
+ goto -> bb5;
+ }
+
+ bb5: {
+ StorageDead(_11);
+ StorageDead(_13);
+ _15 = discriminant(_12);
+ switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10];
+ }
+
+ bb6: {
+ StorageDead(_12);
+ StorageDead(_5);
+ drop(_3) -> [return: bb7, unwind unreachable];
+ }
+
+ bb7: {
+ return;
+ }
+
+ bb8: {
+ _16 = ((_12 as Some).0: u32);
+ StorageLive(_17);
+ _17 = &_3;
+ StorageLive(_18);
+ _18 = (_16,);
+ _19 = <impl Fn(u32) as Fn<(u32,)>>::call(move _17, move _18) -> [return: bb9, unwind unreachable];
+ }
+
+ bb9: {
+ StorageDead(_18);
+ StorageDead(_17);
+ StorageDead(_12);
+ goto -> bb1;
+ }
+
+ bb10: {
+ unreachable;
+ }
+}
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
new file mode 100644
index 000000000..fbe16dc3c
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,139 @@
+// MIR for `forward_loop` after PreCodegen
+
+fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
+ debug start => _1;
+ 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 _12: std::option::Option<u32>;
+ let mut _15: isize;
+ let mut _17: &impl Fn(u32);
+ let mut _18: (u32,);
+ let _19: ();
+ scope 1 {
+ debug iter => _5;
+ let _16: u32;
+ scope 2 {
+ debug x => _16;
+ }
+ 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 _13: u32;
+ let mut _14: u32;
+ scope 6 {
+ debug old => _13;
+ scope 7 {
+ }
+ }
+ scope 8 (inlined cmp::impls::<impl PartialOrd for u32>::lt) {
+ debug self => _7;
+ debug other => _8;
+ let mut _9: u32;
+ let mut _10: 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 = move _4;
+ goto -> bb1;
+ }
+
+ bb1: {
+ StorageLive(_12);
+ _6 = &mut _5;
+ StorageLive(_13);
+ StorageLive(_11);
+ StorageLive(_7);
+ _7 = &((*_6).0: u32);
+ StorageLive(_8);
+ _8 = &((*_6).1: u32);
+ StorageLive(_9);
+ _9 = (*_7);
+ StorageLive(_10);
+ _10 = (*_8);
+ _11 = Lt(move _9, move _10);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_7);
+ switchInt(move _11) -> [0: bb2, otherwise: bb3];
+ }
+
+ bb2: {
+ _12 = Option::<u32>::None;
+ goto -> bb5;
+ }
+
+ bb3: {
+ _13 = ((*_6).0: u32);
+ StorageLive(_14);
+ _14 = <u32 as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb11];
+ }
+
+ bb4: {
+ ((*_6).0: u32) = move _14;
+ StorageDead(_14);
+ _12 = Option::<u32>::Some(_13);
+ goto -> bb5;
+ }
+
+ bb5: {
+ StorageDead(_11);
+ StorageDead(_13);
+ _15 = discriminant(_12);
+ switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10];
+ }
+
+ bb6: {
+ StorageDead(_12);
+ StorageDead(_5);
+ drop(_3) -> [return: bb7, unwind continue];
+ }
+
+ bb7: {
+ return;
+ }
+
+ bb8: {
+ _16 = ((_12 as Some).0: u32);
+ StorageLive(_17);
+ _17 = &_3;
+ StorageLive(_18);
+ _18 = (_16,);
+ _19 = <impl Fn(u32) as Fn<(u32,)>>::call(move _17, move _18) -> [return: bb9, unwind: bb11];
+ }
+
+ bb9: {
+ StorageDead(_18);
+ StorageDead(_17);
+ StorageDead(_12);
+ goto -> bb1;
+ }
+
+ bb10: {
+ unreachable;
+ }
+
+ bb11 (cleanup): {
+ drop(_3) -> [return: bb12, unwind terminate];
+ }
+
+ bb12 (cleanup): {
+ resume;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.mir
deleted file mode 100644
index f45eabba2..000000000
--- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.mir
+++ /dev/null
@@ -1,95 +0,0 @@
-// MIR for `inclusive_loop` after PreCodegen
-
-fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
- debug start => _1; // in scope 0 at $DIR/range_iter.rs:+0:23: +0:28
- debug end => _2; // in scope 0 at $DIR/range_iter.rs:+0:35: +0:38
- debug f => _3; // in scope 0 at $DIR/range_iter.rs:+0:45: +0:46
- let mut _0: (); // return place in scope 0 at $DIR/range_iter.rs:+0:62: +0:62
- let mut _4: std::ops::RangeInclusive<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25
- let mut _5: std::ops::RangeInclusive<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25
- let _6: (); // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25
- let mut _7: std::option::Option<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25
- let mut _8: &mut std::ops::RangeInclusive<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25
- let mut _9: isize; // in scope 0 at $DIR/range_iter.rs:+1:5: +3:6
- let mut _11: &impl Fn(u32); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:10
- let mut _12: (u32,); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:13
- scope 1 {
- debug iter => _5; // in scope 1 at $DIR/range_iter.rs:+1:14: +1:25
- let _10: u32; // in scope 1 at $DIR/range_iter.rs:+1:9: +1:10
- scope 2 {
- debug x => _10; // in scope 2 at $DIR/range_iter.rs:+1:9: +1:10
- }
- scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { // at $DIR/range_iter.rs:28:14: 28:25
- debug self => _8; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
- }
- }
- scope 3 (inlined RangeInclusive::<u32>::new) { // at $DIR/range_iter.rs:28:14: 28:25
- debug start => _1; // in scope 3 at $SRC_DIR/core/src/ops/range.rs:LL:COL
- debug end => _2; // in scope 3 at $SRC_DIR/core/src/ops/range.rs:LL:COL
- }
- scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) { // at $DIR/range_iter.rs:28:14: 28:25
- debug self => _4; // in scope 4 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- }
-
- bb0: {
- _4 = RangeInclusive::<u32> { start: _1, end: _2, exhausted: const false }; // scope 3 at $SRC_DIR/core/src/ops/range.rs:LL:COL
- StorageLive(_5); // scope 0 at $DIR/range_iter.rs:+1:14: +1:25
- _5 = move _4; // scope 0 at $DIR/range_iter.rs:+1:14: +1:25
- goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6
- }
-
- bb1: {
- StorageLive(_7); // scope 1 at $DIR/range_iter.rs:+1:14: +1:25
- _8 = &mut _5; // scope 1 at $DIR/range_iter.rs:+1:14: +1:25
- _7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_8) -> [return: bb9, unwind: bb7]; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
- // mir::Constant
- // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL
- // + literal: Const { ty: for<'a> fn(&'a mut RangeInclusive<u32>) -> Option<<RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::Item> {<RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next}, val: Value(<ZST>) }
- }
-
- bb2: {
- _10 = ((_7 as Some).0: u32); // scope 1 at $DIR/range_iter.rs:+1:9: +1:10
- StorageLive(_11); // scope 2 at $DIR/range_iter.rs:+2:9: +2:10
- _11 = &_3; // scope 2 at $DIR/range_iter.rs:+2:9: +2:10
- StorageLive(_12); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13
- _12 = (_10,); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13
- _6 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb5, unwind: bb7]; // scope 2 at $DIR/range_iter.rs:+2:9: +2:13
- // mir::Constant
- // + span: $DIR/range_iter.rs:29:9: 29:10
- // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(u32), (u32,)) -> <impl Fn(u32) as FnOnce<(u32,)>>::Output {<impl Fn(u32) as Fn<(u32,)>>::call}, val: Value(<ZST>) }
- }
-
- bb3: {
- unreachable; // scope 1 at $DIR/range_iter.rs:+1:14: +1:25
- }
-
- bb4: {
- StorageDead(_7); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6
- StorageDead(_5); // scope 0 at $DIR/range_iter.rs:+3:5: +3:6
- drop(_3) -> bb6; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2
- }
-
- bb5: {
- StorageDead(_12); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13
- StorageDead(_11); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13
- StorageDead(_7); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6
- goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6
- }
-
- bb6: {
- return; // scope 0 at $DIR/range_iter.rs:+4:2: +4:2
- }
-
- bb7 (cleanup): {
- drop(_3) -> [return: bb8, unwind terminate]; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2
- }
-
- bb8 (cleanup): {
- resume; // scope 0 at $DIR/range_iter.rs:+0:1: +4:2
- }
-
- bb9: {
- _9 = discriminant(_7); // scope 1 at $DIR/range_iter.rs:+1:14: +1:25
- switchInt(move _9) -> [0: bb4, 1: bb2, otherwise: bb3]; // scope 1 at $DIR/range_iter.rs:+1:14: +1:25
- }
-}
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
new file mode 100644
index 000000000..9737c9a87
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,81 @@
+// MIR for `inclusive_loop` after PreCodegen
+
+fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
+ debug start => _1;
+ debug end => _2;
+ debug f => _3;
+ let mut _0: ();
+ let mut _4: std::ops::RangeInclusive<u32>;
+ let mut _5: std::ops::RangeInclusive<u32>;
+ let mut _6: &mut std::ops::RangeInclusive<u32>;
+ let mut _7: std::option::Option<u32>;
+ let mut _8: isize;
+ let mut _10: &impl Fn(u32);
+ let mut _11: (u32,);
+ let _12: ();
+ scope 1 {
+ debug iter => _5;
+ let _9: u32;
+ scope 2 {
+ 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: {
+ _4 = RangeInclusive::<u32> { start: _1, end: _2, exhausted: const false };
+ StorageLive(_5);
+ _5 = move _4;
+ goto -> bb1;
+ }
+
+ bb1: {
+ StorageLive(_7);
+ _6 = &mut _5;
+ _7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_6) -> [return: bb2, unwind unreachable];
+ }
+
+ bb2: {
+ _8 = discriminant(_7);
+ switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb7];
+ }
+
+ bb3: {
+ StorageDead(_7);
+ StorageDead(_5);
+ drop(_3) -> [return: bb4, unwind unreachable];
+ }
+
+ bb4: {
+ return;
+ }
+
+ bb5: {
+ _9 = ((_7 as Some).0: u32);
+ StorageLive(_10);
+ _10 = &_3;
+ StorageLive(_11);
+ _11 = (_9,);
+ _12 = <impl Fn(u32) as Fn<(u32,)>>::call(move _10, move _11) -> [return: bb6, unwind unreachable];
+ }
+
+ bb6: {
+ StorageDead(_11);
+ StorageDead(_10);
+ StorageDead(_7);
+ goto -> bb1;
+ }
+
+ bb7: {
+ unreachable;
+ }
+}
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
new file mode 100644
index 000000000..04d6da1d9
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,89 @@
+// MIR for `inclusive_loop` after PreCodegen
+
+fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
+ debug start => _1;
+ debug end => _2;
+ debug f => _3;
+ let mut _0: ();
+ let mut _4: std::ops::RangeInclusive<u32>;
+ let mut _5: std::ops::RangeInclusive<u32>;
+ let mut _6: &mut std::ops::RangeInclusive<u32>;
+ let mut _7: std::option::Option<u32>;
+ let mut _8: isize;
+ let mut _10: &impl Fn(u32);
+ let mut _11: (u32,);
+ let _12: ();
+ scope 1 {
+ debug iter => _5;
+ let _9: u32;
+ scope 2 {
+ 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: {
+ _4 = RangeInclusive::<u32> { start: _1, end: _2, exhausted: const false };
+ StorageLive(_5);
+ _5 = move _4;
+ goto -> bb1;
+ }
+
+ bb1: {
+ StorageLive(_7);
+ _6 = &mut _5;
+ _7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_6) -> [return: bb2, unwind: bb8];
+ }
+
+ bb2: {
+ _8 = discriminant(_7);
+ switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb7];
+ }
+
+ bb3: {
+ StorageDead(_7);
+ StorageDead(_5);
+ drop(_3) -> [return: bb4, unwind continue];
+ }
+
+ bb4: {
+ return;
+ }
+
+ bb5: {
+ _9 = ((_7 as Some).0: u32);
+ StorageLive(_10);
+ _10 = &_3;
+ StorageLive(_11);
+ _11 = (_9,);
+ _12 = <impl Fn(u32) as Fn<(u32,)>>::call(move _10, move _11) -> [return: bb6, unwind: bb8];
+ }
+
+ bb6: {
+ StorageDead(_11);
+ StorageDead(_10);
+ StorageDead(_7);
+ goto -> bb1;
+ }
+
+ bb7: {
+ unreachable;
+ }
+
+ bb8 (cleanup): {
+ drop(_3) -> [return: bb9, unwind terminate];
+ }
+
+ bb9 (cleanup): {
+ resume;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.mir
deleted file mode 100644
index d013b1b94..000000000
--- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.mir
+++ /dev/null
@@ -1,20 +0,0 @@
-// MIR for `range_inclusive_iter_next` after PreCodegen
-
-fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> {
- debug it => _1; // in scope 0 at $DIR/range_iter.rs:+0:34: +0:36
- let mut _0: std::option::Option<u32>; // return place in scope 0 at $DIR/range_iter.rs:+0:67: +0:78
- scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { // at $DIR/range_iter.rs:16:8: 16:14
- debug self => _1; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL
- }
-
- bb0: {
- _0 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_1) -> bb1; // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL
- // mir::Constant
- // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL
- // + literal: Const { ty: for<'a> fn(&'a mut RangeInclusive<u32>) -> Option<<RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::Item> {<RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next}, val: Value(<ZST>) }
- }
-
- bb1: {
- return; // scope 0 at $DIR/range_iter.rs:+2:2: +2:2
- }
-}
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
new file mode 100644
index 000000000..0a71b6b2c
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,17 @@
+// MIR for `range_inclusive_iter_next` after PreCodegen
+
+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: {
+ _0 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_1) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ return;
+ }
+}
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
new file mode 100644
index 000000000..fd565fe75
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,17 @@
+// MIR for `range_inclusive_iter_next` after PreCodegen
+
+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: {
+ _0 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_1) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir
deleted file mode 100644
index cae46e2b0..000000000
--- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir
+++ /dev/null
@@ -1,20 +0,0 @@
-// MIR for `range_iter_next` after PreCodegen
-
-fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> {
- debug it => _1; // in scope 0 at $DIR/range_iter.rs:+0:24: +0:26
- let mut _0: std::option::Option<u32>; // return place in scope 0 at $DIR/range_iter.rs:+0:48: +0:59
- scope 1 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { // at $DIR/range_iter.rs:11:8: 11:14
- debug self => _1; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL
- }
-
- bb0: {
- _0 = <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next(_1) -> bb1; // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL
- // mir::Constant
- // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL
- // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<u32>) -> Option<<std::ops::Range<u32> as iter::range::RangeIteratorImpl>::Item> {<std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next}, val: Value(<ZST>) }
- }
-
- bb1: {
- return; // scope 0 at $DIR/range_iter.rs:+2:2: +2:2
- }
-}
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
new file mode 100644
index 000000000..1dfd00bf3
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,71 @@
+// MIR for `range_iter_next` after PreCodegen
+
+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;
+ scope 3 {
+ debug old => _7;
+ scope 4 {
+ }
+ }
+ scope 5 (inlined cmp::impls::<impl PartialOrd for u32>::lt) {
+ debug self => _2;
+ debug other => _3;
+ let mut _4: u32;
+ let mut _5: u32;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_7);
+ StorageLive(_6);
+ StorageLive(_2);
+ _2 = &((*_1).0: u32);
+ StorageLive(_3);
+ _3 = &((*_1).1: u32);
+ StorageLive(_4);
+ _4 = (*_2);
+ StorageLive(_5);
+ _5 = (*_3);
+ _6 = Lt(move _4, move _5);
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageDead(_3);
+ StorageDead(_2);
+ switchInt(move _6) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _0 = Option::<u32>::None;
+ goto -> bb4;
+ }
+
+ bb2: {
+ _7 = ((*_1).0: u32);
+ StorageLive(_8);
+ _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb3, unwind unreachable];
+ }
+
+ bb3: {
+ ((*_1).0: u32) = move _8;
+ StorageDead(_8);
+ _0 = Option::<u32>::Some(_7);
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageDead(_6);
+ StorageDead(_7);
+ 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
new file mode 100644
index 000000000..65870f693
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,71 @@
+// MIR for `range_iter_next` after PreCodegen
+
+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;
+ scope 3 {
+ debug old => _7;
+ scope 4 {
+ }
+ }
+ scope 5 (inlined cmp::impls::<impl PartialOrd for u32>::lt) {
+ debug self => _2;
+ debug other => _3;
+ let mut _4: u32;
+ let mut _5: u32;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_7);
+ StorageLive(_6);
+ StorageLive(_2);
+ _2 = &((*_1).0: u32);
+ StorageLive(_3);
+ _3 = &((*_1).1: u32);
+ StorageLive(_4);
+ _4 = (*_2);
+ StorageLive(_5);
+ _5 = (*_3);
+ _6 = Lt(move _4, move _5);
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageDead(_3);
+ StorageDead(_2);
+ switchInt(move _6) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _0 = Option::<u32>::None;
+ goto -> bb4;
+ }
+
+ bb2: {
+ _7 = ((*_1).0: u32);
+ StorageLive(_8);
+ _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb3, unwind continue];
+ }
+
+ bb3: {
+ ((*_1).0: u32) = move _8;
+ StorageDead(_8);
+ _0 = Option::<u32>::Some(_7);
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageDead(_6);
+ StorageDead(_7);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/range_iter.rs b/tests/mir-opt/pre-codegen/range_iter.rs
index fe21d4dfd..cabd9419e 100644
--- a/tests/mir-opt/pre-codegen/range_iter.rs
+++ b/tests/mir-opt/pre-codegen/range_iter.rs
@@ -1,6 +1,7 @@
// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2
// only-64bit
// ignore-debug
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![crate_type = "lib"]
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 986ab3588..df45b1589 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
@@ -1,56 +1,56 @@
// MIR for `ezmap` after PreCodegen
fn ezmap(_1: Option<i32>) -> Option<i32> {
- debug x => _1; // in scope 0 at $DIR/simple_option_map.rs:+0:14: +0:15
- let mut _0: std::option::Option<i32>; // return place in scope 0 at $DIR/simple_option_map.rs:+0:33: +0:44
- let mut _6: i32; // in scope 0 at $DIR/simple_option_map.rs:11:25: 11:29
- scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map.rs:18:12: 18:15]>) { // at $DIR/simple_option_map.rs:18:5: 18:22
- debug slf => _1; // in scope 1 at $DIR/simple_option_map.rs:6:17: 6:20
- debug f => const ZeroSized: [closure@$DIR/simple_option_map.rs:18:12: 18:15]; // in scope 1 at $DIR/simple_option_map.rs:6:33: 6:34
- let mut _2: isize; // in scope 1 at $DIR/simple_option_map.rs:11:9: 11:16
- let _3: i32; // in scope 1 at $DIR/simple_option_map.rs:11:14: 11:15
- let mut _4: i32; // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29
- let mut _5: (i32,); // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29
+ debug x => _1;
+ let mut _0: std::option::Option<i32>;
+ let mut _5: i32;
+ scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map.rs:18:12: 18:15]>) {
+ debug slf => _1;
+ debug f => const ZeroSized: [closure@$DIR/simple_option_map.rs:18:12: 18:15];
+ let mut _2: isize;
+ let _3: i32;
+ let mut _4: (i32,);
+ let mut _6: i32;
scope 2 {
- debug x => _3; // in scope 2 at $DIR/simple_option_map.rs:11:14: 11:15
- scope 3 (inlined ezmap::{closure#0}) { // at $DIR/simple_option_map.rs:11:25: 11:29
- debug n => _6; // in scope 3 at $DIR/simple_option_map.rs:+1:13: +1:14
+ debug x => _3;
+ scope 3 (inlined ezmap::{closure#0}) {
+ debug n => _5;
}
}
}
bb0: {
- StorageLive(_3); // scope 0 at $DIR/simple_option_map.rs:+1:5: +1:22
- _2 = discriminant(_1); // scope 1 at $DIR/simple_option_map.rs:10:11: 10:14
- switchInt(move _2) -> [0: bb1, 1: bb3, otherwise: bb2]; // scope 1 at $DIR/simple_option_map.rs:10:5: 10:14
+ StorageLive(_3);
+ _2 = discriminant(_1);
+ switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4];
}
bb1: {
- _0 = Option::<i32>::None; // scope 1 at $DIR/simple_option_map.rs:12:17: 12:21
- goto -> bb4; // scope 1 at $DIR/simple_option_map.rs:12:17: 12:21
+ _0 = Option::<i32>::None;
+ goto -> bb3;
}
bb2: {
- unreachable; // scope 1 at $DIR/simple_option_map.rs:10:11: 10:14
+ _3 = ((_1 as Some).0: i32);
+ StorageLive(_6);
+ StorageLive(_4);
+ _4 = (move _3,);
+ StorageLive(_5);
+ _5 = move (_4.0: i32);
+ _6 = Add(_5, const 1_i32);
+ StorageDead(_5);
+ StorageDead(_4);
+ _0 = Option::<i32>::Some(move _6);
+ StorageDead(_6);
+ goto -> bb3;
}
bb3: {
- _3 = ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map.rs:11:14: 11:15
- StorageLive(_4); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29
- StorageLive(_5); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29
- _5 = (move _3,); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29
- StorageLive(_6); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29
- _6 = move (_5.0: i32); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29
- _4 = Add(_6, const 1_i32); // scope 3 at $DIR/simple_option_map.rs:+1:16: +1:21
- StorageDead(_6); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29
- StorageDead(_5); // scope 2 at $DIR/simple_option_map.rs:11:28: 11:29
- _0 = Option::<i32>::Some(move _4); // scope 2 at $DIR/simple_option_map.rs:11:20: 11:30
- StorageDead(_4); // scope 2 at $DIR/simple_option_map.rs:11:29: 11:30
- goto -> bb4; // scope 1 at $DIR/simple_option_map.rs:14:1: 14:2
+ StorageDead(_3);
+ return;
}
bb4: {
- StorageDead(_3); // scope 0 at $DIR/simple_option_map.rs:+1:5: +1:22
- return; // scope 0 at $DIR/simple_option_map.rs:+2:2: +2:2
+ unreachable;
}
}
diff --git a/tests/mir-opt/pre-codegen/slice_filter.rs b/tests/mir-opt/pre-codegen/slice_filter.rs
new file mode 100644
index 000000000..aba951acd
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_filter.rs
@@ -0,0 +1,15 @@
+// compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2
+// ignore-debug: standard library debug assertions add a panic that breaks this optimization
+
+#![crate_type = "lib"]
+
+pub fn variant_a(input: &[(usize, usize, usize, usize)]) -> usize {
+ input.iter().filter(|(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count()
+}
+
+pub fn variant_b(input: &[(usize, usize, usize, usize)]) -> usize {
+ input.iter().filter(|&&(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count()
+}
+
+// EMIT_MIR slice_filter.variant_a-{closure#0}.PreCodegen.after.mir
+// EMIT_MIR slice_filter.variant_b-{closure#0}.PreCodegen.after.mir
diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir
new file mode 100644
index 000000000..499bee2ae
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir
@@ -0,0 +1,231 @@
+// MIR for `variant_a::{closure#0}` after PreCodegen
+
+fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2: &&(usize, usize, usize, usize)) -> bool {
+ let mut _0: bool;
+ let mut _3: &(usize, usize, usize, usize);
+ let _4: &usize;
+ let mut _5: &(usize, usize, usize, usize);
+ let _6: &usize;
+ let mut _7: &(usize, usize, usize, usize);
+ let _8: &usize;
+ let mut _9: &(usize, usize, usize, usize);
+ let _10: &usize;
+ let mut _11: &&usize;
+ let _12: &usize;
+ let mut _13: &&usize;
+ let mut _18: bool;
+ let mut _19: bool;
+ let mut _20: &&usize;
+ let _21: &usize;
+ let mut _22: &&usize;
+ let mut _27: bool;
+ let mut _28: &&usize;
+ let _29: &usize;
+ let mut _30: &&usize;
+ let mut _35: bool;
+ let mut _36: bool;
+ let mut _37: &&usize;
+ let _38: &usize;
+ let mut _39: &&usize;
+ let mut _44: bool;
+ scope 1 {
+ debug a => _4;
+ debug b => _6;
+ debug c => _8;
+ debug d => _10;
+ scope 2 (inlined cmp::impls::<impl PartialOrd for &usize>::le) {
+ debug self => _11;
+ debug other => _13;
+ let mut _14: &usize;
+ let mut _15: &usize;
+ scope 3 (inlined cmp::impls::<impl PartialOrd for usize>::le) {
+ debug self => _14;
+ debug other => _15;
+ let mut _16: usize;
+ let mut _17: usize;
+ }
+ }
+ scope 4 (inlined cmp::impls::<impl PartialOrd for &usize>::le) {
+ debug self => _28;
+ debug other => _30;
+ let mut _31: &usize;
+ let mut _32: &usize;
+ scope 5 (inlined cmp::impls::<impl PartialOrd for usize>::le) {
+ debug self => _31;
+ debug other => _32;
+ let mut _33: usize;
+ let mut _34: usize;
+ }
+ }
+ scope 6 (inlined cmp::impls::<impl PartialOrd for &usize>::le) {
+ debug self => _20;
+ debug other => _22;
+ let mut _23: &usize;
+ let mut _24: &usize;
+ scope 7 (inlined cmp::impls::<impl PartialOrd for usize>::le) {
+ debug self => _23;
+ debug other => _24;
+ let mut _25: usize;
+ let mut _26: usize;
+ }
+ }
+ scope 8 (inlined cmp::impls::<impl PartialOrd for &usize>::le) {
+ debug self => _37;
+ debug other => _39;
+ let mut _40: &usize;
+ let mut _41: &usize;
+ scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::le) {
+ debug self => _40;
+ debug other => _41;
+ let mut _42: usize;
+ let mut _43: usize;
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_4);
+ _3 = deref_copy (*_2);
+ _4 = &((*_3).0: usize);
+ StorageLive(_6);
+ _5 = deref_copy (*_2);
+ _6 = &((*_5).1: usize);
+ StorageLive(_8);
+ _7 = deref_copy (*_2);
+ _8 = &((*_7).2: usize);
+ StorageLive(_10);
+ _9 = deref_copy (*_2);
+ _10 = &((*_9).3: usize);
+ StorageLive(_19);
+ StorageLive(_18);
+ StorageLive(_11);
+ _11 = &_4;
+ StorageLive(_13);
+ StorageLive(_12);
+ _12 = _8;
+ _13 = &_12;
+ _14 = deref_copy (*_11);
+ _15 = deref_copy (*_13);
+ StorageLive(_16);
+ _16 = (*_14);
+ StorageLive(_17);
+ _17 = (*_15);
+ _18 = Le(move _16, move _17);
+ StorageDead(_17);
+ StorageDead(_16);
+ StorageDead(_12);
+ StorageDead(_13);
+ StorageDead(_11);
+ switchInt(move _18) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _19 = const false;
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_27);
+ StorageLive(_20);
+ _20 = &_10;
+ StorageLive(_22);
+ StorageLive(_21);
+ _21 = _6;
+ _22 = &_21;
+ _23 = deref_copy (*_20);
+ _24 = deref_copy (*_22);
+ StorageLive(_25);
+ _25 = (*_23);
+ StorageLive(_26);
+ _26 = (*_24);
+ _27 = Le(move _25, move _26);
+ StorageDead(_26);
+ StorageDead(_25);
+ StorageDead(_21);
+ StorageDead(_22);
+ StorageDead(_20);
+ _19 = move _27;
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_27);
+ StorageDead(_18);
+ switchInt(move _19) -> [0: bb4, otherwise: bb8];
+ }
+
+ bb4: {
+ StorageLive(_36);
+ StorageLive(_35);
+ StorageLive(_28);
+ _28 = &_8;
+ StorageLive(_30);
+ StorageLive(_29);
+ _29 = _4;
+ _30 = &_29;
+ _31 = deref_copy (*_28);
+ _32 = deref_copy (*_30);
+ StorageLive(_33);
+ _33 = (*_31);
+ StorageLive(_34);
+ _34 = (*_32);
+ _35 = Le(move _33, move _34);
+ StorageDead(_34);
+ StorageDead(_33);
+ StorageDead(_29);
+ StorageDead(_30);
+ StorageDead(_28);
+ switchInt(move _35) -> [0: bb5, otherwise: bb6];
+ }
+
+ bb5: {
+ _36 = const false;
+ goto -> bb7;
+ }
+
+ bb6: {
+ StorageLive(_44);
+ StorageLive(_37);
+ _37 = &_6;
+ StorageLive(_39);
+ StorageLive(_38);
+ _38 = _10;
+ _39 = &_38;
+ _40 = deref_copy (*_37);
+ _41 = deref_copy (*_39);
+ StorageLive(_42);
+ _42 = (*_40);
+ StorageLive(_43);
+ _43 = (*_41);
+ _44 = Le(move _42, move _43);
+ StorageDead(_43);
+ StorageDead(_42);
+ StorageDead(_38);
+ StorageDead(_39);
+ StorageDead(_37);
+ _36 = move _44;
+ goto -> bb7;
+ }
+
+ bb7: {
+ StorageDead(_44);
+ StorageDead(_35);
+ _0 = move _36;
+ goto -> bb9;
+ }
+
+ bb8: {
+ _0 = const true;
+ goto -> bb9;
+ }
+
+ bb9: {
+ StorageDead(_36);
+ StorageDead(_19);
+ StorageDead(_10);
+ StorageDead(_8);
+ StorageDead(_6);
+ StorageDead(_4);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir
new file mode 100644
index 000000000..bab9f0b58
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir
@@ -0,0 +1,95 @@
+// MIR for `variant_b::{closure#0}` after PreCodegen
+
+fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:11:25: 11:41], _2: &&(usize, usize, usize, usize)) -> bool {
+ let mut _0: bool;
+ let mut _3: &(usize, usize, usize, usize);
+ let _4: usize;
+ let mut _5: &(usize, usize, usize, usize);
+ let _6: usize;
+ let mut _7: &(usize, usize, usize, usize);
+ let _8: usize;
+ let mut _9: &(usize, usize, usize, usize);
+ let _10: usize;
+ let mut _11: bool;
+ let mut _12: bool;
+ let mut _13: bool;
+ let mut _14: bool;
+ let mut _15: bool;
+ let mut _16: bool;
+ scope 1 {
+ debug a => _4;
+ debug b => _6;
+ debug c => _8;
+ debug d => _10;
+ }
+
+ bb0: {
+ _3 = deref_copy (*_2);
+ _4 = ((*_3).0: usize);
+ _5 = deref_copy (*_2);
+ _6 = ((*_5).1: usize);
+ _7 = deref_copy (*_2);
+ _8 = ((*_7).2: usize);
+ _9 = deref_copy (*_2);
+ _10 = ((*_9).3: usize);
+ StorageLive(_12);
+ StorageLive(_11);
+ _11 = Le(_4, _8);
+ switchInt(move _11) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _12 = const false;
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_13);
+ _13 = Le(_10, _6);
+ _12 = move _13;
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_13);
+ StorageDead(_11);
+ switchInt(move _12) -> [0: bb4, otherwise: bb8];
+ }
+
+ bb4: {
+ StorageLive(_15);
+ StorageLive(_14);
+ _14 = Le(_8, _4);
+ switchInt(move _14) -> [0: bb5, otherwise: bb6];
+ }
+
+ bb5: {
+ _15 = const false;
+ goto -> bb7;
+ }
+
+ bb6: {
+ StorageLive(_16);
+ _16 = Le(_6, _10);
+ _15 = move _16;
+ goto -> bb7;
+ }
+
+ bb7: {
+ StorageDead(_16);
+ StorageDead(_14);
+ _0 = move _15;
+ goto -> bb9;
+ }
+
+ bb8: {
+ _0 = const true;
+ goto -> bb9;
+ }
+
+ bb9: {
+ StorageDead(_15);
+ StorageDead(_12);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_index.rs b/tests/mir-opt/pre-codegen/slice_index.rs
index 44b456276..d80bff50c 100644
--- a/tests/mir-opt/pre-codegen/slice_index.rs
+++ b/tests/mir-opt/pre-codegen/slice_index.rs
@@ -1,6 +1,7 @@
// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2
// only-64bit
// ignore-debug
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![crate_type = "lib"]
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir
deleted file mode 100644
index 715a1e3fc..000000000
--- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir
+++ /dev/null
@@ -1,105 +0,0 @@
-// MIR for `slice_get_mut_usize` after PreCodegen
-
-fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
- debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:28: +0:33
- debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:47: +0:52
- let mut _0: std::option::Option<&mut u32>; // return place in scope 0 at $DIR/slice_index.rs:+0:64: +0:80
- scope 1 (inlined core::slice::<impl [u32]>::get_mut::<usize>) { // at $DIR/slice_index.rs:16:11: 16:25
- debug self => _1; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- debug index => _2; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- scope 2 (inlined <usize as SliceIndex<[u32]>>::get_mut) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- debug self => _2; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug slice => _1; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _3: bool; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _4: usize; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _5: &[u32]; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _6: &mut u32; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _7: *mut u32; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _8: *mut [u32]; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- scope 3 {
- scope 4 (inlined <usize as SliceIndex<[u32]>>::get_unchecked_mut) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug self => _2; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug slice => _8; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _9: *mut u32; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _10: usize; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- let mut _11: *mut [u32]; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- scope 5 {
- debug this => _2; // in scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- scope 6 {
- scope 7 (inlined <usize as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- debug this => _10; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- debug slice => _11; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug self => _11; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- let mut _12: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 9 (inlined std::ptr::metadata::<[u32]>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug ptr => _12; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- scope 10 {
- }
- }
- }
- }
- scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug self => _8; // in scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- }
- scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug self => _9; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug count => _2; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 13 {
- }
- }
- }
- }
- }
- }
- }
- }
-
- bb0: {
- StorageLive(_6); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_3); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_4); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_5); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _5 = &(*_1); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _4 = Len((*_5)); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_5); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _3 = Lt(_2, move _4); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_4); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- switchInt(move _3) -> [0: bb2, otherwise: bb1]; // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- }
-
- bb1: {
- StorageLive(_7); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_8); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _8 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_10); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_11); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _9 = _8 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- _7 = Offset(_9, _2); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- StorageDead(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_11); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_10); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_8); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _6 = &mut (*_7); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _0 = Option::<&mut u32>::Some(_6); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_7); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- goto -> bb3; // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- }
-
- bb2: {
- _0 = const Option::<&mut u32>::None; // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- // mir::Constant
- // + span: no-location
- // + literal: Const { ty: Option<&mut u32>, val: Value(Scalar(0x0000000000000000)) }
- goto -> bb3; // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- }
-
- bb3: {
- StorageDead(_3); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_6); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2
- }
-}
diff --git a/tests/mir-opt/pre-codegen/slice_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
new file mode 100644
index 000000000..43efe034d
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,102 @@
+// MIR for `slice_get_mut_usize` after PreCodegen
+
+fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
+ debug slice => _1;
+ 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;
+ scope 2 (inlined <usize as SliceIndex<[u32]>>::get_mut) {
+ debug self => _2;
+ debug slice => _1;
+ let mut _3: &[u32];
+ let mut _4: usize;
+ let mut _5: bool;
+ let mut _6: *mut [u32];
+ let mut _8: *mut u32;
+ let mut _9: &mut u32;
+ scope 3 {
+ scope 4 (inlined <usize as SliceIndex<[u32]>>::get_unchecked_mut) {
+ debug self => _2;
+ debug slice => _6;
+ let mut _7: *mut u32;
+ let mut _10: usize;
+ let mut _11: *mut [u32];
+ scope 5 {
+ debug this => _2;
+ scope 6 {
+ scope 7 (inlined <usize as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) {
+ debug this => _10;
+ debug slice => _11;
+ scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
+ debug self => _11;
+ let mut _12: *const [u32];
+ scope 9 (inlined std::ptr::metadata::<[u32]>) {
+ debug ptr => _12;
+ scope 10 {
+ }
+ }
+ }
+ }
+ scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
+ debug self => _6;
+ }
+ scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
+ debug self => _7;
+ debug count => _2;
+ scope 13 {
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_9);
+ StorageLive(_5);
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = &(*_1);
+ _4 = Len((*_3));
+ StorageDead(_3);
+ _5 = Lt(_2, move _4);
+ StorageDead(_4);
+ switchInt(move _5) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _0 = const Option::<&mut u32>::None;
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_8);
+ StorageLive(_6);
+ _6 = &raw mut (*_1);
+ StorageLive(_10);
+ StorageLive(_11);
+ StorageLive(_12);
+ StorageLive(_7);
+ _7 = _6 as *mut u32 (PtrToPtr);
+ _8 = Offset(_7, _2);
+ StorageDead(_7);
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_10);
+ StorageDead(_6);
+ _9 = &mut (*_8);
+ _0 = Option::<&mut u32>::Some(_9);
+ StorageDead(_8);
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_5);
+ StorageDead(_9);
+ return;
+ }
+}
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
new file mode 100644
index 000000000..43efe034d
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,102 @@
+// MIR for `slice_get_mut_usize` after PreCodegen
+
+fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
+ debug slice => _1;
+ 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;
+ scope 2 (inlined <usize as SliceIndex<[u32]>>::get_mut) {
+ debug self => _2;
+ debug slice => _1;
+ let mut _3: &[u32];
+ let mut _4: usize;
+ let mut _5: bool;
+ let mut _6: *mut [u32];
+ let mut _8: *mut u32;
+ let mut _9: &mut u32;
+ scope 3 {
+ scope 4 (inlined <usize as SliceIndex<[u32]>>::get_unchecked_mut) {
+ debug self => _2;
+ debug slice => _6;
+ let mut _7: *mut u32;
+ let mut _10: usize;
+ let mut _11: *mut [u32];
+ scope 5 {
+ debug this => _2;
+ scope 6 {
+ scope 7 (inlined <usize as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) {
+ debug this => _10;
+ debug slice => _11;
+ scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
+ debug self => _11;
+ let mut _12: *const [u32];
+ scope 9 (inlined std::ptr::metadata::<[u32]>) {
+ debug ptr => _12;
+ scope 10 {
+ }
+ }
+ }
+ }
+ scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
+ debug self => _6;
+ }
+ scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
+ debug self => _7;
+ debug count => _2;
+ scope 13 {
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_9);
+ StorageLive(_5);
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = &(*_1);
+ _4 = Len((*_3));
+ StorageDead(_3);
+ _5 = Lt(_2, move _4);
+ StorageDead(_4);
+ switchInt(move _5) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _0 = const Option::<&mut u32>::None;
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_8);
+ StorageLive(_6);
+ _6 = &raw mut (*_1);
+ StorageLive(_10);
+ StorageLive(_11);
+ StorageLive(_12);
+ StorageLive(_7);
+ _7 = _6 as *mut u32 (PtrToPtr);
+ _8 = Offset(_7, _2);
+ StorageDead(_7);
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_10);
+ StorageDead(_6);
+ _9 = &mut (*_8);
+ _0 = Option::<&mut u32>::Some(_9);
+ StorageDead(_8);
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_5);
+ StorageDead(_9);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir
deleted file mode 100644
index 7a10b929e..000000000
--- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir
+++ /dev/null
@@ -1,134 +0,0 @@
-// MIR for `slice_get_unchecked_mut_range` after PreCodegen
-
-fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> &mut [u32] {
- debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:45: +0:50
- debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:64: +0:69
- let mut _0: &mut [u32]; // return place in scope 0 at $DIR/slice_index.rs:+0:88: +0:98
- scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) { // at $DIR/slice_index.rs:26:11: 26:35
- debug self => _1; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- debug index => _2; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- let mut _3: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- let mut _4: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- scope 2 {
- scope 3 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- debug self => _2; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug slice => _4; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let _5: std::ops::Range<usize>; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _7: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _8: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _9: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _10: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _11: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _12: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let mut _13: std::ops::Range<usize>; // in scope 3 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- let mut _14: *mut [u32]; // in scope 3 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- scope 4 {
- debug this => _5; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- scope 5 {
- let _6: usize; // in scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- scope 6 {
- debug new_len => _6; // in scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug self => _4; // in scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- }
- scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug self => _10; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug count => _11; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 13 {
- }
- }
- scope 14 (inlined slice_from_raw_parts_mut::<u32>) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug data => _9; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- debug len => _12; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- let mut _16: *mut (); // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- scope 15 (inlined ptr::mut_ptr::<impl *mut u32>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- debug self => _9; // in scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- }
- scope 16 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { // at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- debug data_address => _16; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- debug metadata => _12; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- let mut _17: std::ptr::metadata::PtrRepr<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- let mut _18: std::ptr::metadata::PtrComponents<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- let mut _19: *const (); // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- scope 17 {
- }
- }
- }
- }
- scope 7 (inlined <std::ops::Range<usize> as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- debug this => _13; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- debug slice => _14; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug self => _14; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- let mut _15: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 9 (inlined std::ptr::metadata::<[u32]>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug ptr => _15; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- scope 10 {
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- bb0: {
- StorageLive(_3); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_4); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- _4 = &raw mut (*_1); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_5); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_13); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_14); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_6); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_7); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _7 = (_2.1: usize); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_8); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _8 = (_2.0: usize); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _6 = unchecked_sub::<usize>(move _7, move _8) -> [return: bb1, unwind unreachable]; // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- // mir::Constant
- // + span: $SRC_DIR/core/src/slice/index.rs:LL:COL
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize, usize) -> usize {unchecked_sub::<usize>}, val: Value(<ZST>) }
- }
-
- bb1: {
- StorageDead(_8); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_7); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_10); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _10 = _4 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- StorageLive(_11); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _11 = (_2.0: usize); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _9 = Offset(_10, _11); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- StorageDead(_11); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_10); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_12); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _12 = _6; // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageLive(_16); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- _16 = _9 as *mut () (PtrToPtr); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- StorageLive(_17); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- StorageLive(_18); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- StorageLive(_19); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- _19 = _16 as *const () (Pointer(MutToConstPointer)); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- _18 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _19, metadata: _12 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- StorageDead(_19); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- _17 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _18 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- StorageDead(_18); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- _3 = (_17.1: *mut [u32]); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- StorageDead(_17); // scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL
- StorageDead(_16); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- StorageDead(_12); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_6); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageDead(_14); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageDead(_13); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageDead(_5); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageDead(_4); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- _0 = &mut (*_3); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageDead(_3); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2
- }
-}
diff --git a/tests/mir-opt/pre-codegen/slice_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
new file mode 100644
index 000000000..0c44873b7
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,103 @@
+// MIR for `slice_get_unchecked_mut_range` after PreCodegen
+
+fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> &mut [u32] {
+ debug slice => _1;
+ 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 _14: *mut [u32];
+ scope 2 {
+ scope 3 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) {
+ debug self => _2;
+ debug slice => _3;
+ let mut _4: usize;
+ let mut _5: usize;
+ let mut _7: *mut u32;
+ let mut _8: usize;
+ let mut _9: *mut u32;
+ let _15: std::ops::Range<usize>;
+ scope 4 {
+ debug this => _15;
+ scope 5 {
+ let _6: usize;
+ scope 6 {
+ debug new_len => _6;
+ scope 7 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
+ debug self => _3;
+ }
+ scope 8 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
+ debug self => _7;
+ debug count => _8;
+ scope 9 {
+ }
+ }
+ scope 10 (inlined slice_from_raw_parts_mut::<u32>) {
+ debug data => _9;
+ debug len => _6;
+ let mut _10: *mut ();
+ scope 11 (inlined ptr::mut_ptr::<impl *mut u32>::cast::<()>) {
+ debug self => _9;
+ }
+ scope 12 (inlined std::ptr::from_raw_parts_mut::<[u32]>) {
+ debug data_address => _10;
+ debug metadata => _6;
+ let mut _11: *const ();
+ let mut _12: std::ptr::metadata::PtrComponents<[u32]>;
+ let mut _13: std::ptr::metadata::PtrRepr<[u32]>;
+ scope 13 {
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_14);
+ StorageLive(_3);
+ _3 = &raw mut (*_1);
+ StorageLive(_15);
+ StorageLive(_6);
+ StorageLive(_4);
+ _4 = (_2.1: usize);
+ StorageLive(_5);
+ _5 = (_2.0: usize);
+ _6 = SubUnchecked(move _4, move _5);
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageLive(_9);
+ StorageLive(_7);
+ _7 = _3 as *mut u32 (PtrToPtr);
+ StorageLive(_8);
+ _8 = (_2.0: usize);
+ _9 = Offset(_7, _8);
+ StorageDead(_8);
+ StorageDead(_7);
+ StorageLive(_10);
+ _10 = _9 as *mut () (PtrToPtr);
+ StorageLive(_13);
+ StorageLive(_12);
+ StorageLive(_11);
+ _11 = _10 as *const () (PointerCoercion(MutToConstPointer));
+ _12 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _11, metadata: _6 };
+ StorageDead(_11);
+ _13 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _12 };
+ StorageDead(_12);
+ _14 = (_13.1: *mut [u32]);
+ StorageDead(_13);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_6);
+ StorageDead(_15);
+ StorageDead(_3);
+ _0 = &mut (*_14);
+ StorageDead(_14);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir
new file mode 100644
index 000000000..0c44873b7
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,103 @@
+// MIR for `slice_get_unchecked_mut_range` after PreCodegen
+
+fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> &mut [u32] {
+ debug slice => _1;
+ 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 _14: *mut [u32];
+ scope 2 {
+ scope 3 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) {
+ debug self => _2;
+ debug slice => _3;
+ let mut _4: usize;
+ let mut _5: usize;
+ let mut _7: *mut u32;
+ let mut _8: usize;
+ let mut _9: *mut u32;
+ let _15: std::ops::Range<usize>;
+ scope 4 {
+ debug this => _15;
+ scope 5 {
+ let _6: usize;
+ scope 6 {
+ debug new_len => _6;
+ scope 7 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
+ debug self => _3;
+ }
+ scope 8 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
+ debug self => _7;
+ debug count => _8;
+ scope 9 {
+ }
+ }
+ scope 10 (inlined slice_from_raw_parts_mut::<u32>) {
+ debug data => _9;
+ debug len => _6;
+ let mut _10: *mut ();
+ scope 11 (inlined ptr::mut_ptr::<impl *mut u32>::cast::<()>) {
+ debug self => _9;
+ }
+ scope 12 (inlined std::ptr::from_raw_parts_mut::<[u32]>) {
+ debug data_address => _10;
+ debug metadata => _6;
+ let mut _11: *const ();
+ let mut _12: std::ptr::metadata::PtrComponents<[u32]>;
+ let mut _13: std::ptr::metadata::PtrRepr<[u32]>;
+ scope 13 {
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_14);
+ StorageLive(_3);
+ _3 = &raw mut (*_1);
+ StorageLive(_15);
+ StorageLive(_6);
+ StorageLive(_4);
+ _4 = (_2.1: usize);
+ StorageLive(_5);
+ _5 = (_2.0: usize);
+ _6 = SubUnchecked(move _4, move _5);
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageLive(_9);
+ StorageLive(_7);
+ _7 = _3 as *mut u32 (PtrToPtr);
+ StorageLive(_8);
+ _8 = (_2.0: usize);
+ _9 = Offset(_7, _8);
+ StorageDead(_8);
+ StorageDead(_7);
+ StorageLive(_10);
+ _10 = _9 as *mut () (PtrToPtr);
+ StorageLive(_13);
+ StorageLive(_12);
+ StorageLive(_11);
+ _11 = _10 as *const () (PointerCoercion(MutToConstPointer));
+ _12 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _11, metadata: _6 };
+ StorageDead(_11);
+ _13 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _12 };
+ StorageDead(_12);
+ _14 = (_13.1: *mut [u32]);
+ StorageDead(_13);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_6);
+ StorageDead(_15);
+ StorageDead(_3);
+ _0 = &mut (*_14);
+ StorageDead(_14);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.mir
deleted file mode 100644
index dcf79a4a4..000000000
--- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.mir
+++ /dev/null
@@ -1,26 +0,0 @@
-// MIR for `slice_index_range` after PreCodegen
-
-fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] {
- debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:26: +0:31
- debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:41: +0:46
- let mut _0: &[u32]; // return place in scope 0 at $DIR/slice_index.rs:+0:65: +0:71
- scope 1 (inlined #[track_caller] core::slice::index::<impl Index<std::ops::Range<usize>> for [u32]>::index) { // at $DIR/slice_index.rs:21:6: 21:18
- debug self => _1; // in scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- debug index => _2; // in scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- let _3: &[u32]; // in scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- }
-
- bb0: {
- StorageLive(_3); // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- _3 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, _1) -> bb1; // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- // mir::Constant
- // + span: $SRC_DIR/core/src/slice/index.rs:LL:COL
- // + literal: Const { ty: for<'a> fn(std::ops::Range<usize>, &'a [u32]) -> &'a <std::ops::Range<usize> as SliceIndex<[u32]>>::Output {<std::ops::Range<usize> as SliceIndex<[u32]>>::index}, val: Value(<ZST>) }
- }
-
- bb1: {
- _0 = _3; // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- StorageDead(_3); // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
- return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2
- }
-}
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
new file mode 100644
index 000000000..aff718566
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,23 @@
+// MIR for `slice_index_range` after PreCodegen
+
+fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] {
+ debug slice => _1;
+ 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;
+ let _3: &[u32];
+ }
+
+ bb0: {
+ StorageLive(_3);
+ _3 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, _1) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ _0 = _3;
+ StorageDead(_3);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir
new file mode 100644
index 000000000..a6b931d2c
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,23 @@
+// MIR for `slice_index_range` after PreCodegen
+
+fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] {
+ debug slice => _1;
+ 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;
+ let _3: &[u32];
+ }
+
+ bb0: {
+ StorageLive(_3);
+ _3 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, _1) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ _0 = _3;
+ StorageDead(_3);
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.mir
deleted file mode 100644
index 6cc0ee057..000000000
--- a/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.mir
+++ /dev/null
@@ -1,20 +0,0 @@
-// MIR for `slice_index_usize` after PreCodegen
-
-fn slice_index_usize(_1: &[u32], _2: usize) -> u32 {
- debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:26: +0:31
- debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:41: +0:46
- let mut _0: u32; // return place in scope 0 at $DIR/slice_index.rs:+0:58: +0:61
- let mut _3: usize; // in scope 0 at $DIR/slice_index.rs:+1:5: +1:17
- let mut _4: bool; // in scope 0 at $DIR/slice_index.rs:+1:5: +1:17
-
- bb0: {
- _3 = Len((*_1)); // scope 0 at $DIR/slice_index.rs:+1:5: +1:17
- _4 = Lt(_2, _3); // scope 0 at $DIR/slice_index.rs:+1:5: +1:17
- assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> bb1; // scope 0 at $DIR/slice_index.rs:+1:5: +1:17
- }
-
- bb1: {
- _0 = (*_1)[_2]; // scope 0 at $DIR/slice_index.rs:+1:5: +1:17
- return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2
- }
-}
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-abort.mir
new file mode 100644
index 000000000..210f9d6a1
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,20 @@
+// MIR for `slice_index_usize` after PreCodegen
+
+fn slice_index_usize(_1: &[u32], _2: usize) -> u32 {
+ debug slice => _1;
+ debug index => _2;
+ let mut _0: u32;
+ let mut _3: usize;
+ let mut _4: bool;
+
+ bb0: {
+ _3 = Len((*_1));
+ _4 = Lt(_2, _3);
+ assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ _0 = (*_1)[_2];
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-unwind.mir
new file mode 100644
index 000000000..d576520a8
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,20 @@
+// MIR for `slice_index_usize` after PreCodegen
+
+fn slice_index_usize(_1: &[u32], _2: usize) -> u32 {
+ debug slice => _1;
+ debug index => _2;
+ let mut _0: u32;
+ let mut _3: usize;
+ let mut _4: bool;
+
+ bb0: {
+ _3 = Len((*_1));
+ _4 = Lt(_2, _3);
+ assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+ _0 = (*_1)[_2];
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir
new file mode 100644
index 000000000..3c4140257
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,197 @@
+// MIR for `enumerated_loop` after PreCodegen
+
+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 _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: ();
+ scope 1 {
+ debug iter => _15;
+ let _19: usize;
+ let _20: &T;
+ scope 2 {
+ debug i => _19;
+ debug x => _20;
+ }
+ }
+ scope 3 (inlined core::slice::<impl [T]>::iter) {
+ debug self => _1;
+ scope 4 (inlined std::slice::Iter::<'_, T>::new) {
+ debug slice => _1;
+ let _4: *const T;
+ let mut _5: bool;
+ let mut _6: usize;
+ let mut _8: usize;
+ let mut _9: *mut T;
+ let mut _11: std::ptr::NonNull<T>;
+ let mut _12: *const T;
+ scope 5 {
+ debug ptr => _4;
+ scope 6 {
+ let _7: *const T;
+ scope 7 {
+ debug end => _7;
+ scope 13 (inlined NonNull::<T>::new_unchecked) {
+ debug ptr => _9;
+ let mut _10: *const T;
+ let mut _24: *mut T;
+ scope 14 {
+ scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) {
+ debug ptr => _24;
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) {
+ debug self => _24;
+ let mut _25: *mut u8;
+ scope 17 {
+ scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _25;
+ scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _25;
+ scope 20 {
+ scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _25;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 9 (inlined invalid::<T>) {
+ debug addr => _8;
+ scope 10 {
+ }
+ }
+ scope 11 (inlined ptr::const_ptr::<impl *const T>::add) {
+ debug self => _4;
+ debug count => _6;
+ scope 12 {
+ }
+ }
+ }
+ }
+ scope 8 (inlined core::slice::<impl [T]>::as_ptr) {
+ debug self => _1;
+ let mut _3: *const [T];
+ }
+ }
+ }
+ scope 22 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) {
+ debug self => _13;
+ scope 23 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) {
+ debug iter => _13;
+ }
+ }
+ scope 24 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) {
+ debug self => _14;
+ }
+
+ bb0: {
+ StorageLive(_13);
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = &raw const (*_1);
+ _4 = move _3 as *const T (PtrToPtr);
+ StorageDead(_3);
+ StorageLive(_7);
+ StorageLive(_5);
+ _5 = const _;
+ switchInt(move _5) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_6);
+ _6 = Len((*_1));
+ _7 = Offset(_4, _6);
+ StorageDead(_6);
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_8);
+ _8 = Len((*_1));
+ _7 = _8 as *const T (Transmute);
+ StorageDead(_8);
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_5);
+ StorageLive(_11);
+ StorageLive(_9);
+ _9 = _4 as *mut T (PtrToPtr);
+ StorageLive(_10);
+ StorageLive(_24);
+ StorageLive(_25);
+ _10 = _9 as *const T (PointerCoercion(MutToConstPointer));
+ _11 = NonNull::<T> { pointer: _10 };
+ StorageDead(_25);
+ StorageDead(_24);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageLive(_12);
+ _12 = _7;
+ _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> };
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_7);
+ StorageDead(_4);
+ _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: move _13, count: const 0_usize };
+ StorageDead(_13);
+ StorageLive(_15);
+ _15 = move _14;
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageLive(_17);
+ _16 = &mut _15;
+ _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(_16) -> [return: bb5, unwind unreachable];
+ }
+
+ bb5: {
+ _18 = discriminant(_17);
+ switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10];
+ }
+
+ bb6: {
+ StorageDead(_17);
+ StorageDead(_15);
+ drop(_2) -> [return: bb7, unwind unreachable];
+ }
+
+ bb7: {
+ return;
+ }
+
+ bb8: {
+ _19 = (((_17 as Some).0: (usize, &T)).0: usize);
+ _20 = (((_17 as Some).0: (usize, &T)).1: &T);
+ 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];
+ }
+
+ bb9: {
+ StorageDead(_22);
+ StorageDead(_21);
+ StorageDead(_17);
+ goto -> bb4;
+ }
+
+ bb10: {
+ unreachable;
+ }
+}
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
new file mode 100644
index 000000000..e3df8b961
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,205 @@
+// MIR for `enumerated_loop` after PreCodegen
+
+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 _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: ();
+ scope 1 {
+ debug iter => _15;
+ let _19: usize;
+ let _20: &T;
+ scope 2 {
+ debug i => _19;
+ debug x => _20;
+ }
+ }
+ scope 3 (inlined core::slice::<impl [T]>::iter) {
+ debug self => _1;
+ scope 4 (inlined std::slice::Iter::<'_, T>::new) {
+ debug slice => _1;
+ let _4: *const T;
+ let mut _5: bool;
+ let mut _6: usize;
+ let mut _8: usize;
+ let mut _9: *mut T;
+ let mut _11: std::ptr::NonNull<T>;
+ let mut _12: *const T;
+ scope 5 {
+ debug ptr => _4;
+ scope 6 {
+ let _7: *const T;
+ scope 7 {
+ debug end => _7;
+ scope 13 (inlined NonNull::<T>::new_unchecked) {
+ debug ptr => _9;
+ let mut _10: *const T;
+ let mut _24: *mut T;
+ scope 14 {
+ scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) {
+ debug ptr => _24;
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) {
+ debug self => _24;
+ let mut _25: *mut u8;
+ scope 17 {
+ scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _25;
+ scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _25;
+ scope 20 {
+ scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _25;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 9 (inlined invalid::<T>) {
+ debug addr => _8;
+ scope 10 {
+ }
+ }
+ scope 11 (inlined ptr::const_ptr::<impl *const T>::add) {
+ debug self => _4;
+ debug count => _6;
+ scope 12 {
+ }
+ }
+ }
+ }
+ scope 8 (inlined core::slice::<impl [T]>::as_ptr) {
+ debug self => _1;
+ let mut _3: *const [T];
+ }
+ }
+ }
+ scope 22 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) {
+ debug self => _13;
+ scope 23 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) {
+ debug iter => _13;
+ }
+ }
+ scope 24 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) {
+ debug self => _14;
+ }
+
+ bb0: {
+ StorageLive(_13);
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = &raw const (*_1);
+ _4 = move _3 as *const T (PtrToPtr);
+ StorageDead(_3);
+ StorageLive(_7);
+ StorageLive(_5);
+ _5 = const _;
+ switchInt(move _5) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_6);
+ _6 = Len((*_1));
+ _7 = Offset(_4, _6);
+ StorageDead(_6);
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_8);
+ _8 = Len((*_1));
+ _7 = _8 as *const T (Transmute);
+ StorageDead(_8);
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_5);
+ StorageLive(_11);
+ StorageLive(_9);
+ _9 = _4 as *mut T (PtrToPtr);
+ StorageLive(_10);
+ StorageLive(_24);
+ StorageLive(_25);
+ _10 = _9 as *const T (PointerCoercion(MutToConstPointer));
+ _11 = NonNull::<T> { pointer: _10 };
+ StorageDead(_25);
+ StorageDead(_24);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageLive(_12);
+ _12 = _7;
+ _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> };
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_7);
+ StorageDead(_4);
+ _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: move _13, count: const 0_usize };
+ StorageDead(_13);
+ StorageLive(_15);
+ _15 = move _14;
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageLive(_17);
+ _16 = &mut _15;
+ _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(_16) -> [return: bb5, unwind: bb11];
+ }
+
+ bb5: {
+ _18 = discriminant(_17);
+ switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10];
+ }
+
+ bb6: {
+ StorageDead(_17);
+ StorageDead(_15);
+ drop(_2) -> [return: bb7, unwind continue];
+ }
+
+ bb7: {
+ return;
+ }
+
+ bb8: {
+ _19 = (((_17 as Some).0: (usize, &T)).0: usize);
+ _20 = (((_17 as Some).0: (usize, &T)).1: &T);
+ 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];
+ }
+
+ bb9: {
+ StorageDead(_22);
+ StorageDead(_21);
+ StorageDead(_17);
+ goto -> bb4;
+ }
+
+ bb10: {
+ unreachable;
+ }
+
+ bb11 (cleanup): {
+ drop(_2) -> [return: bb12, unwind terminate];
+ }
+
+ bb12 (cleanup): {
+ resume;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir
deleted file mode 100644
index 0da7e5536..000000000
--- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir
+++ /dev/null
@@ -1,203 +0,0 @@
-// MIR for `forward_loop` after PreCodegen
-
-fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
- debug slice => _1; // in scope 0 at $DIR/slice_iter.rs:+0:28: +0:33
- debug f => _2; // in scope 0 at $DIR/slice_iter.rs:+0:44: +0:45
- let mut _0: (); // return place in scope 0 at $DIR/slice_iter.rs:+0:60: +0:60
- let mut _3: std::slice::Iter<'_, T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26
- let mut _4: std::slice::Iter<'_, T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26
- let _5: (); // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26
- let mut _6: std::option::Option<&T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26
- let mut _7: &mut std::slice::Iter<'_, T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26
- let mut _8: isize; // in scope 0 at $DIR/slice_iter.rs:+1:5: +3:6
- let mut _10: &impl Fn(&T); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:10
- let mut _11: (&T,); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:13
- scope 1 {
- debug iter => _4; // in scope 1 at $DIR/slice_iter.rs:+1:14: +1:26
- let _9: &T; // in scope 1 at $DIR/slice_iter.rs:+1:9: +1:10
- scope 2 {
- debug x => _9; // in scope 2 at $DIR/slice_iter.rs:+1:9: +1:10
- }
- }
- scope 3 (inlined core::slice::<impl [T]>::iter) { // at $DIR/slice_iter.rs:28:20: 28:26
- debug self => _1; // in scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- scope 4 (inlined std::slice::Iter::<'_, T>::new) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- debug slice => _1; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let _12: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _14: bool; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _15: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _16: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _17: std::ptr::NonNull<T>; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _18: *mut T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _19: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- scope 5 {
- debug ptr => _12; // in scope 5 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- scope 6 {
- let _13: *const T; // in scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- scope 7 {
- debug end => _13; // in scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- scope 13 (inlined NonNull::<T>::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- debug ptr => _18; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- let mut _21: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- let mut _22: *mut T; // in scope 13 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- scope 14 {
- scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- debug ptr => _22; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- debug self => _22; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- let mut _23: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 17 {
- scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug ptr => _23; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug self => _23; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 20 {
- scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug self => _23; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- scope 9 (inlined invalid::<T>) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- debug addr => _15; // in scope 9 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- scope 10 {
- }
- }
- scope 11 (inlined ptr::const_ptr::<impl *const T>::add) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- debug self => _12; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- debug count => _16; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- scope 12 {
- }
- }
- }
- }
- scope 8 (inlined core::slice::<impl [T]>::as_ptr) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- debug self => _1; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- let mut _20: *const [T]; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- }
- }
- }
- scope 22 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) { // at $DIR/slice_iter.rs:28:14: 28:26
- debug self => _3; // in scope 22 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- }
-
- bb0: {
- StorageLive(_12); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_20); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- _20 = &raw const (*_1); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- _12 = move _20 as *const T (PtrToPtr); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageDead(_20); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_13); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_14); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _14 = const _; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- switchInt(move _14) -> [0: bb11, otherwise: bb10]; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- }
-
- bb1: {
- StorageLive(_6); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26
- _7 = &mut _4; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26
- _6 = <std::slice::Iter<'_, T> as Iterator>::next(_7) -> [return: bb2, unwind: bb8]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26
- // mir::Constant
- // + span: $DIR/slice_iter.rs:28:14: 28:26
- // + literal: Const { ty: for<'a> fn(&'a mut std::slice::Iter<'_, T>) -> Option<<std::slice::Iter<'_, T> as Iterator>::Item> {<std::slice::Iter<'_, T> as Iterator>::next}, val: Value(<ZST>) }
- }
-
- bb2: {
- _8 = discriminant(_6); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26
- switchInt(move _8) -> [0: bb5, 1: bb3, otherwise: bb4]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26
- }
-
- bb3: {
- _9 = ((_6 as Some).0: &T); // scope 1 at $DIR/slice_iter.rs:+1:9: +1:10
- StorageLive(_10); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10
- _10 = &_2; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10
- StorageLive(_11); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13
- _11 = (_9,); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13
- _5 = <impl Fn(&T) as Fn<(&T,)>>::call(move _10, move _11) -> [return: bb6, unwind: bb8]; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13
- // mir::Constant
- // + span: $DIR/slice_iter.rs:29:9: 29:10
- // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(&T), (&T,)) -> <impl Fn(&T) as FnOnce<(&T,)>>::Output {<impl Fn(&T) as Fn<(&T,)>>::call}, val: Value(<ZST>) }
- }
-
- bb4: {
- unreachable; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26
- }
-
- bb5: {
- StorageDead(_6); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6
- StorageDead(_4); // scope 0 at $DIR/slice_iter.rs:+3:5: +3:6
- drop(_2) -> bb7; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2
- }
-
- bb6: {
- StorageDead(_11); // scope 2 at $DIR/slice_iter.rs:+2:12: +2:13
- StorageDead(_10); // scope 2 at $DIR/slice_iter.rs:+2:12: +2:13
- StorageDead(_6); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6
- goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6
- }
-
- bb7: {
- return; // scope 0 at $DIR/slice_iter.rs:+4:2: +4:2
- }
-
- bb8 (cleanup): {
- drop(_2) -> [return: bb9, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2
- }
-
- bb9 (cleanup): {
- resume; // scope 0 at $DIR/slice_iter.rs:+0:1: +4:2
- }
-
- bb10: {
- StorageLive(_15); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _15 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _13 = _15 as *const T (Transmute); // scope 10 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- StorageDead(_15); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- goto -> bb12; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- }
-
- bb11: {
- StorageLive(_16); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _16 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _13 = Offset(_12, _16); // scope 12 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- StorageDead(_16); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- goto -> bb12; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- }
-
- bb12: {
- StorageDead(_14); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_17); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_18); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _18 = _12 as *mut T (PtrToPtr); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_21); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _21 = _18 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- _17 = NonNull::<T> { pointer: _21 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- StorageDead(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_21); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_18); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_19); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _19 = _13; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _3 = std::slice::Iter::<'_, T> { ptr: move _17, end: move _19, _marker: const ZeroSized: PhantomData<&T> }; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- // mir::Constant
- // + span: no-location
- // + literal: Const { ty: PhantomData<&T>, val: Value(<ZST>) }
- // adt
- // + user_ty: UserType(1)
- StorageDead(_19); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_17); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_13); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_12); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_4); // scope 0 at $DIR/slice_iter.rs:+1:14: +1:26
- _4 = move _3; // scope 0 at $DIR/slice_iter.rs:+1:14: +1:26
- goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6
- }
-}
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
new file mode 100644
index 000000000..49de4b463
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,184 @@
+// MIR for `forward_loop` after PreCodegen
+
+fn forward_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 _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: ();
+ scope 1 {
+ debug iter => _14;
+ let _18: &T;
+ scope 2 {
+ debug x => _18;
+ }
+ }
+ scope 3 (inlined core::slice::<impl [T]>::iter) {
+ debug self => _1;
+ scope 4 (inlined std::slice::Iter::<'_, T>::new) {
+ debug slice => _1;
+ let _4: *const T;
+ let mut _5: bool;
+ let mut _6: usize;
+ let mut _8: usize;
+ let mut _9: *mut T;
+ let mut _11: std::ptr::NonNull<T>;
+ let mut _12: *const T;
+ scope 5 {
+ debug ptr => _4;
+ scope 6 {
+ let _7: *const T;
+ scope 7 {
+ debug end => _7;
+ scope 13 (inlined NonNull::<T>::new_unchecked) {
+ debug ptr => _9;
+ let mut _10: *const T;
+ let mut _22: *mut T;
+ scope 14 {
+ scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) {
+ debug ptr => _22;
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) {
+ debug self => _22;
+ let mut _23: *mut u8;
+ scope 17 {
+ scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _23;
+ scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _23;
+ scope 20 {
+ scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _23;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 9 (inlined invalid::<T>) {
+ debug addr => _8;
+ scope 10 {
+ }
+ }
+ scope 11 (inlined ptr::const_ptr::<impl *const T>::add) {
+ debug self => _4;
+ debug count => _6;
+ scope 12 {
+ }
+ }
+ }
+ }
+ scope 8 (inlined core::slice::<impl [T]>::as_ptr) {
+ debug self => _1;
+ let mut _3: *const [T];
+ }
+ }
+ }
+ scope 22 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) {
+ debug self => _13;
+ }
+
+ bb0: {
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = &raw const (*_1);
+ _4 = move _3 as *const T (PtrToPtr);
+ StorageDead(_3);
+ StorageLive(_7);
+ StorageLive(_5);
+ _5 = const _;
+ switchInt(move _5) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_6);
+ _6 = Len((*_1));
+ _7 = Offset(_4, _6);
+ StorageDead(_6);
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_8);
+ _8 = Len((*_1));
+ _7 = _8 as *const T (Transmute);
+ StorageDead(_8);
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_5);
+ StorageLive(_11);
+ StorageLive(_9);
+ _9 = _4 as *mut T (PtrToPtr);
+ StorageLive(_10);
+ StorageLive(_22);
+ StorageLive(_23);
+ _10 = _9 as *const T (PointerCoercion(MutToConstPointer));
+ _11 = NonNull::<T> { pointer: _10 };
+ StorageDead(_23);
+ StorageDead(_22);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageLive(_12);
+ _12 = _7;
+ _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> };
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_7);
+ StorageDead(_4);
+ StorageLive(_14);
+ _14 = move _13;
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageLive(_16);
+ _15 = &mut _14;
+ _16 = <std::slice::Iter<'_, T> as Iterator>::next(_15) -> [return: bb5, unwind unreachable];
+ }
+
+ bb5: {
+ _17 = discriminant(_16);
+ switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10];
+ }
+
+ bb6: {
+ StorageDead(_16);
+ StorageDead(_14);
+ drop(_2) -> [return: bb7, unwind unreachable];
+ }
+
+ bb7: {
+ return;
+ }
+
+ bb8: {
+ _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(_20);
+ StorageDead(_19);
+ StorageDead(_16);
+ goto -> bb4;
+ }
+
+ bb10: {
+ unreachable;
+ }
+}
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
new file mode 100644
index 000000000..cfc304987
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,192 @@
+// MIR for `forward_loop` after PreCodegen
+
+fn forward_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 _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: ();
+ scope 1 {
+ debug iter => _14;
+ let _18: &T;
+ scope 2 {
+ debug x => _18;
+ }
+ }
+ scope 3 (inlined core::slice::<impl [T]>::iter) {
+ debug self => _1;
+ scope 4 (inlined std::slice::Iter::<'_, T>::new) {
+ debug slice => _1;
+ let _4: *const T;
+ let mut _5: bool;
+ let mut _6: usize;
+ let mut _8: usize;
+ let mut _9: *mut T;
+ let mut _11: std::ptr::NonNull<T>;
+ let mut _12: *const T;
+ scope 5 {
+ debug ptr => _4;
+ scope 6 {
+ let _7: *const T;
+ scope 7 {
+ debug end => _7;
+ scope 13 (inlined NonNull::<T>::new_unchecked) {
+ debug ptr => _9;
+ let mut _10: *const T;
+ let mut _22: *mut T;
+ scope 14 {
+ scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) {
+ debug ptr => _22;
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) {
+ debug self => _22;
+ let mut _23: *mut u8;
+ scope 17 {
+ scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _23;
+ scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _23;
+ scope 20 {
+ scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _23;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 9 (inlined invalid::<T>) {
+ debug addr => _8;
+ scope 10 {
+ }
+ }
+ scope 11 (inlined ptr::const_ptr::<impl *const T>::add) {
+ debug self => _4;
+ debug count => _6;
+ scope 12 {
+ }
+ }
+ }
+ }
+ scope 8 (inlined core::slice::<impl [T]>::as_ptr) {
+ debug self => _1;
+ let mut _3: *const [T];
+ }
+ }
+ }
+ scope 22 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) {
+ debug self => _13;
+ }
+
+ bb0: {
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = &raw const (*_1);
+ _4 = move _3 as *const T (PtrToPtr);
+ StorageDead(_3);
+ StorageLive(_7);
+ StorageLive(_5);
+ _5 = const _;
+ switchInt(move _5) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_6);
+ _6 = Len((*_1));
+ _7 = Offset(_4, _6);
+ StorageDead(_6);
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_8);
+ _8 = Len((*_1));
+ _7 = _8 as *const T (Transmute);
+ StorageDead(_8);
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_5);
+ StorageLive(_11);
+ StorageLive(_9);
+ _9 = _4 as *mut T (PtrToPtr);
+ StorageLive(_10);
+ StorageLive(_22);
+ StorageLive(_23);
+ _10 = _9 as *const T (PointerCoercion(MutToConstPointer));
+ _11 = NonNull::<T> { pointer: _10 };
+ StorageDead(_23);
+ StorageDead(_22);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageLive(_12);
+ _12 = _7;
+ _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> };
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_7);
+ StorageDead(_4);
+ StorageLive(_14);
+ _14 = move _13;
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageLive(_16);
+ _15 = &mut _14;
+ _16 = <std::slice::Iter<'_, T> as Iterator>::next(_15) -> [return: bb5, unwind: bb11];
+ }
+
+ bb5: {
+ _17 = discriminant(_16);
+ switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10];
+ }
+
+ bb6: {
+ StorageDead(_16);
+ StorageDead(_14);
+ drop(_2) -> [return: bb7, unwind continue];
+ }
+
+ bb7: {
+ return;
+ }
+
+ bb8: {
+ _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(_20);
+ StorageDead(_19);
+ StorageDead(_16);
+ goto -> bb4;
+ }
+
+ bb10: {
+ unreachable;
+ }
+
+ bb11 (cleanup): {
+ drop(_2) -> [return: bb12, unwind terminate];
+ }
+
+ bb12 (cleanup): {
+ resume;
+ }
+}
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
new file mode 100644
index 000000000..00177033b
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,147 @@
+// MIR for `range_loop` after PreCodegen
+
+fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
+ debug slice => _1;
+ 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 _12: std::option::Option<usize>;
+ let mut _15: isize;
+ let mut _17: usize;
+ let mut _18: bool;
+ let mut _20: &impl Fn(usize, &T);
+ let mut _21: (usize, &T);
+ let _22: ();
+ scope 1 {
+ debug iter => _5;
+ let _16: usize;
+ scope 2 {
+ debug i => _16;
+ let _19: &T;
+ scope 3 {
+ debug x => _19;
+ }
+ }
+ 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 _13: usize;
+ let mut _14: usize;
+ scope 7 {
+ debug old => _13;
+ scope 8 {
+ }
+ }
+ scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::lt) {
+ debug self => _7;
+ debug other => _8;
+ let mut _9: usize;
+ let mut _10: 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 = move _4;
+ goto -> bb1;
+ }
+
+ bb1: {
+ StorageLive(_12);
+ _6 = &mut _5;
+ StorageLive(_13);
+ StorageLive(_11);
+ StorageLive(_7);
+ _7 = &((*_6).0: usize);
+ StorageLive(_8);
+ _8 = &((*_6).1: usize);
+ StorageLive(_9);
+ _9 = (*_7);
+ StorageLive(_10);
+ _10 = (*_8);
+ _11 = Lt(move _9, move _10);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_7);
+ switchInt(move _11) -> [0: bb2, otherwise: bb3];
+ }
+
+ bb2: {
+ _12 = Option::<usize>::None;
+ goto -> bb5;
+ }
+
+ bb3: {
+ _13 = ((*_6).0: usize);
+ StorageLive(_14);
+ _14 = <usize as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind unreachable];
+ }
+
+ bb4: {
+ ((*_6).0: usize) = move _14;
+ StorageDead(_14);
+ _12 = Option::<usize>::Some(_13);
+ goto -> bb5;
+ }
+
+ bb5: {
+ StorageDead(_11);
+ StorageDead(_13);
+ _15 = discriminant(_12);
+ switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11];
+ }
+
+ bb6: {
+ StorageDead(_12);
+ StorageDead(_5);
+ drop(_2) -> [return: bb7, unwind unreachable];
+ }
+
+ bb7: {
+ return;
+ }
+
+ bb8: {
+ _16 = ((_12 as Some).0: usize);
+ _17 = Len((*_1));
+ _18 = Lt(_16, _17);
+ assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind unreachable];
+ }
+
+ bb9: {
+ _19 = &(*_1)[_16];
+ StorageLive(_20);
+ _20 = &_2;
+ StorageLive(_21);
+ _21 = (_16, _19);
+ _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb10, unwind unreachable];
+ }
+
+ bb10: {
+ StorageDead(_21);
+ StorageDead(_20);
+ StorageDead(_12);
+ goto -> bb1;
+ }
+
+ bb11: {
+ unreachable;
+ }
+}
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
new file mode 100644
index 000000000..3423c5d86
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,155 @@
+// MIR for `range_loop` after PreCodegen
+
+fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
+ debug slice => _1;
+ 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 _12: std::option::Option<usize>;
+ let mut _15: isize;
+ let mut _17: usize;
+ let mut _18: bool;
+ let mut _20: &impl Fn(usize, &T);
+ let mut _21: (usize, &T);
+ let _22: ();
+ scope 1 {
+ debug iter => _5;
+ let _16: usize;
+ scope 2 {
+ debug i => _16;
+ let _19: &T;
+ scope 3 {
+ debug x => _19;
+ }
+ }
+ 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 _13: usize;
+ let mut _14: usize;
+ scope 7 {
+ debug old => _13;
+ scope 8 {
+ }
+ }
+ scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::lt) {
+ debug self => _7;
+ debug other => _8;
+ let mut _9: usize;
+ let mut _10: 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 = move _4;
+ goto -> bb1;
+ }
+
+ bb1: {
+ StorageLive(_12);
+ _6 = &mut _5;
+ StorageLive(_13);
+ StorageLive(_11);
+ StorageLive(_7);
+ _7 = &((*_6).0: usize);
+ StorageLive(_8);
+ _8 = &((*_6).1: usize);
+ StorageLive(_9);
+ _9 = (*_7);
+ StorageLive(_10);
+ _10 = (*_8);
+ _11 = Lt(move _9, move _10);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_7);
+ switchInt(move _11) -> [0: bb2, otherwise: bb3];
+ }
+
+ bb2: {
+ _12 = Option::<usize>::None;
+ goto -> bb5;
+ }
+
+ bb3: {
+ _13 = ((*_6).0: usize);
+ StorageLive(_14);
+ _14 = <usize as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb12];
+ }
+
+ bb4: {
+ ((*_6).0: usize) = move _14;
+ StorageDead(_14);
+ _12 = Option::<usize>::Some(_13);
+ goto -> bb5;
+ }
+
+ bb5: {
+ StorageDead(_11);
+ StorageDead(_13);
+ _15 = discriminant(_12);
+ switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11];
+ }
+
+ bb6: {
+ StorageDead(_12);
+ StorageDead(_5);
+ drop(_2) -> [return: bb7, unwind continue];
+ }
+
+ bb7: {
+ return;
+ }
+
+ bb8: {
+ _16 = ((_12 as Some).0: usize);
+ _17 = Len((*_1));
+ _18 = Lt(_16, _17);
+ assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind: bb12];
+ }
+
+ bb9: {
+ _19 = &(*_1)[_16];
+ StorageLive(_20);
+ _20 = &_2;
+ StorageLive(_21);
+ _21 = (_16, _19);
+ _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb10, unwind: bb12];
+ }
+
+ bb10: {
+ StorageDead(_21);
+ StorageDead(_20);
+ StorageDead(_12);
+ goto -> bb1;
+ }
+
+ bb11: {
+ unreachable;
+ }
+
+ bb12 (cleanup): {
+ drop(_2) -> [return: bb13, unwind terminate];
+ }
+
+ bb13 (cleanup): {
+ resume;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir
deleted file mode 100644
index 45b41b54c..000000000
--- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir
+++ /dev/null
@@ -1,220 +0,0 @@
-// MIR for `reverse_loop` after PreCodegen
-
-fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
- debug slice => _1; // in scope 0 at $DIR/slice_iter.rs:+0:28: +0:33
- debug f => _2; // in scope 0 at $DIR/slice_iter.rs:+0:44: +0:45
- let mut _0: (); // return place in scope 0 at $DIR/slice_iter.rs:+0:60: +0:60
- let mut _3: std::iter::Rev<std::slice::Iter<'_, T>>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32
- let mut _4: std::slice::Iter<'_, T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26
- let mut _5: std::iter::Rev<std::slice::Iter<'_, T>>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32
- let _6: (); // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32
- let mut _7: std::option::Option<&T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32
- let mut _8: &mut std::iter::Rev<std::slice::Iter<'_, T>>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32
- let mut _9: isize; // in scope 0 at $DIR/slice_iter.rs:+1:5: +3:6
- let mut _11: &impl Fn(&T); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:10
- let mut _12: (&T,); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:13
- scope 1 {
- debug iter => _5; // in scope 1 at $DIR/slice_iter.rs:+1:14: +1:32
- let _10: &T; // in scope 1 at $DIR/slice_iter.rs:+1:9: +1:10
- scope 2 {
- debug x => _10; // in scope 2 at $DIR/slice_iter.rs:+1:9: +1:10
- }
- scope 25 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { // at $DIR/slice_iter.rs:35:14: 35:32
- debug self => _8; // in scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL
- let mut _25: &mut std::slice::Iter<'_, T>; // in scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL
- }
- }
- scope 3 (inlined core::slice::<impl [T]>::iter) { // at $DIR/slice_iter.rs:35:20: 35:26
- debug self => _1; // in scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- scope 4 (inlined std::slice::Iter::<'_, T>::new) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- debug slice => _1; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let _13: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _15: bool; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _16: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _17: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _18: std::ptr::NonNull<T>; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _19: *mut T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- let mut _20: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- scope 5 {
- debug ptr => _13; // in scope 5 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- scope 6 {
- let _14: *const T; // in scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- scope 7 {
- debug end => _14; // in scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- scope 13 (inlined NonNull::<T>::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- debug ptr => _19; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- let mut _22: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- let mut _23: *mut T; // in scope 13 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- scope 14 {
- scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- debug ptr => _23; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
- scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- debug self => _23; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- let mut _24: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 17 {
- scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug ptr => _24; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug self => _24; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- scope 20 {
- scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- debug self => _24; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- scope 9 (inlined invalid::<T>) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- debug addr => _16; // in scope 9 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- scope 10 {
- }
- }
- scope 11 (inlined ptr::const_ptr::<impl *const T>::add) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- debug self => _13; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- debug count => _17; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- scope 12 {
- }
- }
- }
- }
- scope 8 (inlined core::slice::<impl [T]>::as_ptr) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- debug self => _1; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- let mut _21: *const [T]; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- }
- }
- }
- scope 22 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { // at $DIR/slice_iter.rs:35:27: 35:32
- debug self => _4; // in scope 22 at $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
- scope 23 (inlined Rev::<std::slice::Iter<'_, T>>::new) { // at $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
- debug iter => _4; // in scope 23 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL
- }
- }
- scope 24 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { // at $DIR/slice_iter.rs:35:14: 35:32
- debug self => _3; // in scope 24 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- }
-
- bb0: {
- StorageLive(_4); // scope 0 at $DIR/slice_iter.rs:+1:14: +1:26
- StorageLive(_13); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_21); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- _21 = &raw const (*_1); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- _13 = move _21 as *const T (PtrToPtr); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageDead(_21); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- StorageLive(_14); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_15); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _15 = const _; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- switchInt(move _15) -> [0: bb10, otherwise: bb9]; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- }
-
- bb1: {
- StorageLive(_7); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32
- _8 = &mut _5; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32
- StorageLive(_25); // scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL
- _25 = &mut ((*_8).0: std::slice::Iter<'_, T>); // scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL
- _7 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _25) -> [return: bb12, unwind: bb7]; // scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL
- // mir::Constant
- // + span: $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL
- // + literal: Const { ty: for<'a> fn(&'a mut std::slice::Iter<'_, T>) -> Option<<std::slice::Iter<'_, T> as Iterator>::Item> {<std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back}, val: Value(<ZST>) }
- }
-
- bb2: {
- _10 = ((_7 as Some).0: &T); // scope 1 at $DIR/slice_iter.rs:+1:9: +1:10
- StorageLive(_11); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10
- _11 = &_2; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10
- StorageLive(_12); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13
- _12 = (_10,); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13
- _6 = <impl Fn(&T) as Fn<(&T,)>>::call(move _11, move _12) -> [return: bb5, unwind: bb7]; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13
- // mir::Constant
- // + span: $DIR/slice_iter.rs:36:9: 36:10
- // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(&T), (&T,)) -> <impl Fn(&T) as FnOnce<(&T,)>>::Output {<impl Fn(&T) as Fn<(&T,)>>::call}, val: Value(<ZST>) }
- }
-
- bb3: {
- unreachable; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32
- }
-
- bb4: {
- StorageDead(_7); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6
- StorageDead(_5); // scope 0 at $DIR/slice_iter.rs:+3:5: +3:6
- drop(_2) -> bb6; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2
- }
-
- bb5: {
- StorageDead(_12); // scope 2 at $DIR/slice_iter.rs:+2:12: +2:13
- StorageDead(_11); // scope 2 at $DIR/slice_iter.rs:+2:12: +2:13
- StorageDead(_7); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6
- goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6
- }
-
- bb6: {
- return; // scope 0 at $DIR/slice_iter.rs:+4:2: +4:2
- }
-
- bb7 (cleanup): {
- drop(_2) -> [return: bb8, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2
- }
-
- bb8 (cleanup): {
- resume; // scope 0 at $DIR/slice_iter.rs:+0:1: +4:2
- }
-
- bb9: {
- StorageLive(_16); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _16 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _14 = _16 as *const T (Transmute); // scope 10 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- StorageDead(_16); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- goto -> bb11; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- }
-
- bb10: {
- StorageLive(_17); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _17 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _14 = Offset(_13, _17); // scope 12 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- StorageDead(_17); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- goto -> bb11; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- }
-
- bb11: {
- StorageDead(_15); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_18); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_19); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _19 = _13 as *mut T (PtrToPtr); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _22 = _19 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- _18 = NonNull::<T> { pointer: _22 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
- StorageDead(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_19); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageLive(_20); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _20 = _14; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- _4 = std::slice::Iter::<'_, T> { ptr: move _18, end: move _20, _marker: const ZeroSized: PhantomData<&T> }; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- // mir::Constant
- // + span: no-location
- // + literal: Const { ty: PhantomData<&T>, val: Value(<ZST>) }
- // adt
- // + user_ty: UserType(1)
- StorageDead(_20); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_18); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_14); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
- StorageDead(_13); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL
- _3 = Rev::<std::slice::Iter<'_, T>> { iter: move _4 }; // scope 23 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL
- StorageDead(_4); // scope 0 at $DIR/slice_iter.rs:+1:31: +1:32
- StorageLive(_5); // scope 0 at $DIR/slice_iter.rs:+1:14: +1:32
- _5 = move _3; // scope 0 at $DIR/slice_iter.rs:+1:14: +1:32
- goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6
- }
-
- bb12: {
- StorageDead(_25); // scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL
- _9 = discriminant(_7); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32
- switchInt(move _9) -> [0: bb4, 1: bb2, otherwise: bb3]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32
- }
-}
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
new file mode 100644
index 000000000..1b4ac793f
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,201 @@
+// MIR for `reverse_loop` after PreCodegen
+
+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 _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: ();
+ scope 1 {
+ debug iter => _15;
+ let _20: &T;
+ scope 2 {
+ debug x => _20;
+ }
+ scope 25 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
+ debug self => _16;
+ let mut _17: &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 _4: *const T;
+ let mut _5: bool;
+ let mut _6: usize;
+ let mut _8: usize;
+ let mut _9: *mut T;
+ let mut _11: std::ptr::NonNull<T>;
+ let mut _12: *const T;
+ scope 5 {
+ debug ptr => _4;
+ scope 6 {
+ let _7: *const T;
+ scope 7 {
+ debug end => _7;
+ scope 13 (inlined NonNull::<T>::new_unchecked) {
+ debug ptr => _9;
+ let mut _10: *const T;
+ let mut _24: *mut T;
+ scope 14 {
+ scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) {
+ debug ptr => _24;
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) {
+ debug self => _24;
+ let mut _25: *mut u8;
+ scope 17 {
+ scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _25;
+ scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _25;
+ scope 20 {
+ scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _25;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 9 (inlined invalid::<T>) {
+ debug addr => _8;
+ scope 10 {
+ }
+ }
+ scope 11 (inlined ptr::const_ptr::<impl *const T>::add) {
+ debug self => _4;
+ debug count => _6;
+ scope 12 {
+ }
+ }
+ }
+ }
+ scope 8 (inlined core::slice::<impl [T]>::as_ptr) {
+ debug self => _1;
+ let mut _3: *const [T];
+ }
+ }
+ }
+ scope 22 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) {
+ debug self => _13;
+ scope 23 (inlined Rev::<std::slice::Iter<'_, T>>::new) {
+ debug iter => _13;
+ }
+ }
+ scope 24 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) {
+ debug self => _14;
+ }
+
+ bb0: {
+ StorageLive(_13);
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = &raw const (*_1);
+ _4 = move _3 as *const T (PtrToPtr);
+ StorageDead(_3);
+ StorageLive(_7);
+ StorageLive(_5);
+ _5 = const _;
+ switchInt(move _5) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_6);
+ _6 = Len((*_1));
+ _7 = Offset(_4, _6);
+ StorageDead(_6);
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_8);
+ _8 = Len((*_1));
+ _7 = _8 as *const T (Transmute);
+ StorageDead(_8);
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_5);
+ StorageLive(_11);
+ StorageLive(_9);
+ _9 = _4 as *mut T (PtrToPtr);
+ StorageLive(_10);
+ StorageLive(_24);
+ StorageLive(_25);
+ _10 = _9 as *const T (PointerCoercion(MutToConstPointer));
+ _11 = NonNull::<T> { pointer: _10 };
+ StorageDead(_25);
+ StorageDead(_24);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageLive(_12);
+ _12 = _7;
+ _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> };
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_7);
+ StorageDead(_4);
+ _14 = Rev::<std::slice::Iter<'_, T>> { iter: move _13 };
+ StorageDead(_13);
+ StorageLive(_15);
+ _15 = move _14;
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageLive(_18);
+ _16 = &mut _15;
+ StorageLive(_17);
+ _17 = &mut ((*_16).0: std::slice::Iter<'_, T>);
+ _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind unreachable];
+ }
+
+ bb5: {
+ StorageDead(_17);
+ _19 = discriminant(_18);
+ switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10];
+ }
+
+ bb6: {
+ StorageDead(_18);
+ StorageDead(_15);
+ drop(_2) -> [return: bb7, unwind unreachable];
+ }
+
+ bb7: {
+ return;
+ }
+
+ 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];
+ }
+
+ bb9: {
+ StorageDead(_22);
+ StorageDead(_21);
+ StorageDead(_18);
+ goto -> bb4;
+ }
+
+ bb10: {
+ unreachable;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir
new file mode 100644
index 000000000..f75a9a03d
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,209 @@
+// MIR for `reverse_loop` after PreCodegen
+
+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 _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: ();
+ scope 1 {
+ debug iter => _15;
+ let _20: &T;
+ scope 2 {
+ debug x => _20;
+ }
+ scope 25 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
+ debug self => _16;
+ let mut _17: &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 _4: *const T;
+ let mut _5: bool;
+ let mut _6: usize;
+ let mut _8: usize;
+ let mut _9: *mut T;
+ let mut _11: std::ptr::NonNull<T>;
+ let mut _12: *const T;
+ scope 5 {
+ debug ptr => _4;
+ scope 6 {
+ let _7: *const T;
+ scope 7 {
+ debug end => _7;
+ scope 13 (inlined NonNull::<T>::new_unchecked) {
+ debug ptr => _9;
+ let mut _10: *const T;
+ let mut _24: *mut T;
+ scope 14 {
+ scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) {
+ debug ptr => _24;
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) {
+ debug self => _24;
+ let mut _25: *mut u8;
+ scope 17 {
+ scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _25;
+ scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _25;
+ scope 20 {
+ scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _25;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 9 (inlined invalid::<T>) {
+ debug addr => _8;
+ scope 10 {
+ }
+ }
+ scope 11 (inlined ptr::const_ptr::<impl *const T>::add) {
+ debug self => _4;
+ debug count => _6;
+ scope 12 {
+ }
+ }
+ }
+ }
+ scope 8 (inlined core::slice::<impl [T]>::as_ptr) {
+ debug self => _1;
+ let mut _3: *const [T];
+ }
+ }
+ }
+ scope 22 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) {
+ debug self => _13;
+ scope 23 (inlined Rev::<std::slice::Iter<'_, T>>::new) {
+ debug iter => _13;
+ }
+ }
+ scope 24 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) {
+ debug self => _14;
+ }
+
+ bb0: {
+ StorageLive(_13);
+ StorageLive(_4);
+ StorageLive(_3);
+ _3 = &raw const (*_1);
+ _4 = move _3 as *const T (PtrToPtr);
+ StorageDead(_3);
+ StorageLive(_7);
+ StorageLive(_5);
+ _5 = const _;
+ switchInt(move _5) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_6);
+ _6 = Len((*_1));
+ _7 = Offset(_4, _6);
+ StorageDead(_6);
+ goto -> bb3;
+ }
+
+ bb2: {
+ StorageLive(_8);
+ _8 = Len((*_1));
+ _7 = _8 as *const T (Transmute);
+ StorageDead(_8);
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_5);
+ StorageLive(_11);
+ StorageLive(_9);
+ _9 = _4 as *mut T (PtrToPtr);
+ StorageLive(_10);
+ StorageLive(_24);
+ StorageLive(_25);
+ _10 = _9 as *const T (PointerCoercion(MutToConstPointer));
+ _11 = NonNull::<T> { pointer: _10 };
+ StorageDead(_25);
+ StorageDead(_24);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageLive(_12);
+ _12 = _7;
+ _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> };
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_7);
+ StorageDead(_4);
+ _14 = Rev::<std::slice::Iter<'_, T>> { iter: move _13 };
+ StorageDead(_13);
+ StorageLive(_15);
+ _15 = move _14;
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageLive(_18);
+ _16 = &mut _15;
+ StorageLive(_17);
+ _17 = &mut ((*_16).0: std::slice::Iter<'_, T>);
+ _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind: bb11];
+ }
+
+ bb5: {
+ StorageDead(_17);
+ _19 = discriminant(_18);
+ switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10];
+ }
+
+ bb6: {
+ StorageDead(_18);
+ StorageDead(_15);
+ drop(_2) -> [return: bb7, unwind continue];
+ }
+
+ bb7: {
+ return;
+ }
+
+ 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];
+ }
+
+ bb9: {
+ StorageDead(_22);
+ StorageDead(_21);
+ StorageDead(_18);
+ goto -> bb4;
+ }
+
+ bb10: {
+ unreachable;
+ }
+
+ bb11 (cleanup): {
+ drop(_2) -> [return: bb12, unwind terminate];
+ }
+
+ bb12 (cleanup): {
+ resume;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.rs b/tests/mir-opt/pre-codegen/slice_iter.rs
index ca423ca55..4e954aa34 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.rs
+++ b/tests/mir-opt/pre-codegen/slice_iter.rs
@@ -1,6 +1,7 @@
// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2
// only-64bit
// ignore-debug
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![crate_type = "lib"]
@@ -36,3 +37,18 @@ pub fn reverse_loop<'a, T>(slice: &'a [T], f: impl Fn(&T)) {
f(x)
}
}
+
+// EMIT_MIR slice_iter.enumerated_loop.PreCodegen.after.mir
+pub fn enumerated_loop<'a, T>(slice: &'a [T], f: impl Fn(usize, &T)) {
+ for (i, x) in slice.iter().enumerate() {
+ f(i, x)
+ }
+}
+
+// EMIT_MIR slice_iter.range_loop.PreCodegen.after.mir
+pub fn range_loop<'a, T>(slice: &'a [T], f: impl Fn(usize, &T)) {
+ for i in 0..slice.len() {
+ let x = &slice[i];
+ f(i, x)
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir
deleted file mode 100644
index a1431d473..000000000
--- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir
+++ /dev/null
@@ -1,17 +0,0 @@
-// MIR for `slice_iter_mut_next_back` after PreCodegen
-
-fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut T> {
- debug it => _1; // in scope 0 at $DIR/slice_iter.rs:+0:40: +0:42
- let mut _0: std::option::Option<&mut T>; // return place in scope 0 at $DIR/slice_iter.rs:+0:80: +0:97
-
- bb0: {
- _0 = <std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back(_1) -> bb1; // scope 0 at $DIR/slice_iter.rs:+1:5: +1:19
- // mir::Constant
- // + span: $DIR/slice_iter.rs:23:8: 23:17
- // + literal: Const { ty: for<'a> fn(&'a mut std::slice::IterMut<'_, T>) -> Option<<std::slice::IterMut<'_, T> as Iterator>::Item> {<std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back}, val: Value(<ZST>) }
- }
-
- bb1: {
- return; // scope 0 at $DIR/slice_iter.rs:+2:2: +2:2
- }
-}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir
new file mode 100644
index 000000000..0471d0757
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,14 @@
+// MIR for `slice_iter_mut_next_back` after PreCodegen
+
+fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut T> {
+ debug it => _1;
+ let mut _0: std::option::Option<&mut T>;
+
+ bb0: {
+ _0 = <std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back(_1) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir
new file mode 100644
index 000000000..386f3a9ed
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,14 @@
+// MIR for `slice_iter_mut_next_back` after PreCodegen
+
+fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut T> {
+ debug it => _1;
+ let mut _0: std::option::Option<&mut T>;
+
+ bb0: {
+ _0 = <std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back(_1) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.mir
deleted file mode 100644
index d2a963cad..000000000
--- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.mir
+++ /dev/null
@@ -1,17 +0,0 @@
-// MIR for `slice_iter_next` after PreCodegen
-
-fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
- debug it => _1; // in scope 0 at $DIR/slice_iter.rs:+0:31: +0:33
- let mut _0: std::option::Option<&T>; // return place in scope 0 at $DIR/slice_iter.rs:+0:68: +0:81
-
- bb0: {
- _0 = <std::slice::Iter<'_, T> as Iterator>::next(_1) -> bb1; // scope 0 at $DIR/slice_iter.rs:+1:5: +1:14
- // mir::Constant
- // + span: $DIR/slice_iter.rs:18:8: 18:12
- // + literal: Const { ty: for<'a> fn(&'a mut std::slice::Iter<'_, T>) -> Option<<std::slice::Iter<'_, T> as Iterator>::Item> {<std::slice::Iter<'_, T> as Iterator>::next}, val: Value(<ZST>) }
- }
-
- bb1: {
- return; // scope 0 at $DIR/slice_iter.rs:+2:2: +2:2
- }
-}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir
new file mode 100644
index 000000000..8c0209ae1
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,14 @@
+// MIR for `slice_iter_next` after PreCodegen
+
+fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
+ debug it => _1;
+ let mut _0: std::option::Option<&T>;
+
+ bb0: {
+ _0 = <std::slice::Iter<'_, T> as Iterator>::next(_1) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir
new file mode 100644
index 000000000..e76ec0039
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,14 @@
+// MIR for `slice_iter_next` after PreCodegen
+
+fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
+ debug it => _1;
+ let mut _0: std::option::Option<&T>;
+
+ bb0: {
+ _0 = <std::slice::Iter<'_, T> as Iterator>::next(_1) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ return;
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir
new file mode 100644
index 000000000..b9329520b
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir
@@ -0,0 +1,19 @@
+// MIR for `outer` after PreCodegen
+
+fn outer(_1: u8) -> u8 {
+ debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15
+ let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26
+ let _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13
+
+ bb0: {
+ _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13
+ _0 = inner(_2) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/spans.rs:11:5: 11:14
+ // mir::Constant
+ // + span: $DIR/spans.rs:11:5: 11:10
+ // + literal: Const { ty: for<'a> fn(&'a u8) -> u8 {inner}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+ return; // scope 0 at $DIR/spans.rs:12:2: 12:2
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir
new file mode 100644
index 000000000..1e20b1be5
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir
@@ -0,0 +1,19 @@
+// MIR for `outer` after PreCodegen
+
+fn outer(_1: u8) -> u8 {
+ debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15
+ let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26
+ let _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13
+
+ bb0: {
+ _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13
+ _0 = inner(_2) -> [return: bb1, unwind continue]; // scope 0 at $DIR/spans.rs:11:5: 11:14
+ // mir::Constant
+ // + span: $DIR/spans.rs:11:5: 11:10
+ // + literal: Const { ty: for<'a> fn(&'a u8) -> u8 {inner}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+ return; // scope 0 at $DIR/spans.rs:12:2: 12:2
+ }
+}
diff --git a/tests/mir-opt/pre-codegen/spans.rs b/tests/mir-opt/pre-codegen/spans.rs
new file mode 100644
index 000000000..6ae9935ee
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/spans.rs
@@ -0,0 +1,16 @@
+// Test that the comments we emit in MIR opts are accurate.
+//
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// compile-flags: -Zmir-include-spans
+// ignore-wasm32
+
+#![crate_type = "lib"]
+
+// EMIT_MIR spans.outer.PreCodegen.after.mir
+pub fn outer(v: u8) -> u8 {
+ inner(&v)
+}
+
+pub fn inner(x: &u8) -> u8 {
+ *x
+}
diff --git a/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir
index 53971b4cf..0bf4a2670 100644
--- a/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir
@@ -1,70 +1,70 @@
// MIR for `new` after PreCodegen
fn new(_1: Result<T, E>) -> Result<T, E> {
- debug x => _1; // in scope 0 at $DIR/try_identity.rs:+0:14: +0:15
- let mut _0: std::result::Result<T, E>; // return place in scope 0 at $DIR/try_identity.rs:+0:34: +0:46
- let mut _2: std::ops::ControlFlow<E, T>; // in scope 0 at $DIR/try_identity.rs:+2:15: +7:10
- let mut _3: isize; // in scope 0 at $DIR/try_identity.rs:+4:17: +4:22
- let _4: T; // in scope 0 at $DIR/try_identity.rs:+4:20: +4:21
- let _5: E; // in scope 0 at $DIR/try_identity.rs:+5:21: +5:22
- let mut _6: isize; // in scope 0 at $DIR/try_identity.rs:+8:13: +8:37
- let _7: T; // in scope 0 at $DIR/try_identity.rs:+8:35: +8:36
- let _8: E; // in scope 0 at $DIR/try_identity.rs:+9:32: +9:33
+ debug x => _1;
+ let mut _0: std::result::Result<T, E>;
+ let mut _2: isize;
+ let _3: T;
+ let mut _4: std::ops::ControlFlow<E, T>;
+ let _5: E;
+ let mut _6: isize;
+ let _7: T;
+ let _8: E;
scope 1 {
- debug v => _4; // in scope 1 at $DIR/try_identity.rs:+4:20: +4:21
+ debug v => _3;
}
scope 2 {
- debug e => _5; // in scope 2 at $DIR/try_identity.rs:+5:21: +5:22
+ debug e => _5;
}
scope 3 {
- debug v => _7; // in scope 3 at $DIR/try_identity.rs:+8:35: +8:36
+ debug v => _7;
}
scope 4 {
- debug e => _8; // in scope 4 at $DIR/try_identity.rs:+9:32: +9:33
+ debug e => _8;
}
bb0: {
- StorageLive(_2); // scope 0 at $DIR/try_identity.rs:+2:15: +7:10
- _3 = discriminant(_1); // scope 0 at $DIR/try_identity.rs:+3:19: +3:20
- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 0 at $DIR/try_identity.rs:+3:13: +3:20
+ StorageLive(_4);
+ _2 = discriminant(_1);
+ switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb7];
}
bb1: {
- _5 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity.rs:+5:21: +5:22
- _2 = ControlFlow::<E, T>::Break(move _5); // scope 2 at $DIR/try_identity.rs:+5:27: +5:48
- goto -> bb4; // scope 0 at $DIR/try_identity.rs:+5:47: +5:48
+ _3 = move ((_1 as Ok).0: T);
+ _4 = ControlFlow::<E, T>::Continue(move _3);
+ goto -> bb3;
}
bb2: {
- unreachable; // scope 0 at $DIR/try_identity.rs:+3:19: +3:20
+ _5 = move ((_1 as Err).0: E);
+ _4 = ControlFlow::<E, T>::Break(move _5);
+ goto -> bb3;
}
bb3: {
- _4 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity.rs:+4:20: +4:21
- _2 = ControlFlow::<E, T>::Continue(move _4); // scope 1 at $DIR/try_identity.rs:+4:26: +4:50
- goto -> bb4; // scope 0 at $DIR/try_identity.rs:+4:49: +4:50
+ _6 = discriminant(_4);
+ switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb7];
}
bb4: {
- _6 = discriminant(_2); // scope 0 at $DIR/try_identity.rs:+2:15: +7:10
- switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb2]; // scope 0 at $DIR/try_identity.rs:+2:9: +7:10
+ _7 = move ((_4 as Continue).0: T);
+ _0 = Result::<T, E>::Ok(move _7);
+ StorageDead(_4);
+ goto -> bb6;
}
bb5: {
- _8 = move ((_2 as Break).0: E); // scope 0 at $DIR/try_identity.rs:+9:32: +9:33
- _0 = Result::<T, E>::Err(move _8); // scope 4 at $DIR/try_identity.rs:+9:45: +9:51
- StorageDead(_2); // scope 0 at $DIR/try_identity.rs:+12:1: +12:2
- goto -> bb7; // scope 0 at $DIR/try_identity.rs:+12:1: +12:2
+ _8 = move ((_4 as Break).0: E);
+ _0 = Result::<T, E>::Err(move _8);
+ StorageDead(_4);
+ goto -> bb6;
}
bb6: {
- _7 = move ((_2 as Continue).0: T); // scope 0 at $DIR/try_identity.rs:+8:35: +8:36
- _0 = Result::<T, E>::Ok(move _7); // scope 0 at $DIR/try_identity.rs:+1:5: +11:6
- StorageDead(_2); // scope 0 at $DIR/try_identity.rs:+12:1: +12:2
- goto -> bb7; // scope 0 at $DIR/try_identity.rs:+12:1: +12:2
+ return;
}
bb7: {
- return; // scope 0 at $DIR/try_identity.rs:+12:2: +12:2
+ unreachable;
}
}
diff --git a/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir
index e217d1994..7ccb8b043 100644
--- a/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir
@@ -1,40 +1,40 @@
// MIR for `old` after PreCodegen
fn old(_1: Result<T, E>) -> Result<T, E> {
- debug x => _1; // in scope 0 at $DIR/try_identity.rs:+0:14: +0:15
- let mut _0: std::result::Result<T, E>; // return place in scope 0 at $DIR/try_identity.rs:+0:34: +0:46
- let mut _2: isize; // in scope 0 at $DIR/try_identity.rs:+3:13: +3:18
- let _3: T; // in scope 0 at $DIR/try_identity.rs:+3:16: +3:17
- let _4: E; // in scope 0 at $DIR/try_identity.rs:+4:17: +4:18
+ debug x => _1;
+ let mut _0: std::result::Result<T, E>;
+ let mut _2: isize;
+ let _3: T;
+ let _4: E;
scope 1 {
- debug v => _3; // in scope 1 at $DIR/try_identity.rs:+3:16: +3:17
+ debug v => _3;
}
scope 2 {
- debug e => _4; // in scope 2 at $DIR/try_identity.rs:+4:17: +4:18
+ debug e => _4;
}
bb0: {
- _2 = discriminant(_1); // scope 0 at $DIR/try_identity.rs:+2:15: +2:16
- switchInt(move _2) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 0 at $DIR/try_identity.rs:+2:9: +2:16
+ _2 = discriminant(_1);
+ switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4];
}
bb1: {
- _4 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity.rs:+4:17: +4:18
- _0 = Result::<T, E>::Err(move _4); // scope 2 at $DIR/try_identity.rs:+4:30: +4:36
- goto -> bb4; // scope 0 at $DIR/try_identity.rs:+7:1: +7:2
+ _3 = move ((_1 as Ok).0: T);
+ _0 = Result::<T, E>::Ok(move _3);
+ goto -> bb3;
}
bb2: {
- unreachable; // scope 0 at $DIR/try_identity.rs:+2:15: +2:16
+ _4 = move ((_1 as Err).0: E);
+ _0 = Result::<T, E>::Err(move _4);
+ goto -> bb3;
}
bb3: {
- _3 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity.rs:+3:16: +3:17
- _0 = Result::<T, E>::Ok(move _3); // scope 0 at $DIR/try_identity.rs:+1:5: +6:6
- goto -> bb4; // scope 0 at $DIR/try_identity.rs:+7:1: +7:2
+ return;
}
bb4: {
- return; // scope 0 at $DIR/try_identity.rs:+7:2: +7:2
+ unreachable;
}
}