Skip to content

Commit 8a222ff

Browse files
committedJul 9, 2024
Don't try to save an extra block
This is preparation for the next commit.
1 parent c5062f7 commit 8a222ff

15 files changed

+284
-268
lines changed
 

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

+9-13
Original file line numberDiff line numberDiff line change
@@ -2021,19 +2021,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
20212021

20222022
// The block that we should branch to if none of the
20232023
// `target_candidates` match.
2024-
let remainder_start = if !remaining_candidates.is_empty() {
2025-
let remainder_start = self.cfg.start_new_block();
2026-
self.match_candidates(
2027-
span,
2028-
scrutinee_span,
2029-
remainder_start,
2030-
otherwise_block,
2031-
remaining_candidates,
2032-
);
2033-
remainder_start
2034-
} else {
2035-
otherwise_block
2036-
};
2024+
let remainder_start = self.cfg.start_new_block();
20372025

20382026
// For each outcome of test, process the candidates that still apply.
20392027
let target_blocks: FxIndexMap<_, _> = target_candidates
@@ -2061,6 +2049,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
20612049
&test,
20622050
target_blocks,
20632051
);
2052+
2053+
self.match_candidates(
2054+
span,
2055+
scrutinee_span,
2056+
remainder_start,
2057+
otherwise_block,
2058+
remaining_candidates,
2059+
);
20642060
}
20652061
}
20662062

‎tests/mir-opt/building/issue_101867.main.built.after.mir

+11-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ fn main() -> () {
2727
StorageLive(_5);
2828
PlaceMention(_1);
2929
_6 = discriminant(_1);
30-
switchInt(move _6) -> [1: bb4, otherwise: bb3];
30+
switchInt(move _6) -> [1: bb5, otherwise: bb4];
3131
}
3232

3333
bb1: {
3434
StorageLive(_3);
3535
StorageLive(_4);
36-
_4 = begin_panic::<&str>(const "explicit panic") -> bb8;
36+
_4 = begin_panic::<&str>(const "explicit panic") -> bb9;
3737
}
3838

3939
bb2: {
@@ -43,31 +43,35 @@ fn main() -> () {
4343
}
4444

4545
bb3: {
46-
goto -> bb7;
46+
goto -> bb8;
4747
}
4848

4949
bb4: {
50-
falseEdge -> [real: bb6, imaginary: bb3];
50+
goto -> bb3;
5151
}
5252

5353
bb5: {
54-
goto -> bb3;
54+
falseEdge -> [real: bb7, imaginary: bb3];
5555
}
5656

5757
bb6: {
58+
goto -> bb4;
59+
}
60+
61+
bb7: {
5862
_5 = ((_1 as Some).0: u8);
5963
_0 = const ();
6064
StorageDead(_5);
6165
StorageDead(_1);
6266
return;
6367
}
6468

65-
bb7: {
69+
bb8: {
6670
StorageDead(_5);
6771
goto -> bb1;
6872
}
6973

70-
bb8 (cleanup): {
74+
bb9 (cleanup): {
7175
resume;
7276
}
7377
}

‎tests/mir-opt/building/issue_49232.main.built.after.mir

+19-15
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ fn main() -> () {
1717
}
1818

1919
bb1: {
20-
falseUnwind -> [real: bb2, unwind: bb14];
20+
falseUnwind -> [real: bb2, unwind: bb15];
2121
}
2222

2323
bb2: {
2424
StorageLive(_2);
2525
StorageLive(_3);
2626
_3 = const true;
2727
PlaceMention(_3);
28-
switchInt(_3) -> [0: bb4, otherwise: bb6];
28+
switchInt(_3) -> [0: bb5, otherwise: bb7];
2929
}
3030

3131
bb3: {
@@ -34,59 +34,63 @@ fn main() -> () {
3434
}
3535

3636
bb4: {
37-
falseEdge -> [real: bb8, imaginary: bb6];
37+
goto -> bb3;
3838
}
3939

4040
bb5: {
41-
goto -> bb3;
41+
falseEdge -> [real: bb9, imaginary: bb7];
4242
}
4343

4444
bb6: {
45-
_0 = const ();
46-
goto -> bb13;
45+
goto -> bb4;
4746
}
4847

4948
bb7: {
50-
goto -> bb3;
49+
_0 = const ();
50+
goto -> bb14;
5151
}
5252

5353
bb8: {
54-
_2 = const 4_i32;
55-
goto -> bb11;
54+
goto -> bb4;
5655
}
5756

5857
bb9: {
59-
unreachable;
58+
_2 = const 4_i32;
59+
goto -> bb12;
6060
}
6161

6262
bb10: {
63-
goto -> bb11;
63+
unreachable;
6464
}
6565

6666
bb11: {
67+
goto -> bb12;
68+
}
69+
70+
bb12: {
6771
FakeRead(ForLet(None), _2);
6872
StorageDead(_3);
6973
StorageLive(_5);
7074
StorageLive(_6);
7175
_6 = &_2;
72-
_5 = std::mem::drop::<&i32>(move _6) -> [return: bb12, unwind: bb14];
76+
_5 = std::mem::drop::<&i32>(move _6) -> [return: bb13, unwind: bb15];
7377
}
7478

75-
bb12: {
79+
bb13: {
7680
StorageDead(_6);
7781
StorageDead(_5);
7882
_1 = const ();
7983
StorageDead(_2);
8084
goto -> bb1;
8185
}
8286

83-
bb13: {
87+
bb14: {
8488
StorageDead(_3);
8589
StorageDead(_2);
8690
return;
8791
}
8892

89-
bb14 (cleanup): {
93+
bb15 (cleanup): {
9094
resume;
9195
}
9296
}

‎tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir

+65-57
Original file line numberDiff line numberDiff line change
@@ -19,180 +19,188 @@ fn test_complex() -> () {
1919
bb0: {
2020
StorageLive(_1);
2121
StorageLive(_2);
22-
_2 = E::f() -> [return: bb1, unwind: bb34];
22+
_2 = E::f() -> [return: bb1, unwind: bb36];
2323
}
2424

2525
bb1: {
2626
PlaceMention(_2);
2727
_3 = discriminant(_2);
28-
switchInt(move _3) -> [0: bb3, otherwise: bb2];
28+
switchInt(move _3) -> [0: bb4, otherwise: bb3];
2929
}
3030

3131
bb2: {
32-
goto -> bb21;
32+
goto -> bb22;
3333
}
3434

3535
bb3: {
36-
falseEdge -> [real: bb5, imaginary: bb2];
36+
goto -> bb2;
3737
}
3838

3939
bb4: {
40-
goto -> bb2;
40+
falseEdge -> [real: bb6, imaginary: bb2];
4141
}
4242

4343
bb5: {
44-
StorageLive(_4);
45-
_4 = always_true() -> [return: bb6, unwind: bb34];
44+
goto -> bb3;
4645
}
4746

4847
bb6: {
49-
switchInt(move _4) -> [0: bb8, otherwise: bb7];
48+
StorageLive(_4);
49+
_4 = always_true() -> [return: bb7, unwind: bb36];
5050
}
5151

5252
bb7: {
53+
switchInt(move _4) -> [0: bb9, otherwise: bb8];
54+
}
55+
56+
bb8: {
5357
StorageLive(_5);
5458
StorageLive(_6);
5559
StorageLive(_7);
5660
_7 = Droppy(const 0_u8);
5761
_6 = (_7.0: u8);
5862
_5 = Gt(move _6, const 0_u8);
59-
switchInt(move _5) -> [0: bb10, otherwise: bb9];
60-
}
61-
62-
bb8: {
63-
goto -> bb14;
63+
switchInt(move _5) -> [0: bb11, otherwise: bb10];
6464
}
6565

6666
bb9: {
67-
drop(_7) -> [return: bb11, unwind: bb34];
67+
goto -> bb15;
6868
}
6969

7070
bb10: {
71-
goto -> bb12;
71+
drop(_7) -> [return: bb12, unwind: bb36];
7272
}
7373

7474
bb11: {
75-
StorageDead(_7);
76-
StorageDead(_6);
77-
goto -> bb18;
75+
goto -> bb13;
7876
}
7977

8078
bb12: {
81-
drop(_7) -> [return: bb13, unwind: bb34];
79+
StorageDead(_7);
80+
StorageDead(_6);
81+
goto -> bb19;
8282
}
8383

8484
bb13: {
85+
drop(_7) -> [return: bb14, unwind: bb36];
86+
}
87+
88+
bb14: {
8589
StorageDead(_7);
8690
StorageDead(_6);
87-
goto -> bb14;
91+
goto -> bb15;
8892
}
8993

90-
bb14: {
94+
bb15: {
9195
StorageLive(_8);
9296
StorageLive(_9);
9397
StorageLive(_10);
9498
_10 = Droppy(const 1_u8);
9599
_9 = (_10.0: u8);
96100
_8 = Gt(move _9, const 1_u8);
97-
switchInt(move _8) -> [0: bb16, otherwise: bb15];
98-
}
99-
100-
bb15: {
101-
drop(_10) -> [return: bb17, unwind: bb34];
101+
switchInt(move _8) -> [0: bb17, otherwise: bb16];
102102
}
103103

104104
bb16: {
105-
goto -> bb19;
105+
drop(_10) -> [return: bb18, unwind: bb36];
106106
}
107107

108108
bb17: {
109-
StorageDead(_10);
110-
StorageDead(_9);
111-
goto -> bb18;
109+
goto -> bb20;
112110
}
113111

114112
bb18: {
115-
_1 = const ();
116-
goto -> bb22;
113+
StorageDead(_10);
114+
StorageDead(_9);
115+
goto -> bb19;
117116
}
118117

119118
bb19: {
120-
drop(_10) -> [return: bb20, unwind: bb34];
119+
_1 = const ();
120+
goto -> bb23;
121121
}
122122

123123
bb20: {
124-
StorageDead(_10);
125-
StorageDead(_9);
126-
goto -> bb21;
124+
drop(_10) -> [return: bb21, unwind: bb36];
127125
}
128126

129127
bb21: {
130-
_1 = const ();
128+
StorageDead(_10);
129+
StorageDead(_9);
131130
goto -> bb22;
132131
}
133132

134133
bb22: {
134+
_1 = const ();
135+
goto -> bb23;
136+
}
137+
138+
bb23: {
135139
StorageDead(_8);
136140
StorageDead(_5);
137141
StorageDead(_4);
138142
StorageDead(_2);
139143
StorageDead(_1);
140144
StorageLive(_11);
141-
_11 = always_true() -> [return: bb23, unwind: bb34];
142-
}
143-
144-
bb23: {
145-
switchInt(move _11) -> [0: bb25, otherwise: bb24];
145+
_11 = always_true() -> [return: bb24, unwind: bb36];
146146
}
147147

148148
bb24: {
149-
goto -> bb32;
149+
switchInt(move _11) -> [0: bb26, otherwise: bb25];
150150
}
151151

152152
bb25: {
153-
goto -> bb26;
153+
goto -> bb34;
154154
}
155155

156156
bb26: {
157-
StorageLive(_12);
158-
_12 = E::f() -> [return: bb27, unwind: bb34];
157+
goto -> bb27;
159158
}
160159

161160
bb27: {
162-
PlaceMention(_12);
163-
_13 = discriminant(_12);
164-
switchInt(move _13) -> [1: bb29, otherwise: bb28];
161+
StorageLive(_12);
162+
_12 = E::f() -> [return: bb28, unwind: bb36];
165163
}
166164

167165
bb28: {
168-
goto -> bb32;
166+
PlaceMention(_12);
167+
_13 = discriminant(_12);
168+
switchInt(move _13) -> [1: bb31, otherwise: bb30];
169169
}
170170

171171
bb29: {
172-
falseEdge -> [real: bb31, imaginary: bb28];
172+
goto -> bb34;
173173
}
174174

175175
bb30: {
176-
goto -> bb28;
176+
goto -> bb29;
177177
}
178178

179179
bb31: {
180-
_0 = const ();
181-
goto -> bb33;
180+
falseEdge -> [real: bb33, imaginary: bb29];
182181
}
183182

184183
bb32: {
185-
_0 = const ();
186-
goto -> bb33;
184+
goto -> bb30;
187185
}
188186

189187
bb33: {
188+
_0 = const ();
189+
goto -> bb35;
190+
}
191+
192+
bb34: {
193+
_0 = const ();
194+
goto -> bb35;
195+
}
196+
197+
bb35: {
190198
StorageDead(_11);
191199
StorageDead(_12);
192200
return;
193201
}
194202

195-
bb34 (cleanup): {
203+
bb36 (cleanup): {
196204
resume;
197205
}
198206
}

‎tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir

+27-23
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn full_tested_match() -> () {
2828
_2 = Option::<i32>::Some(const 42_i32);
2929
PlaceMention(_2);
3030
_4 = discriminant(_2);
31-
switchInt(move _4) -> [0: bb5, 1: bb2, otherwise: bb1];
31+
switchInt(move _4) -> [0: bb6, 1: bb3, otherwise: bb2];
3232
}
3333

3434
bb1: {
@@ -37,39 +37,43 @@ fn full_tested_match() -> () {
3737
}
3838

3939
bb2: {
40-
falseEdge -> [real: bb7, imaginary: bb3];
40+
goto -> bb1;
4141
}
4242

4343
bb3: {
44-
falseEdge -> [real: bb12, imaginary: bb5];
44+
falseEdge -> [real: bb8, imaginary: bb4];
4545
}
4646

4747
bb4: {
48-
goto -> bb1;
48+
falseEdge -> [real: bb13, imaginary: bb6];
4949
}
5050

5151
bb5: {
52-
_1 = (const 3_i32, const 3_i32);
53-
goto -> bb13;
52+
goto -> bb2;
5453
}
5554

5655
bb6: {
57-
goto -> bb1;
56+
_1 = (const 3_i32, const 3_i32);
57+
goto -> bb14;
5858
}
5959

6060
bb7: {
61+
goto -> bb2;
62+
}
63+
64+
bb8: {
6165
StorageLive(_6);
6266
_6 = &((_2 as Some).0: i32);
6367
_3 = &fake shallow _2;
6468
StorageLive(_7);
65-
_7 = guard() -> [return: bb8, unwind: bb16];
69+
_7 = guard() -> [return: bb9, unwind: bb17];
6670
}
6771

68-
bb8: {
69-
switchInt(move _7) -> [0: bb10, otherwise: bb9];
72+
bb9: {
73+
switchInt(move _7) -> [0: bb11, otherwise: bb10];
7074
}
7175

72-
bb9: {
76+
bb10: {
7377
StorageDead(_7);
7478
FakeRead(ForMatchGuard, _3);
7579
FakeRead(ForGuardBinding, _6);
@@ -81,48 +85,48 @@ fn full_tested_match() -> () {
8185
StorageDead(_8);
8286
StorageDead(_5);
8387
StorageDead(_6);
84-
goto -> bb13;
88+
goto -> bb14;
8589
}
8690

87-
bb10: {
88-
goto -> bb11;
91+
bb11: {
92+
goto -> bb12;
8993
}
9094

91-
bb11: {
95+
bb12: {
9296
StorageDead(_7);
9397
StorageDead(_6);
94-
goto -> bb3;
98+
goto -> bb4;
9599
}
96100

97-
bb12: {
101+
bb13: {
98102
StorageLive(_9);
99103
_9 = ((_2 as Some).0: i32);
100104
StorageLive(_10);
101105
_10 = _9;
102106
_1 = (const 2_i32, move _10);
103107
StorageDead(_10);
104108
StorageDead(_9);
105-
goto -> bb13;
109+
goto -> bb14;
106110
}
107111

108-
bb13: {
112+
bb14: {
109113
PlaceMention(_1);
110114
StorageDead(_2);
111115
StorageDead(_1);
112116
_0 = const ();
113117
return;
114118
}
115119

116-
bb14: {
120+
bb15: {
117121
FakeRead(ForMatchedPlace(None), _1);
118122
unreachable;
119123
}
120124

121-
bb15: {
122-
goto -> bb14;
125+
bb16: {
126+
goto -> bb15;
123127
}
124128

125-
bb16 (cleanup): {
129+
bb17 (cleanup): {
126130
resume;
127131
}
128132
}

‎tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir

+29-25
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn full_tested_match2() -> () {
2828
_2 = Option::<i32>::Some(const 42_i32);
2929
PlaceMention(_2);
3030
_4 = discriminant(_2);
31-
switchInt(move _4) -> [0: bb5, 1: bb2, otherwise: bb1];
31+
switchInt(move _4) -> [0: bb6, 1: bb3, otherwise: bb2];
3232
}
3333

3434
bb1: {
@@ -37,45 +37,49 @@ fn full_tested_match2() -> () {
3737
}
3838

3939
bb2: {
40-
falseEdge -> [real: bb7, imaginary: bb5];
40+
goto -> bb1;
4141
}
4242

4343
bb3: {
44+
falseEdge -> [real: bb8, imaginary: bb6];
45+
}
46+
47+
bb4: {
4448
StorageLive(_9);
4549
_9 = ((_2 as Some).0: i32);
4650
StorageLive(_10);
4751
_10 = _9;
4852
_1 = (const 2_i32, move _10);
4953
StorageDead(_10);
5054
StorageDead(_9);
51-
goto -> bb13;
52-
}
53-
54-
bb4: {
55-
goto -> bb1;
55+
goto -> bb14;
5656
}
5757

5858
bb5: {
59-
falseEdge -> [real: bb12, imaginary: bb3];
59+
goto -> bb2;
6060
}
6161

6262
bb6: {
63-
goto -> bb1;
63+
falseEdge -> [real: bb13, imaginary: bb4];
6464
}
6565

6666
bb7: {
67+
goto -> bb2;
68+
}
69+
70+
bb8: {
6771
StorageLive(_6);
6872
_6 = &((_2 as Some).0: i32);
6973
_3 = &fake shallow _2;
7074
StorageLive(_7);
71-
_7 = guard() -> [return: bb8, unwind: bb16];
75+
_7 = guard() -> [return: bb9, unwind: bb17];
7276
}
7377

74-
bb8: {
75-
switchInt(move _7) -> [0: bb10, otherwise: bb9];
78+
bb9: {
79+
switchInt(move _7) -> [0: bb11, otherwise: bb10];
7680
}
7781

78-
bb9: {
82+
bb10: {
7983
StorageDead(_7);
8084
FakeRead(ForMatchGuard, _3);
8185
FakeRead(ForGuardBinding, _6);
@@ -87,42 +91,42 @@ fn full_tested_match2() -> () {
8791
StorageDead(_8);
8892
StorageDead(_5);
8993
StorageDead(_6);
90-
goto -> bb13;
94+
goto -> bb14;
9195
}
9296

93-
bb10: {
94-
goto -> bb11;
97+
bb11: {
98+
goto -> bb12;
9599
}
96100

97-
bb11: {
101+
bb12: {
98102
StorageDead(_7);
99103
StorageDead(_6);
100-
falseEdge -> [real: bb3, imaginary: bb5];
104+
falseEdge -> [real: bb4, imaginary: bb6];
101105
}
102106

103-
bb12: {
107+
bb13: {
104108
_1 = (const 3_i32, const 3_i32);
105-
goto -> bb13;
109+
goto -> bb14;
106110
}
107111

108-
bb13: {
112+
bb14: {
109113
PlaceMention(_1);
110114
StorageDead(_2);
111115
StorageDead(_1);
112116
_0 = const ();
113117
return;
114118
}
115119

116-
bb14: {
120+
bb15: {
117121
FakeRead(ForMatchedPlace(None), _1);
118122
unreachable;
119123
}
120124

121-
bb15: {
122-
goto -> bb14;
125+
bb16: {
126+
goto -> bb15;
123127
}
124128

125-
bb16 (cleanup): {
129+
bb17 (cleanup): {
126130
resume;
127131
}
128132
}

‎tests/mir-opt/building/match/match_false_edges.main.built.after.mir

+17-17
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ fn main() -> () {
3838
StorageLive(_2);
3939
_2 = Option::<i32>::Some(const 1_i32);
4040
PlaceMention(_2);
41-
_5 = discriminant(_2);
42-
switchInt(move _5) -> [1: bb8, otherwise: bb2];
41+
_4 = discriminant(_2);
42+
switchInt(move _4) -> [1: bb3, otherwise: bb2];
4343
}
4444

4545
bb1: {
@@ -48,40 +48,40 @@ fn main() -> () {
4848
}
4949

5050
bb2: {
51-
falseEdge -> [real: bb15, imaginary: bb3];
51+
falseEdge -> [real: bb15, imaginary: bb5];
5252
}
5353

5454
bb3: {
55-
_4 = discriminant(_2);
56-
switchInt(move _4) -> [1: bb6, otherwise: bb4];
55+
falseEdge -> [real: bb10, imaginary: bb2];
5756
}
5857

5958
bb4: {
60-
StorageLive(_14);
61-
_14 = _2;
62-
_1 = const 4_i32;
63-
StorageDead(_14);
64-
goto -> bb21;
59+
goto -> bb2;
6560
}
6661

6762
bb5: {
68-
goto -> bb1;
63+
_5 = discriminant(_2);
64+
switchInt(move _5) -> [1: bb7, otherwise: bb6];
6965
}
7066

7167
bb6: {
72-
falseEdge -> [real: bb16, imaginary: bb4];
68+
StorageLive(_14);
69+
_14 = _2;
70+
_1 = const 4_i32;
71+
StorageDead(_14);
72+
goto -> bb21;
7373
}
7474

7575
bb7: {
76-
goto -> bb4;
76+
falseEdge -> [real: bb16, imaginary: bb6];
7777
}
7878

7979
bb8: {
80-
falseEdge -> [real: bb10, imaginary: bb2];
80+
goto -> bb6;
8181
}
8282

8383
bb9: {
84-
goto -> bb2;
84+
goto -> bb1;
8585
}
8686

8787
bb10: {
@@ -115,7 +115,7 @@ fn main() -> () {
115115
bb14: {
116116
StorageDead(_8);
117117
StorageDead(_7);
118-
falseEdge -> [real: bb9, imaginary: bb2];
118+
falseEdge -> [real: bb4, imaginary: bb2];
119119
}
120120

121121
bb15: {
@@ -161,7 +161,7 @@ fn main() -> () {
161161
StorageDead(_13);
162162
StorageDead(_12);
163163
StorageDead(_11);
164-
falseEdge -> [real: bb7, imaginary: bb4];
164+
falseEdge -> [real: bb8, imaginary: bb6];
165165
}
166166

167167
bb21: {

‎tests/mir-opt/building/match/simple_match.match_bool.built.after.mir

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn match_bool(_1: bool) -> usize {
66

77
bb0: {
88
PlaceMention(_1);
9-
switchInt(_1) -> [0: bb2, otherwise: bb4];
9+
switchInt(_1) -> [0: bb2, otherwise: bb3];
1010
}
1111

1212
bb1: {
@@ -20,15 +20,15 @@ fn match_bool(_1: bool) -> usize {
2020
}
2121

2222
bb3: {
23-
goto -> bb1;
23+
falseEdge -> [real: bb6, imaginary: bb2];
2424
}
2525

2626
bb4: {
27-
falseEdge -> [real: bb6, imaginary: bb2];
27+
goto -> bb2;
2828
}
2929

3030
bb5: {
31-
goto -> bb2;
31+
goto -> bb1;
3232
}
3333

3434
bb6: {

‎tests/mir-opt/building/match/simple_match.match_enum.built.after.mir

+15-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn match_enum(_1: E1) -> bool {
88
bb0: {
99
PlaceMention(_1);
1010
_2 = discriminant(_1);
11-
switchInt(move _2) -> [0: bb3, 1: bb5, 2: bb7, otherwise: bb2];
11+
switchInt(move _2) -> [0: bb4, 1: bb6, 2: bb8, otherwise: bb3];
1212
}
1313

1414
bb1: {
@@ -21,40 +21,44 @@ fn match_enum(_1: E1) -> bool {
2121
}
2222

2323
bb3: {
24-
goto -> bb9;
24+
goto -> bb2;
2525
}
2626

2727
bb4: {
28-
goto -> bb2;
28+
goto -> bb10;
2929
}
3030

3131
bb5: {
32-
goto -> bb9;
32+
goto -> bb3;
3333
}
3434

3535
bb6: {
36-
goto -> bb2;
36+
goto -> bb10;
3737
}
3838

3939
bb7: {
40-
_0 = const false;
41-
goto -> bb11;
40+
goto -> bb3;
4241
}
4342

4443
bb8: {
45-
goto -> bb2;
44+
_0 = const false;
45+
goto -> bb12;
4646
}
4747

4848
bb9: {
49-
falseEdge -> [real: bb10, imaginary: bb7];
49+
goto -> bb3;
5050
}
5151

5252
bb10: {
53-
_0 = const true;
54-
goto -> bb11;
53+
falseEdge -> [real: bb11, imaginary: bb8];
5554
}
5655

5756
bb11: {
57+
_0 = const true;
58+
goto -> bb12;
59+
}
60+
61+
bb12: {
5862
return;
5963
}
6064
}

‎tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir

+14-14
Original file line numberDiff line numberDiff line change
@@ -23,52 +23,52 @@ fn constant_eq(_1: &str, _2: bool) -> u32 {
2323
StorageDead(_5);
2424
StorageDead(_4);
2525
PlaceMention(_3);
26-
_9 = <str as PartialEq>::eq((_3.0: &str), const "a") -> [return: bb11, unwind: bb19];
26+
_9 = <str as PartialEq>::eq((_3.0: &str), const "a") -> [return: bb9, unwind: bb19];
2727
}
2828

2929
bb1: {
30-
switchInt((_3.1: bool)) -> [0: bb2, otherwise: bb3];
30+
switchInt((_3.1: bool)) -> [0: bb10, otherwise: bb11];
3131
}
3232

3333
bb2: {
34-
_0 = const 5_u32;
35-
goto -> bb18;
34+
falseEdge -> [real: bb12, imaginary: bb5];
3635
}
3736

3837
bb3: {
39-
falseEdge -> [real: bb17, imaginary: bb2];
38+
switchInt((_3.1: bool)) -> [0: bb1, otherwise: bb4];
4039
}
4140

4241
bb4: {
43-
falseEdge -> [real: bb12, imaginary: bb7];
42+
falseEdge -> [real: bb16, imaginary: bb1];
4443
}
4544

4645
bb5: {
47-
switchInt((_3.1: bool)) -> [0: bb1, otherwise: bb6];
46+
_8 = <str as PartialEq>::eq((_3.0: &str), const "b") -> [return: bb8, unwind: bb19];
4847
}
4948

5049
bb6: {
51-
falseEdge -> [real: bb16, imaginary: bb1];
50+
switchInt((_3.1: bool)) -> [0: bb1, otherwise: bb7];
5251
}
5352

5453
bb7: {
55-
_8 = <str as PartialEq>::eq((_3.0: &str), const "b") -> [return: bb10, unwind: bb19];
54+
falseEdge -> [real: bb15, imaginary: bb3];
5655
}
5756

5857
bb8: {
59-
switchInt((_3.1: bool)) -> [0: bb1, otherwise: bb9];
58+
switchInt(move _8) -> [0: bb1, otherwise: bb6];
6059
}
6160

6261
bb9: {
63-
falseEdge -> [real: bb15, imaginary: bb5];
62+
switchInt(move _9) -> [0: bb5, otherwise: bb2];
6463
}
6564

6665
bb10: {
67-
switchInt(move _8) -> [0: bb1, otherwise: bb8];
66+
_0 = const 5_u32;
67+
goto -> bb18;
6868
}
6969

7070
bb11: {
71-
switchInt(move _9) -> [0: bb7, otherwise: bb4];
71+
falseEdge -> [real: bb17, imaginary: bb10];
7272
}
7373

7474
bb12: {
@@ -89,7 +89,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 {
8989

9090
bb14: {
9191
StorageDead(_10);
92-
falseEdge -> [real: bb5, imaginary: bb7];
92+
falseEdge -> [real: bb3, imaginary: bb5];
9393
}
9494

9595
bb15: {

‎tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff

+22-26
Original file line numberDiff line numberDiff line change
@@ -22,59 +22,55 @@
2222

2323
bb1: {
2424
StorageDead(_3);
25-
_7 = Len((*_2));
26-
_8 = const 4_usize;
27-
_9 = Ge(move _7, move _8);
28-
- switchInt(move _9) -> [0: bb2, otherwise: bb7];
29-
+ switchInt(move _9) -> [0: bb2, otherwise: bb6];
25+
_4 = Len((*_2));
26+
_5 = const 4_usize;
27+
_6 = Ge(move _4, move _5);
28+
switchInt(move _6) -> [0: bb2, otherwise: bb3];
3029
}
3130

3231
bb2: {
33-
_4 = Len((*_2));
34-
_5 = const 3_usize;
35-
_6 = Ge(move _4, move _5);
36-
- switchInt(move _6) -> [0: bb3, otherwise: bb4];
37-
+ switchInt(move _6) -> [0: bb10, otherwise: bb3];
32+
_7 = Len((*_2));
33+
_8 = const 3_usize;
34+
_9 = Ge(move _7, move _8);
35+
- switchInt(move _9) -> [0: bb7, otherwise: bb8];
36+
+ switchInt(move _9) -> [0: bb10, otherwise: bb7];
3837
}
3938

4039
bb3: {
41-
- _0 = const false;
42-
- goto -> bb14;
43-
+ switchInt((*_2)[0 of 3]) -> [47: bb4, otherwise: bb10];
40+
switchInt((*_2)[0 of 4]) -> [47: bb4, otherwise: bb2];
4441
}
4542

4643
bb4: {
47-
- switchInt((*_2)[0 of 3]) -> [47: bb5, otherwise: bb3];
48-
+ switchInt((*_2)[1 of 3]) -> [47: bb5, otherwise: bb10];
44+
switchInt((*_2)[1 of 4]) -> [47: bb5, otherwise: bb2];
4945
}
5046

5147
bb5: {
52-
- switchInt((*_2)[1 of 3]) -> [47: bb6, otherwise: bb3];
53-
+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10];
48+
switchInt((*_2)[2 of 4]) -> [47: bb6, otherwise: bb2];
5449
}
5550

5651
bb6: {
57-
- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb3];
58-
+ switchInt((*_2)[0 of 4]) -> [47: bb7, otherwise: bb2];
52+
- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
53+
+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2];
5954
}
6055

6156
bb7: {
62-
- switchInt((*_2)[0 of 4]) -> [47: bb8, otherwise: bb2];
63-
+ switchInt((*_2)[1 of 4]) -> [47: bb8, otherwise: bb2];
57+
- _0 = const false;
58+
- goto -> bb14;
59+
+ switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10];
6460
}
6561

6662
bb8: {
67-
- switchInt((*_2)[1 of 4]) -> [47: bb9, otherwise: bb2];
68-
+ switchInt((*_2)[2 of 4]) -> [47: bb9, otherwise: bb2];
63+
- switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7];
64+
+ switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10];
6965
}
7066

7167
bb9: {
72-
- switchInt((*_2)[2 of 4]) -> [47: bb10, otherwise: bb2];
73-
+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2];
68+
- switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7];
69+
+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10];
7470
}
7571

7672
bb10: {
77-
- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
73+
- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb7];
7874
- }
7975
-
8076
- bb11: {

‎tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff

+22-26
Original file line numberDiff line numberDiff line change
@@ -22,59 +22,55 @@
2222

2323
bb1: {
2424
StorageDead(_3);
25-
_7 = Len((*_2));
26-
_8 = const 4_usize;
27-
_9 = Ge(move _7, move _8);
28-
- switchInt(move _9) -> [0: bb2, otherwise: bb7];
29-
+ switchInt(move _9) -> [0: bb2, otherwise: bb6];
25+
_4 = Len((*_2));
26+
_5 = const 4_usize;
27+
_6 = Ge(move _4, move _5);
28+
switchInt(move _6) -> [0: bb2, otherwise: bb3];
3029
}
3130

3231
bb2: {
33-
_4 = Len((*_2));
34-
_5 = const 3_usize;
35-
_6 = Ge(move _4, move _5);
36-
- switchInt(move _6) -> [0: bb3, otherwise: bb4];
37-
+ switchInt(move _6) -> [0: bb10, otherwise: bb3];
32+
_7 = Len((*_2));
33+
_8 = const 3_usize;
34+
_9 = Ge(move _7, move _8);
35+
- switchInt(move _9) -> [0: bb7, otherwise: bb8];
36+
+ switchInt(move _9) -> [0: bb10, otherwise: bb7];
3837
}
3938

4039
bb3: {
41-
- _0 = const false;
42-
- goto -> bb14;
43-
+ switchInt((*_2)[0 of 3]) -> [47: bb4, otherwise: bb10];
40+
switchInt((*_2)[0 of 4]) -> [47: bb4, otherwise: bb2];
4441
}
4542

4643
bb4: {
47-
- switchInt((*_2)[0 of 3]) -> [47: bb5, otherwise: bb3];
48-
+ switchInt((*_2)[1 of 3]) -> [47: bb5, otherwise: bb10];
44+
switchInt((*_2)[1 of 4]) -> [47: bb5, otherwise: bb2];
4945
}
5046

5147
bb5: {
52-
- switchInt((*_2)[1 of 3]) -> [47: bb6, otherwise: bb3];
53-
+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10];
48+
switchInt((*_2)[2 of 4]) -> [47: bb6, otherwise: bb2];
5449
}
5550

5651
bb6: {
57-
- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb3];
58-
+ switchInt((*_2)[0 of 4]) -> [47: bb7, otherwise: bb2];
52+
- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
53+
+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2];
5954
}
6055

6156
bb7: {
62-
- switchInt((*_2)[0 of 4]) -> [47: bb8, otherwise: bb2];
63-
+ switchInt((*_2)[1 of 4]) -> [47: bb8, otherwise: bb2];
57+
- _0 = const false;
58+
- goto -> bb14;
59+
+ switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10];
6460
}
6561

6662
bb8: {
67-
- switchInt((*_2)[1 of 4]) -> [47: bb9, otherwise: bb2];
68-
+ switchInt((*_2)[2 of 4]) -> [47: bb9, otherwise: bb2];
63+
- switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7];
64+
+ switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10];
6965
}
7066

7167
bb9: {
72-
- switchInt((*_2)[2 of 4]) -> [47: bb10, otherwise: bb2];
73-
+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2];
68+
- switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7];
69+
+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10];
7470
}
7571

7672
bb10: {
77-
- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
73+
- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb7];
7874
- }
7975
-
8076
- bb11: {

‎tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff

+13-13
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,33 @@
3232

3333
bb0: {
3434
PlaceMention(_2);
35-
- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1];
35+
- switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1];
3636
+ switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1];
3737
}
3838

3939
bb1: {
40-
- switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2];
40+
- switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3];
4141
+ switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2];
4242
}
4343

4444
bb2: {
45-
- switchInt((_2.0: bool)) -> [0: bb4, otherwise: bb3];
45+
- falseEdge -> [real: bb8, imaginary: bb1];
4646
+ switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17];
4747
}
4848

4949
bb3: {
50-
- falseEdge -> [real: bb20, imaginary: bb4];
50+
- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb5];
5151
- }
5252
-
5353
- bb4: {
54+
- falseEdge -> [real: bb13, imaginary: bb3];
55+
- }
56+
-
57+
- bb5: {
58+
- falseEdge -> [real: bb20, imaginary: bb6];
59+
- }
60+
-
61+
- bb6: {
5462
StorageLive(_15);
5563
_15 = (_2.1: bool);
5664
StorageLive(_16);
@@ -59,14 +67,6 @@
5967
+ goto -> bb16;
6068
}
6169

62-
- bb5: {
63-
- falseEdge -> [real: bb13, imaginary: bb2];
64-
- }
65-
-
66-
- bb6: {
67-
- falseEdge -> [real: bb8, imaginary: bb1];
68-
- }
69-
-
7070
- bb7: {
7171
+ bb4: {
7272
_0 = const 1_i32;
@@ -184,7 +184,7 @@
184184
StorageDead(_12);
185185
StorageDead(_8);
186186
StorageDead(_6);
187-
- falseEdge -> [real: bb2, imaginary: bb2];
187+
- falseEdge -> [real: bb3, imaginary: bb3];
188188
+ goto -> bb2;
189189
}
190190

‎tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff

+13-13
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,33 @@
3232

3333
bb0: {
3434
PlaceMention(_2);
35-
- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1];
35+
- switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1];
3636
+ switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1];
3737
}
3838

3939
bb1: {
40-
- switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2];
40+
- switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3];
4141
+ switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2];
4242
}
4343

4444
bb2: {
45-
- switchInt((_2.0: bool)) -> [0: bb4, otherwise: bb3];
45+
- falseEdge -> [real: bb8, imaginary: bb1];
4646
+ switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17];
4747
}
4848

4949
bb3: {
50-
- falseEdge -> [real: bb20, imaginary: bb4];
50+
- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb5];
5151
- }
5252
-
5353
- bb4: {
54+
- falseEdge -> [real: bb13, imaginary: bb3];
55+
- }
56+
-
57+
- bb5: {
58+
- falseEdge -> [real: bb20, imaginary: bb6];
59+
- }
60+
-
61+
- bb6: {
5462
StorageLive(_15);
5563
_15 = (_2.1: bool);
5664
StorageLive(_16);
@@ -59,14 +67,6 @@
5967
+ goto -> bb16;
6068
}
6169

62-
- bb5: {
63-
- falseEdge -> [real: bb13, imaginary: bb2];
64-
- }
65-
-
66-
- bb6: {
67-
- falseEdge -> [real: bb8, imaginary: bb1];
68-
- }
69-
-
7070
- bb7: {
7171
+ bb4: {
7272
_0 = const 1_i32;
@@ -184,7 +184,7 @@
184184
StorageDead(_12);
185185
StorageDead(_8);
186186
StorageDead(_6);
187-
- falseEdge -> [real: bb2, imaginary: bb2];
187+
- falseEdge -> [real: bb3, imaginary: bb3];
188188
+ goto -> bb2;
189189
}
190190

‎tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn shortcut_second_or() -> () {
1818
_1 = (move _2, const 0_i32);
1919
StorageDead(_2);
2020
PlaceMention(_1);
21-
switchInt(((_1.0: (i32, i32)).0: i32)) -> [0: bb4, otherwise: bb2];
21+
switchInt(((_1.0: (i32, i32)).0: i32)) -> [0: bb3, otherwise: bb2];
2222
}
2323

2424
bb1: {
@@ -27,15 +27,15 @@ fn shortcut_second_or() -> () {
2727
}
2828

2929
bb2: {
30-
switchInt(((_1.0: (i32, i32)).1: i32)) -> [1: bb3, otherwise: bb1];
30+
switchInt(((_1.0: (i32, i32)).1: i32)) -> [1: bb4, otherwise: bb1];
3131
}
3232

3333
bb3: {
34-
switchInt((_1.1: i32)) -> [2: bb7, 3: bb8, otherwise: bb1];
34+
switchInt((_1.1: i32)) -> [2: bb5, 3: bb6, otherwise: bb1];
3535
}
3636

3737
bb4: {
38-
switchInt((_1.1: i32)) -> [2: bb5, 3: bb6, otherwise: bb1];
38+
switchInt((_1.1: i32)) -> [2: bb7, 3: bb8, otherwise: bb1];
3939
}
4040

4141
bb5: {

0 commit comments

Comments
 (0)
Please sign in to comment.