Skip to content

Commit 015a824

Browse files
committedAug 22, 2022
Auto merge of #99762 - Nilstrieb:unreachable-prop, r=oli-obk
UnreachableProp: Preserve unreachable branches for multiple targets Before, UnreachablePropagation removed all unreachable branches. This was a pessimization, as it removed information about reachability that was used later in the optimization pipeline. For example, this code ```rust pub enum Two { A, B } pub fn identity(x: Two) -> Two { match x { Two::A => Two::A, Two::B => Two::B, } } ``` basically has `switchInt() -> [0: 0, 1: 1, otherwise: unreachable]` for the match. This allows it to be transformed into a simple `x`. If we remove the unreachable branch, the transformation becomes illegal. This was the problem keeping `UnreachablePropagation` from being enabled, so we can enable it now. Something similar already happened in #77800, but it did not show a perf improvement there. Let's try it again anyways! Fixes #68105, although that issue has been fixed for a long time (see #77680).
2 parents a785176 + 18bfcd3 commit 015a824

File tree

25 files changed

+315
-181
lines changed

25 files changed

+315
-181
lines changed
 

‎compiler/rustc_mir_transform/src/unreachable_prop.rs

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ pub struct UnreachablePropagation;
1212

1313
impl MirPass<'_> for UnreachablePropagation {
1414
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
15-
// Enable only under -Zmir-opt-level=4 as in some cases (check the deeply-nested-opt
16-
// perf benchmark) LLVM may spend quite a lot of time optimizing the generated code.
17-
sess.mir_opt_level() >= 4
15+
// Enable only under -Zmir-opt-level=2 as this can make programs less debuggable.
16+
sess.mir_opt_level() >= 2
1817
}
1918

2019
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
@@ -38,7 +37,19 @@ impl MirPass<'_> for UnreachablePropagation {
3837
}
3938
}
4039

40+
// We do want do keep some unreachable blocks, but make them empty.
41+
for bb in unreachable_blocks {
42+
if !tcx.consider_optimizing(|| {
43+
format!("UnreachablePropagation {:?} ", body.source.def_id())
44+
}) {
45+
break;
46+
}
47+
48+
body.basic_blocks_mut()[bb].statements.clear();
49+
}
50+
4151
let replaced = !replacements.is_empty();
52+
4253
for (bb, terminator_kind) in replacements {
4354
if !tcx.consider_optimizing(|| {
4455
format!("UnreachablePropagation {:?} ", body.source.def_id())
@@ -57,42 +68,55 @@ impl MirPass<'_> for UnreachablePropagation {
5768

5869
fn remove_successors<'tcx, F>(
5970
terminator_kind: &TerminatorKind<'tcx>,
60-
predicate: F,
71+
is_unreachable: F,
6172
) -> Option<TerminatorKind<'tcx>>
6273
where
6374
F: Fn(BasicBlock) -> bool,
6475
{
65-
let terminator = match *terminator_kind {
66-
TerminatorKind::Goto { target } if predicate(target) => TerminatorKind::Unreachable,
67-
TerminatorKind::SwitchInt { ref discr, switch_ty, ref targets } => {
76+
let terminator = match terminator_kind {
77+
// This will unconditionally run into an unreachable and is therefore unreachable as well.
78+
TerminatorKind::Goto { target } if is_unreachable(*target) => TerminatorKind::Unreachable,
79+
TerminatorKind::SwitchInt { targets, discr, switch_ty } => {
6880
let otherwise = targets.otherwise();
6981

70-
let original_targets_len = targets.iter().len() + 1;
71-
let (mut values, mut targets): (Vec<_>, Vec<_>) =
72-
targets.iter().filter(|(_, bb)| !predicate(*bb)).unzip();
82+
// If all targets are unreachable, we can be unreachable as well.
83+
if targets.all_targets().iter().all(|bb| is_unreachable(*bb)) {
84+
TerminatorKind::Unreachable
85+
} else if is_unreachable(otherwise) {
86+
// If there are multiple targets, don't delete unreachable branches (like an unreachable otherwise)
87+
// unless otherwise is unrachable, in which case deleting a normal branch causes it to be merged with
88+
// the otherwise, keeping its unreachable.
89+
// This looses information about reachability causing worse codegen.
90+
// For example (see src/test/codegen/match-optimizes-away.rs)
91+
//
92+
// pub enum Two { A, B }
93+
// pub fn identity(x: Two) -> Two {
94+
// match x {
95+
// Two::A => Two::A,
96+
// Two::B => Two::B,
97+
// }
98+
// }
99+
//
100+
// This generates a `switchInt() -> [0: 0, 1: 1, otherwise: unreachable]`, which allows us or LLVM to
101+
// turn it into just `x` later. Without the unreachable, such a transformation would be illegal.
102+
// If the otherwise branch is unreachable, we can delete all other unreacahble targets, as they will
103+
// still point to the unreachable and therefore not lose reachability information.
104+
let reachable_iter = targets.iter().filter(|(_, bb)| !is_unreachable(*bb));
73105

74-
if !predicate(otherwise) {
75-
targets.push(otherwise);
76-
} else {
77-
values.pop();
78-
}
106+
let new_targets = SwitchTargets::new(reachable_iter, otherwise);
79107

80-
let retained_targets_len = targets.len();
108+
// No unreachable branches were removed.
109+
if new_targets.all_targets().len() == targets.all_targets().len() {
110+
return None;
111+
}
81112

82-
if targets.is_empty() {
83-
TerminatorKind::Unreachable
84-
} else if targets.len() == 1 {
85-
TerminatorKind::Goto { target: targets[0] }
86-
} else if original_targets_len != retained_targets_len {
87113
TerminatorKind::SwitchInt {
88114
discr: discr.clone(),
89-
switch_ty,
90-
targets: SwitchTargets::new(
91-
values.iter().copied().zip(targets.iter().copied()),
92-
*targets.last().unwrap(),
93-
),
115+
switch_ty: *switch_ty,
116+
targets: new_targets,
94117
}
95118
} else {
119+
// If the otherwise branch is reachable, we don't want to delete any unreachable branches.
96120
return None;
97121
}
98122
}

‎src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
5656
discriminant(_2) = 1; // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
5757
_3 = const 1_isize; // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
58-
goto -> bb2; // scope 0 at $DIR/issue-73223.rs:+1:17: +1:30
58+
goto -> bb3; // scope 0 at $DIR/issue-73223.rs:+1:17: +1:30
5959
}
6060

6161
bb1: {
@@ -66,6 +66,10 @@
6666
}
6767

6868
bb2: {
69+
unreachable; // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
70+
}
71+
72+
bb3: {
6973
StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:+2:14: +2:15
7074
_4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:+2:14: +2:15
7175
_1 = _4; // scope 2 at $DIR/issue-73223.rs:+2:20: +2:21
@@ -108,10 +112,10 @@
108112
StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
109113
_15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
110114
StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
111-
switchInt(move _15) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
115+
switchInt(move _15) -> [false: bb5, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
112116
}
113117

114-
bb3: {
118+
bb4: {
115119
StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
116120
Deinit(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
117121
discriminant(_20) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -141,7 +145,7 @@
141145
// + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) }
142146
}
143147

144-
bb4: {
148+
bb5: {
145149
nop; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
146150
StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
147151
StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL

‎src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
5656
discriminant(_2) = 1; // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
5757
_3 = const 1_isize; // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
58-
goto -> bb2; // scope 0 at $DIR/issue-73223.rs:+1:17: +1:30
58+
goto -> bb3; // scope 0 at $DIR/issue-73223.rs:+1:17: +1:30
5959
}
6060

6161
bb1: {
@@ -66,6 +66,10 @@
6666
}
6767

6868
bb2: {
69+
unreachable; // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
70+
}
71+
72+
bb3: {
6973
StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:+2:14: +2:15
7074
_4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:+2:14: +2:15
7175
_1 = _4; // scope 2 at $DIR/issue-73223.rs:+2:20: +2:21
@@ -108,10 +112,10 @@
108112
StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
109113
_15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
110114
StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
111-
switchInt(move _15) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
115+
switchInt(move _15) -> [false: bb5, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
112116
}
113117

114-
bb3: {
118+
bb4: {
115119
StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
116120
Deinit(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
117121
discriminant(_20) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -141,7 +145,7 @@
141145
// + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) }
142146
}
143147

144-
bb4: {
148+
bb5: {
145149
nop; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
146150
StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
147151
StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL

‎src/test/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.32bit.diff

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@
88

99
bb0: {
1010
_2 = discriminant(_1); // scope 0 at $DIR/matches_u8.rs:+1:11: +1:12
11-
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_u8.rs:+1:5: +1:12
11+
switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/matches_u8.rs:+1:5: +1:12
1212
}
1313

1414
bb1: {
1515
_0 = const 1_u8; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
16-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
16+
goto -> bb4; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
1717
}
1818

1919
bb2: {
20-
_0 = const 0_u8; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
21-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
20+
unreachable; // scope 0 at $DIR/matches_u8.rs:+1:11: +1:12
2221
}
2322

2423
bb3: {
24+
_0 = const 0_u8; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
25+
goto -> bb4; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
26+
}
27+
28+
bb4: {
2529
return; // scope 0 at $DIR/matches_u8.rs:+5:2: +5:2
2630
}
2731
}

‎src/test/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.64bit.diff

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@
88

99
bb0: {
1010
_2 = discriminant(_1); // scope 0 at $DIR/matches_u8.rs:+1:11: +1:12
11-
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_u8.rs:+1:5: +1:12
11+
switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/matches_u8.rs:+1:5: +1:12
1212
}
1313

1414
bb1: {
1515
_0 = const 1_u8; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
16-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
16+
goto -> bb4; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
1717
}
1818

1919
bb2: {
20-
_0 = const 0_u8; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
21-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
20+
unreachable; // scope 0 at $DIR/matches_u8.rs:+1:11: +1:12
2221
}
2322

2423
bb3: {
24+
_0 = const 0_u8; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
25+
goto -> bb4; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
26+
}
27+
28+
bb4: {
2529
return; // scope 0 at $DIR/matches_u8.rs:+5:2: +5:2
2630
}
2731
}

‎src/test/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.32bit.diff

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@
88

99
bb0: {
1010
_2 = discriminant(_1); // scope 0 at $DIR/matches_u8.rs:+1:11: +1:12
11-
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_u8.rs:+1:5: +1:12
11+
switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/matches_u8.rs:+1:5: +1:12
1212
}
1313

1414
bb1: {
1515
_0 = const 1_i8; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
16-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
16+
goto -> bb4; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
1717
}
1818

1919
bb2: {
20-
_0 = const 0_i8; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
21-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
20+
unreachable; // scope 0 at $DIR/matches_u8.rs:+1:11: +1:12
2221
}
2322

2423
bb3: {
24+
_0 = const 0_i8; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
25+
goto -> bb4; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
26+
}
27+
28+
bb4: {
2529
return; // scope 0 at $DIR/matches_u8.rs:+5:2: +5:2
2630
}
2731
}

‎src/test/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.64bit.diff

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@
88

99
bb0: {
1010
_2 = discriminant(_1); // scope 0 at $DIR/matches_u8.rs:+1:11: +1:12
11-
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_u8.rs:+1:5: +1:12
11+
switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/matches_u8.rs:+1:5: +1:12
1212
}
1313

1414
bb1: {
1515
_0 = const 1_i8; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
16-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
16+
goto -> bb4; // scope 0 at $DIR/matches_u8.rs:+3:17: +3:18
1717
}
1818

1919
bb2: {
20-
_0 = const 0_i8; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
21-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
20+
unreachable; // scope 0 at $DIR/matches_u8.rs:+1:11: +1:12
2221
}
2322

2423
bb3: {
24+
_0 = const 0_i8; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
25+
goto -> bb4; // scope 0 at $DIR/matches_u8.rs:+2:17: +2:18
26+
}
27+
28+
bb4: {
2529
return; // scope 0 at $DIR/matches_u8.rs:+5:2: +5:2
2630
}
2731
}

‎src/test/mir-opt/separate_const_switch.identity.ConstProp.diff

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
_4 = _1; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:9
5858
StorageLive(_10); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
5959
_10 = discriminant(_4); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
60-
switchInt(move _10) -> [0_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
60+
switchInt(move _10) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
6161
}
6262

6363
bb1: {
@@ -74,6 +74,10 @@
7474
}
7575

7676
bb2: {
77+
unreachable; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
78+
}
79+
80+
bb3: {
7781
StorageLive(_6); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10
7882
_6 = ((_3 as Break).0: std::result::Result<std::convert::Infallible, i32>); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10
7983
StorageLive(_8); // scope 2 at $DIR/separate_const_switch.rs:+1:9: +1:10
@@ -97,7 +101,7 @@
97101
return; // scope 0 at $DIR/separate_const_switch.rs:+2:2: +2:2
98102
}
99103

100-
bb3: {
104+
bb4: {
101105
StorageLive(_13); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
102106
_13 = move ((_4 as Err).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
103107
StorageLive(_14); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
@@ -115,16 +119,16 @@
115119
StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
116120
StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10
117121
- _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
118-
- switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
122+
- switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
119123
+ _5 = const 1_isize; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
120-
+ switchInt(const 1_isize) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
124+
+ switchInt(const 1_isize) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
121125
}
122126

123-
bb4: {
127+
bb5: {
124128
unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
125129
}
126130

127-
bb5: {
131+
bb6: {
128132
StorageLive(_11); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
129133
_11 = move ((_4 as Ok).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
130134
StorageLive(_12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL
@@ -137,9 +141,9 @@
137141
StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
138142
StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10
139143
- _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
140-
- switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
144+
- switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
141145
+ _5 = const 0_isize; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
142-
+ switchInt(const 0_isize) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
146+
+ switchInt(const 0_isize) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
143147
}
144148
}
145149

‎src/test/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@
5757
_4 = _1; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:9
5858
StorageLive(_10); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
5959
_10 = discriminant(_4); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
60-
- switchInt(move _10) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
61-
+ switchInt(move _10) -> [0_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
60+
- switchInt(move _10) -> [0_isize: bb7, 1_isize: bb5, otherwise: bb6]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
61+
+ switchInt(move _10) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
6262
}
6363

6464
bb1: {
6565
- StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
6666
- StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10
6767
- _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
68-
- switchInt(move _5) -> [0_isize: bb2, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
68+
- switchInt(move _5) -> [0_isize: bb2, 1_isize: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
6969
- }
7070
-
7171
- bb2: {
@@ -83,6 +83,11 @@
8383

8484
- bb3: {
8585
+ bb2: {
86+
unreachable; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
87+
}
88+
89+
- bb4: {
90+
+ bb3: {
8691
StorageLive(_6); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10
8792
_6 = ((_3 as Break).0: std::result::Result<std::convert::Infallible, i32>); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10
8893
StorageLive(_8); // scope 2 at $DIR/separate_const_switch.rs:+1:9: +1:10
@@ -106,8 +111,8 @@
106111
return; // scope 0 at $DIR/separate_const_switch.rs:+2:2: +2:2
107112
}
108113

109-
- bb4: {
110-
+ bb3: {
114+
- bb5: {
115+
+ bb4: {
111116
StorageLive(_13); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
112117
_13 = move ((_4 as Err).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
113118
StorageLive(_14); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
@@ -126,16 +131,16 @@
126131
+ StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
127132
+ StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10
128133
+ _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
129-
+ switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
134+
+ switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
130135
}
131136

132-
- bb5: {
133-
+ bb4: {
137+
- bb6: {
138+
+ bb5: {
134139
unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
135140
}
136141

137-
- bb6: {
138-
+ bb5: {
142+
- bb7: {
143+
+ bb6: {
139144
StorageLive(_11); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
140145
_11 = move ((_4 as Ok).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
141146
StorageLive(_12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL
@@ -149,7 +154,7 @@
149154
+ StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
150155
+ StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10
151156
+ _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
152-
+ switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
157+
+ switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10
153158
}
154159
}
155160

‎src/test/mir-opt/separate_const_switch.too_complex.ConstProp.diff

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
bb0: {
3131
StorageLive(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
3232
_3 = discriminant(_1); // scope 0 at $DIR/separate_const_switch.rs:+6:15: +6:16
33-
switchInt(move _3) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/separate_const_switch.rs:+6:9: +6:16
33+
switchInt(move _3) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+6:9: +6:16
3434
}
3535

3636
bb1: {
@@ -44,12 +44,16 @@
4444
StorageDead(_7); // scope 2 at $DIR/separate_const_switch.rs:+8:43: +8:44
4545
StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:+8:43: +8:44
4646
- _8 = discriminant(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
47-
- switchInt(move _8) -> [0_isize: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
47+
- switchInt(move _8) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
4848
+ _8 = const 1_isize; // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
49-
+ switchInt(const 1_isize) -> [0_isize: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
49+
+ switchInt(const 1_isize) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
5050
}
5151

5252
bb2: {
53+
unreachable; // scope 0 at $DIR/separate_const_switch.rs:+6:15: +6:16
54+
}
55+
56+
bb3: {
5357
StorageLive(_4); // scope 0 at $DIR/separate_const_switch.rs:+7:16: +7:17
5458
_4 = ((_1 as Ok).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+7:16: +7:17
5559
StorageLive(_5); // scope 1 at $DIR/separate_const_switch.rs:+7:44: +7:45
@@ -60,21 +64,25 @@
6064
StorageDead(_5); // scope 1 at $DIR/separate_const_switch.rs:+7:45: +7:46
6165
StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+7:45: +7:46
6266
- _8 = discriminant(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
63-
- switchInt(move _8) -> [0_isize: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
67+
- switchInt(move _8) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
6468
+ _8 = const 0_isize; // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
65-
+ switchInt(const 0_isize) -> [0_isize: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
69+
+ switchInt(const 0_isize) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
6670
}
6771

68-
bb3: {
72+
bb4: {
6973
StorageLive(_11); // scope 0 at $DIR/separate_const_switch.rs:+12:28: +12:29
7074
_11 = ((_2 as Break).0: usize); // scope 0 at $DIR/separate_const_switch.rs:+12:28: +12:29
7175
Deinit(_0); // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38
7276
discriminant(_0) = 0; // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38
7377
StorageDead(_11); // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
74-
goto -> bb5; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
78+
goto -> bb7; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
7579
}
7680

77-
bb4: {
81+
bb5: {
82+
unreachable; // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
83+
}
84+
85+
bb6: {
7886
StorageLive(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32
7987
_9 = ((_2 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32
8088
StorageLive(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:42: +11:43
@@ -84,10 +92,10 @@
8492
discriminant(_0) = 1; // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44
8593
StorageDead(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:43: +11:44
8694
StorageDead(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
87-
goto -> bb5; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
95+
goto -> bb7; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
8896
}
8997

90-
bb5: {
98+
bb7: {
9199
StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:+14:1: +14:2
92100
return; // scope 0 at $DIR/separate_const_switch.rs:+14:2: +14:2
93101
}

‎src/test/mir-opt/separate_const_switch.too_complex.PreCodegen.after.mir

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn too_complex(_1: Result<i32, usize>) -> Option<i32> {
2727
bb0: {
2828
StorageLive(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
2929
_3 = discriminant(_1); // scope 0 at $DIR/separate_const_switch.rs:+6:15: +6:16
30-
switchInt(move _3) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/separate_const_switch.rs:+6:9: +6:16
30+
switchInt(move _3) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+6:9: +6:16
3131
}
3232

3333
bb1: {
@@ -37,10 +37,14 @@ fn too_complex(_1: Result<i32, usize>) -> Option<i32> {
3737
Deinit(_0); // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38
3838
discriminant(_0) = 0; // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38
3939
StorageDead(_9); // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
40-
goto -> bb3; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
40+
goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
4141
}
4242

4343
bb2: {
44+
unreachable; // scope 0 at $DIR/separate_const_switch.rs:+6:15: +6:16
45+
}
46+
47+
bb3: {
4448
StorageLive(_4); // scope 0 at $DIR/separate_const_switch.rs:+7:16: +7:17
4549
_4 = ((_1 as Ok).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+7:16: +7:17
4650
StorageLive(_5); // scope 1 at $DIR/separate_const_switch.rs:+7:44: +7:45
@@ -59,10 +63,10 @@ fn too_complex(_1: Result<i32, usize>) -> Option<i32> {
5963
discriminant(_0) = 1; // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44
6064
StorageDead(_8); // scope 3 at $DIR/separate_const_switch.rs:+11:43: +11:44
6165
StorageDead(_7); // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
62-
goto -> bb3; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
66+
goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
6367
}
6468

65-
bb3: {
69+
bb4: {
6670
StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:+14:1: +14:2
6771
return; // scope 0 at $DIR/separate_const_switch.rs:+14:2: +14:2
6872
}

‎src/test/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
bb0: {
3131
StorageLive(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
3232
_3 = discriminant(_1); // scope 0 at $DIR/separate_const_switch.rs:+6:15: +6:16
33-
switchInt(move _3) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/separate_const_switch.rs:+6:9: +6:16
33+
switchInt(move _3) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+6:9: +6:16
3434
}
3535

3636
bb1: {
@@ -43,12 +43,16 @@
4343
discriminant(_2) = 1; // scope 2 at $DIR/separate_const_switch.rs:+8:23: +8:44
4444
StorageDead(_7); // scope 2 at $DIR/separate_const_switch.rs:+8:43: +8:44
4545
StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:+8:43: +8:44
46-
- goto -> bb3; // scope 0 at $DIR/separate_const_switch.rs:+8:43: +8:44
46+
- goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+8:43: +8:44
4747
+ _8 = discriminant(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
48-
+ switchInt(move _8) -> [0_isize: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
48+
+ switchInt(move _8) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
4949
}
5050

5151
bb2: {
52+
unreachable; // scope 0 at $DIR/separate_const_switch.rs:+6:15: +6:16
53+
}
54+
55+
bb3: {
5256
StorageLive(_4); // scope 0 at $DIR/separate_const_switch.rs:+7:16: +7:17
5357
_4 = ((_1 as Ok).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+7:16: +7:17
5458
StorageLive(_5); // scope 1 at $DIR/separate_const_switch.rs:+7:44: +7:45
@@ -58,28 +62,33 @@
5862
discriminant(_2) = 0; // scope 1 at $DIR/separate_const_switch.rs:+7:22: +7:46
5963
StorageDead(_5); // scope 1 at $DIR/separate_const_switch.rs:+7:45: +7:46
6064
StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+7:45: +7:46
61-
- goto -> bb3; // scope 0 at $DIR/separate_const_switch.rs:+7:45: +7:46
65+
- goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+7:45: +7:46
6266
- }
6367
-
64-
- bb3: {
68+
- bb4: {
6569
_8 = discriminant(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
66-
- switchInt(move _8) -> [0_isize: bb5, otherwise: bb4]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
67-
+ switchInt(move _8) -> [0_isize: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
70+
- switchInt(move _8) -> [0_isize: bb7, 1_isize: bb5, otherwise: bb6]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
71+
+ switchInt(move _8) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6
6872
}
6973

70-
- bb4: {
71-
+ bb3: {
74+
- bb5: {
75+
+ bb4: {
7276
StorageLive(_11); // scope 0 at $DIR/separate_const_switch.rs:+12:28: +12:29
7377
_11 = ((_2 as Break).0: usize); // scope 0 at $DIR/separate_const_switch.rs:+12:28: +12:29
7478
Deinit(_0); // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38
7579
discriminant(_0) = 0; // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38
7680
StorageDead(_11); // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
77-
- goto -> bb6; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
78-
+ goto -> bb5; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
81+
- goto -> bb8; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
82+
+ goto -> bb7; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38
7983
}
8084

81-
- bb5: {
82-
+ bb4: {
85+
- bb6: {
86+
+ bb5: {
87+
unreachable; // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6
88+
}
89+
90+
- bb7: {
91+
+ bb6: {
8392
StorageLive(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32
8493
_9 = ((_2 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32
8594
StorageLive(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:42: +11:43
@@ -89,12 +98,12 @@
8998
discriminant(_0) = 1; // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44
9099
StorageDead(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:43: +11:44
91100
StorageDead(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
92-
- goto -> bb6; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
93-
+ goto -> bb5; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
101+
- goto -> bb8; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
102+
+ goto -> bb7; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44
94103
}
95104

96-
- bb6: {
97-
+ bb5: {
105+
- bb8: {
106+
+ bb7: {
98107
StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:+14:1: +14:2
99108
return; // scope 0 at $DIR/separate_const_switch.rs:+14:2: +14:2
100109
}

‎src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.32bit.diff

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,27 @@
1616

1717
bb0: {
1818
_2 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12
19-
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:5: +1:12
19+
switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:5: +1:12
2020
}
2121

2222
bb1: {
2323
((_0 as Some).0: std::boxed::Box<()>) = move ((_1 as Some).0: std::boxed::Box<()>); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:14: +3:15
2424
Deinit(_0); // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:20: +3:27
2525
discriminant(_0) = 1; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:20: +3:27
26-
goto -> bb3; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:26: +3:27
26+
goto -> bb4; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:26: +3:27
2727
}
2828

2929
bb2: {
30+
unreachable; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12
31+
}
32+
33+
bb3: {
3034
Deinit(_0); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
3135
discriminant(_0) = 0; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
32-
goto -> bb3; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
36+
goto -> bb4; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
3337
}
3438

35-
bb3: {
39+
bb4: {
3640
return; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:2: +5:2
3741
}
3842
}

‎src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.64bit.diff

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,27 @@
1616

1717
bb0: {
1818
_2 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12
19-
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:5: +1:12
19+
switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:5: +1:12
2020
}
2121

2222
bb1: {
2323
((_0 as Some).0: std::boxed::Box<()>) = move ((_1 as Some).0: std::boxed::Box<()>); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:14: +3:15
2424
Deinit(_0); // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:20: +3:27
2525
discriminant(_0) = 1; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:20: +3:27
26-
goto -> bb3; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:26: +3:27
26+
goto -> bb4; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:26: +3:27
2727
}
2828

2929
bb2: {
30+
unreachable; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12
31+
}
32+
33+
bb3: {
3034
Deinit(_0); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
3135
discriminant(_0) = 0; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
32-
goto -> bb3; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
36+
goto -> bb4; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
3337
}
3438

35-
bb3: {
39+
bb4: {
3640
return; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:2: +5:2
3741
}
3842
}

‎src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
+ nop; // scope 4 at $DIR/simplify_try.rs:9:5: 9:6
5151
+ nop; // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33
5252
_5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
53-
switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
53+
switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
5454
}
5555

5656
bb1: {
@@ -80,6 +80,10 @@
8080
}
8181

8282
bb2: {
83+
unreachable; // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
84+
}
85+
86+
bb3: {
8387
StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
8488
nop; // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
8589
StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50

‎src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
_3 = move _4; // scope 4 at $DIR/simplify_try.rs:9:5: 9:6
4242
StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33
4343
_5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
44-
switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
44+
switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
4545
}
4646

4747
bb1: {
@@ -61,6 +61,10 @@
6161
}
6262

6363
bb2: {
64+
unreachable; // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
65+
}
66+
67+
bb3: {
6468
StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
6569
_6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
6670
StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50

‎src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn try_identity(_1: Result<u32, i32>) -> Result<u32, i32> {
4040
_3 = move _4; // scope 4 at $DIR/simplify_try.rs:9:5: 9:6
4141
StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33
4242
_5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
43-
switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
43+
switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
4444
}
4545

4646
bb1: {
@@ -60,6 +60,10 @@ fn try_identity(_1: Result<u32, i32>) -> Result<u32, i32> {
6060
}
6161

6262
bb2: {
63+
unreachable; // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
64+
}
65+
66+
bb3: {
6367
StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
6468
_6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
6569
StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50

‎src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn try_identity(_1: Result<u32, i32>) -> Result<u32, i32> {
3030
bb0: {
3131
_2 = _1; // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
3232
_3 = discriminant(_2); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
33-
switchInt(move _3) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
33+
switchInt(move _3) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
3434
}
3535

3636
bb1: {
@@ -41,6 +41,10 @@ fn try_identity(_1: Result<u32, i32>) -> Result<u32, i32> {
4141
}
4242

4343
bb2: {
44+
unreachable; // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
45+
}
46+
47+
bb3: {
4448
StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
4549
StorageLive(_5); // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50
4650
StorageLive(_6); // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49

‎src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ fn process_never(_1: *const !) -> () {
1111
}
1212

1313
bb0: {
14-
StorageLive(_2); // scope 0 at $DIR/uninhabited-enum.rs:+1:8: +1:14
15-
StorageDead(_2); // scope 0 at $DIR/uninhabited-enum.rs:+2:1: +2:2
1614
unreachable; // scope 0 at $DIR/uninhabited-enum.rs:+0:39: +2:2
1715
}
1816
}

‎src/test/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ fn main() -> () {
1818
Deinit(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19
1919
discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19
2020
_3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19
21+
switchInt(move _3) -> [2_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +1:19
22+
}
23+
24+
bb1: {
2125
StorageLive(_5); // scope 0 at $DIR/uninhabited_enum_branching.rs:+4:21: +4:24
2226
_5 = const "C"; // scope 0 at $DIR/uninhabited_enum_branching.rs:+4:21: +4:24
2327
// mir::Constant
@@ -32,29 +36,37 @@ fn main() -> () {
3236
Deinit(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19
3337
discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19
3438
_8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19
35-
switchInt(move _8) -> [4_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19
39+
switchInt(move _8) -> [4_isize: bb5, 5_isize: bb3, otherwise: bb4]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19
3640
}
3741

38-
bb1: {
42+
bb2: {
43+
unreachable; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19
44+
}
45+
46+
bb3: {
3947
StorageLive(_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:21: +9:24
4048
_9 = const "E"; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:21: +9:24
4149
// mir::Constant
4250
// + span: $DIR/uninhabited_enum_branching.rs:28:21: 28:24
4351
// + literal: Const { ty: &str, val: Value(Slice(..)) }
4452
_6 = &(*_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:21: +9:24
4553
StorageDead(_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24
46-
goto -> bb3; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24
54+
goto -> bb6; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24
4755
}
4856

49-
bb2: {
57+
bb4: {
58+
unreachable; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19
59+
}
60+
61+
bb5: {
5062
_6 = const "D"; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24
5163
// mir::Constant
5264
// + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24
5365
// + literal: Const { ty: &str, val: Value(Slice(..)) }
54-
goto -> bb3; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24
66+
goto -> bb6; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24
5567
}
5668

57-
bb3: {
69+
bb6: {
5870
StorageDead(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+10:6: +10:7
5971
StorageDead(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:+10:6: +10:7
6072
_0 = const (); // scope 0 at $DIR/uninhabited_enum_branching.rs:+0:11: +11:2

‎src/test/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
Deinit(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19
2020
discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19
2121
_3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19
22-
- switchInt(move _3) -> [0_isize: bb2, 1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +1:19
23-
+ switchInt(move _3) -> bb1; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +1:19
22+
- switchInt(move _3) -> [0_isize: bb3, 1_isize: bb4, 2_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +1:19
23+
+ switchInt(move _3) -> [2_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +1:19
2424
}
2525

2626
bb1: {
@@ -31,59 +31,67 @@
3131
// + literal: Const { ty: &str, val: Value(Slice(..)) }
3232
_1 = &(*_5); // scope 0 at $DIR/uninhabited_enum_branching.rs:+4:21: +4:24
3333
StorageDead(_5); // scope 0 at $DIR/uninhabited_enum_branching.rs:+4:23: +4:24
34-
goto -> bb4; // scope 0 at $DIR/uninhabited_enum_branching.rs:+4:23: +4:24
34+
goto -> bb5; // scope 0 at $DIR/uninhabited_enum_branching.rs:+4:23: +4:24
3535
}
3636

3737
bb2: {
38+
unreachable; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19
39+
}
40+
41+
bb3: {
3842
_1 = const "A(Empty)"; // scope 0 at $DIR/uninhabited_enum_branching.rs:+2:24: +2:34
3943
// mir::Constant
4044
// + span: $DIR/uninhabited_enum_branching.rs:21:24: 21:34
4145
// + literal: Const { ty: &str, val: Value(Slice(..)) }
42-
goto -> bb4; // scope 0 at $DIR/uninhabited_enum_branching.rs:+2:24: +2:34
46+
goto -> bb5; // scope 0 at $DIR/uninhabited_enum_branching.rs:+2:24: +2:34
4347
}
4448

45-
bb3: {
49+
bb4: {
4650
StorageLive(_4); // scope 0 at $DIR/uninhabited_enum_branching.rs:+3:24: +3:34
4751
_4 = const "B(Empty)"; // scope 0 at $DIR/uninhabited_enum_branching.rs:+3:24: +3:34
4852
// mir::Constant
4953
// + span: $DIR/uninhabited_enum_branching.rs:22:24: 22:34
5054
// + literal: Const { ty: &str, val: Value(Slice(..)) }
5155
_1 = &(*_4); // scope 0 at $DIR/uninhabited_enum_branching.rs:+3:24: +3:34
5256
StorageDead(_4); // scope 0 at $DIR/uninhabited_enum_branching.rs:+3:33: +3:34
53-
goto -> bb4; // scope 0 at $DIR/uninhabited_enum_branching.rs:+3:33: +3:34
57+
goto -> bb5; // scope 0 at $DIR/uninhabited_enum_branching.rs:+3:33: +3:34
5458
}
5559

56-
bb4: {
60+
bb5: {
5761
StorageDead(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+5:6: +5:7
5862
StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:+5:6: +5:7
5963
StorageLive(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +10:6
6064
StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19
6165
Deinit(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19
6266
discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19
6367
_8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19
64-
switchInt(move _8) -> [4_isize: bb6, otherwise: bb5]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19
68+
switchInt(move _8) -> [4_isize: bb8, 5_isize: bb6, otherwise: bb7]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19
6569
}
6670

67-
bb5: {
71+
bb6: {
6872
StorageLive(_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:21: +9:24
6973
_9 = const "E"; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:21: +9:24
7074
// mir::Constant
7175
// + span: $DIR/uninhabited_enum_branching.rs:28:21: 28:24
7276
// + literal: Const { ty: &str, val: Value(Slice(..)) }
7377
_6 = &(*_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:21: +9:24
7478
StorageDead(_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24
75-
goto -> bb7; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24
79+
goto -> bb9; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24
7680
}
7781

78-
bb6: {
82+
bb7: {
83+
unreachable; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19
84+
}
85+
86+
bb8: {
7987
_6 = const "D"; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24
8088
// mir::Constant
8189
// + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24
8290
// + literal: Const { ty: &str, val: Value(Slice(..)) }
83-
goto -> bb7; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24
91+
goto -> bb9; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24
8492
}
8593

86-
bb7: {
94+
bb9: {
8795
StorageDead(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+10:6: +10:7
8896
StorageDead(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:+10:6: +10:7
8997
_0 = const (); // scope 0 at $DIR/uninhabited_enum_branching.rs:+0:11: +11:2

‎src/test/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn main() -> () {
3232
StorageLive(_4); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22
3333
_4 = &(_1.1: Test1); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22
3434
_5 = discriminant((*_4)); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22
35-
switchInt(move _5) -> [2_isize: bb2, otherwise: bb1]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:5: +3:22
35+
switchInt(move _5) -> [2_isize: bb3, 3_isize: bb1, otherwise: bb2]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:5: +3:22
3636
}
3737

3838
bb1: {
@@ -43,51 +43,59 @@ fn main() -> () {
4343
// + literal: Const { ty: &str, val: Value(Slice(..)) }
4444
_3 = &(*_8); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+7:21: +7:24
4545
StorageDead(_8); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+7:23: +7:24
46-
goto -> bb3; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+7:23: +7:24
46+
goto -> bb4; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+7:23: +7:24
4747
}
4848

4949
bb2: {
50+
unreachable; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22
51+
}
52+
53+
bb3: {
5054
StorageLive(_7); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:21: +6:24
5155
_7 = const "C"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:21: +6:24
5256
// mir::Constant
5357
// + span: $DIR/uninhabited_enum_branching2.rs:24:21: 24:24
5458
// + literal: Const { ty: &str, val: Value(Slice(..)) }
5559
_3 = &(*_7); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:21: +6:24
5660
StorageDead(_7); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:23: +6:24
57-
goto -> bb3; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:23: +6:24
61+
goto -> bb4; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:23: +6:24
5862
}
5963

60-
bb3: {
64+
bb4: {
6165
StorageDead(_4); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+8:6: +8:7
6266
StorageDead(_3); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+8:6: +8:7
6367
StorageLive(_9); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +15:6
6468
_10 = discriminant((_1.1: Test1)); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:11: +10:21
65-
switchInt(move _10) -> [2_isize: bb5, otherwise: bb4]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21
69+
switchInt(move _10) -> [2_isize: bb7, 3_isize: bb5, otherwise: bb6]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21
6670
}
6771

68-
bb4: {
72+
bb5: {
6973
StorageLive(_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:21: +14:24
7074
_13 = const "D"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:21: +14:24
7175
// mir::Constant
7276
// + span: $DIR/uninhabited_enum_branching2.rs:32:21: 32:24
7377
// + literal: Const { ty: &str, val: Value(Slice(..)) }
7478
_9 = &(*_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:21: +14:24
7579
StorageDead(_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24
76-
goto -> bb6; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24
80+
goto -> bb8; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24
7781
}
7882

79-
bb5: {
83+
bb6: {
84+
unreachable; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:11: +10:21
85+
}
86+
87+
bb7: {
8088
StorageLive(_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24
8189
_12 = const "C"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24
8290
// mir::Constant
8391
// + span: $DIR/uninhabited_enum_branching2.rs:31:21: 31:24
8492
// + literal: Const { ty: &str, val: Value(Slice(..)) }
8593
_9 = &(*_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24
8694
StorageDead(_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24
87-
goto -> bb6; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24
95+
goto -> bb8; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24
8896
}
8997

90-
bb6: {
98+
bb8: {
9199
StorageDead(_9); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+15:6: +15:7
92100
_0 = const (); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+0:11: +16:2
93101
StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+16:1: +16:2

‎src/test/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
StorageLive(_4); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22
3434
_4 = &(_1.1: Test1); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22
3535
_5 = discriminant((*_4)); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22
36-
- switchInt(move _5) -> [0_isize: bb2, 1_isize: bb3, 2_isize: bb4, otherwise: bb1]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:5: +3:22
37-
+ switchInt(move _5) -> [2_isize: bb4, otherwise: bb1]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:5: +3:22
36+
- switchInt(move _5) -> [0_isize: bb3, 1_isize: bb4, 2_isize: bb5, 3_isize: bb1, otherwise: bb2]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:5: +3:22
37+
+ switchInt(move _5) -> [2_isize: bb5, 3_isize: bb1, otherwise: bb2]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:5: +3:22
3838
}
3939

4040
bb1: {
@@ -45,90 +45,98 @@
4545
// + literal: Const { ty: &str, val: Value(Slice(..)) }
4646
_3 = &(*_8); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+7:21: +7:24
4747
StorageDead(_8); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+7:23: +7:24
48-
goto -> bb5; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+7:23: +7:24
48+
goto -> bb6; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+7:23: +7:24
4949
}
5050

5151
bb2: {
52+
unreachable; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22
53+
}
54+
55+
bb3: {
5256
_3 = const "A(Empty)"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+4:24: +4:34
5357
// mir::Constant
5458
// + span: $DIR/uninhabited_enum_branching2.rs:22:24: 22:34
5559
// + literal: Const { ty: &str, val: Value(Slice(..)) }
56-
goto -> bb5; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+4:24: +4:34
60+
goto -> bb6; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+4:24: +4:34
5761
}
5862

59-
bb3: {
63+
bb4: {
6064
StorageLive(_6); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+5:24: +5:34
6165
_6 = const "B(Empty)"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+5:24: +5:34
6266
// mir::Constant
6367
// + span: $DIR/uninhabited_enum_branching2.rs:23:24: 23:34
6468
// + literal: Const { ty: &str, val: Value(Slice(..)) }
6569
_3 = &(*_6); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+5:24: +5:34
6670
StorageDead(_6); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+5:33: +5:34
67-
goto -> bb5; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+5:33: +5:34
71+
goto -> bb6; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+5:33: +5:34
6872
}
6973

70-
bb4: {
74+
bb5: {
7175
StorageLive(_7); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:21: +6:24
7276
_7 = const "C"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:21: +6:24
7377
// mir::Constant
7478
// + span: $DIR/uninhabited_enum_branching2.rs:24:21: 24:24
7579
// + literal: Const { ty: &str, val: Value(Slice(..)) }
7680
_3 = &(*_7); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:21: +6:24
7781
StorageDead(_7); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:23: +6:24
78-
goto -> bb5; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:23: +6:24
82+
goto -> bb6; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+6:23: +6:24
7983
}
8084

81-
bb5: {
85+
bb6: {
8286
StorageDead(_4); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+8:6: +8:7
8387
StorageDead(_3); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+8:6: +8:7
8488
StorageLive(_9); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +15:6
8589
_10 = discriminant((_1.1: Test1)); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:11: +10:21
86-
- switchInt(move _10) -> [0_isize: bb7, 1_isize: bb8, 2_isize: bb9, otherwise: bb6]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21
87-
+ switchInt(move _10) -> [2_isize: bb9, otherwise: bb6]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21
90+
- switchInt(move _10) -> [0_isize: bb9, 1_isize: bb10, 2_isize: bb11, 3_isize: bb7, otherwise: bb8]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21
91+
+ switchInt(move _10) -> [2_isize: bb11, 3_isize: bb7, otherwise: bb8]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21
8892
}
8993

90-
bb6: {
94+
bb7: {
9195
StorageLive(_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:21: +14:24
9296
_13 = const "D"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:21: +14:24
9397
// mir::Constant
9498
// + span: $DIR/uninhabited_enum_branching2.rs:32:21: 32:24
9599
// + literal: Const { ty: &str, val: Value(Slice(..)) }
96100
_9 = &(*_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:21: +14:24
97101
StorageDead(_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24
98-
goto -> bb10; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24
102+
goto -> bb12; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24
99103
}
100104

101-
bb7: {
105+
bb8: {
106+
unreachable; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:11: +10:21
107+
}
108+
109+
bb9: {
102110
_9 = const "A(Empty)"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+11:24: +11:34
103111
// mir::Constant
104112
// + span: $DIR/uninhabited_enum_branching2.rs:29:24: 29:34
105113
// + literal: Const { ty: &str, val: Value(Slice(..)) }
106-
goto -> bb10; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+11:24: +11:34
114+
goto -> bb12; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+11:24: +11:34
107115
}
108116

109-
bb8: {
117+
bb10: {
110118
StorageLive(_11); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:24: +12:34
111119
_11 = const "B(Empty)"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:24: +12:34
112120
// mir::Constant
113121
// + span: $DIR/uninhabited_enum_branching2.rs:30:24: 30:34
114122
// + literal: Const { ty: &str, val: Value(Slice(..)) }
115123
_9 = &(*_11); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:24: +12:34
116124
StorageDead(_11); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:33: +12:34
117-
goto -> bb10; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:33: +12:34
125+
goto -> bb12; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:33: +12:34
118126
}
119127

120-
bb9: {
128+
bb11: {
121129
StorageLive(_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24
122130
_12 = const "C"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24
123131
// mir::Constant
124132
// + span: $DIR/uninhabited_enum_branching2.rs:31:21: 31:24
125133
// + literal: Const { ty: &str, val: Value(Slice(..)) }
126134
_9 = &(*_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24
127135
StorageDead(_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24
128-
goto -> bb10; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24
136+
goto -> bb12; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24
129137
}
130138

131-
bb10: {
139+
bb12: {
132140
StorageDead(_9); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+15:6: +15:7
133141
_0 = const (); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+0:11: +16:2
134142
StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+16:1: +16:2

‎src/test/mir-opt/unreachable.main.UnreachablePropagation.diff

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
bb1: {
2929
_2 = discriminant(_1); // scope 1 at $DIR/unreachable.rs:+1:12: +1:20
3030
- switchInt(move _2) -> [1_isize: bb2, otherwise: bb6]; // scope 1 at $DIR/unreachable.rs:+1:12: +1:20
31-
+ goto -> bb2; // scope 1 at $DIR/unreachable.rs:+1:12: +1:20
31+
+ switchInt(move _2) -> [1_isize: bb2, otherwise: bb3]; // scope 1 at $DIR/unreachable.rs:+1:12: +1:20
3232
}
3333

3434
bb2: {
@@ -39,9 +39,10 @@
3939
- StorageLive(_6); // scope 2 at $DIR/unreachable.rs:+4:12: +4:16
4040
- _6 = const true; // scope 2 at $DIR/unreachable.rs:+4:12: +4:16
4141
- switchInt(move _6) -> [false: bb4, otherwise: bb3]; // scope 2 at $DIR/unreachable.rs:+4:12: +4:16
42-
- }
43-
-
44-
- bb3: {
42+
+ unreachable; // scope 2 at $DIR/unreachable.rs:+4:12: +4:16
43+
}
44+
45+
bb3: {
4546
- _4 = const 21_i32; // scope 2 at $DIR/unreachable.rs:+5:13: +5:20
4647
- _5 = const (); // scope 2 at $DIR/unreachable.rs:+4:17: +6:10
4748
- goto -> bb5; // scope 2 at $DIR/unreachable.rs:+4:9: +8:10

‎src/test/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929

3030
bb1: {
3131
_3 = discriminant(_2); // scope 2 at $DIR/unreachable_diverging.rs:+2:12: +2:22
32-
- switchInt(move _3) -> [1_isize: bb2, otherwise: bb6]; // scope 2 at $DIR/unreachable_diverging.rs:+2:12: +2:22
33-
+ switchInt(move _3) -> [1_isize: bb2, otherwise: bb5]; // scope 2 at $DIR/unreachable_diverging.rs:+2:12: +2:22
32+
switchInt(move _3) -> [1_isize: bb2, otherwise: bb6]; // scope 2 at $DIR/unreachable_diverging.rs:+2:12: +2:22
3433
}
3534

3635
bb2: {
@@ -39,13 +38,11 @@
3938
StorageLive(_5); // scope 2 at $DIR/unreachable_diverging.rs:+3:9: +5:10
4039
StorageLive(_6); // scope 2 at $DIR/unreachable_diverging.rs:+3:12: +3:13
4140
_6 = _1; // scope 2 at $DIR/unreachable_diverging.rs:+3:12: +3:13
42-
- switchInt(move _6) -> [false: bb4, otherwise: bb3]; // scope 2 at $DIR/unreachable_diverging.rs:+3:12: +3:13
43-
+ goto -> bb3; // scope 2 at $DIR/unreachable_diverging.rs:+3:12: +3:13
41+
switchInt(move _6) -> [false: bb4, otherwise: bb3]; // scope 2 at $DIR/unreachable_diverging.rs:+3:12: +3:13
4442
}
4543

4644
bb3: {
47-
- _5 = loop_forever() -> bb5; // scope 2 at $DIR/unreachable_diverging.rs:+4:13: +4:27
48-
+ _5 = loop_forever() -> bb4; // scope 2 at $DIR/unreachable_diverging.rs:+4:13: +4:27
45+
_5 = loop_forever() -> bb5; // scope 2 at $DIR/unreachable_diverging.rs:+4:13: +4:27
4946
// mir::Constant
5047
// + span: $DIR/unreachable_diverging.rs:16:13: 16:25
5148
// + literal: Const { ty: fn() {loop_forever}, val: Value(<ZST>) }
@@ -54,17 +51,17 @@
5451
bb4: {
5552
- _5 = const (); // scope 2 at $DIR/unreachable_diverging.rs:+5:10: +5:10
5653
- goto -> bb5; // scope 2 at $DIR/unreachable_diverging.rs:+3:9: +5:10
57-
- }
58-
-
59-
- bb5: {
60-
StorageDead(_6); // scope 2 at $DIR/unreachable_diverging.rs:+5:9: +5:10
61-
StorageDead(_5); // scope 2 at $DIR/unreachable_diverging.rs:+5:9: +5:10
62-
StorageLive(_7); // scope 2 at $DIR/unreachable_diverging.rs:+6:9: +6:22
54+
+ unreachable; // scope 2 at $DIR/unreachable_diverging.rs:+3:9: +5:10
55+
}
56+
57+
bb5: {
58+
- StorageDead(_6); // scope 2 at $DIR/unreachable_diverging.rs:+5:9: +5:10
59+
- StorageDead(_5); // scope 2 at $DIR/unreachable_diverging.rs:+5:9: +5:10
60+
- StorageLive(_7); // scope 2 at $DIR/unreachable_diverging.rs:+6:9: +6:22
6361
unreachable; // scope 2 at $DIR/unreachable_diverging.rs:+6:15: +6:19
6462
}
6563

66-
- bb6: {
67-
+ bb5: {
64+
bb6: {
6865
_0 = const (); // scope 1 at $DIR/unreachable_diverging.rs:+7:6: +7:6
6966
StorageDead(_1); // scope 0 at $DIR/unreachable_diverging.rs:+8:1: +8:2
7067
StorageDead(_2); // scope 0 at $DIR/unreachable_diverging.rs:+8:1: +8:2

0 commit comments

Comments
 (0)
Please sign in to comment.