Skip to content

Commit a0b9500

Browse files
committed
Implement multiple return terminators optimization
1 parent 286a346 commit a0b9500

16 files changed

+114
-88
lines changed

src/librustc_mir/transform/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub mod inline;
3030
pub mod instcombine;
3131
pub mod instrument_coverage;
3232
pub mod match_branches;
33+
pub mod multiple_return_terminators;
3334
pub mod no_landing_pads;
3435
pub mod nrvo;
3536
pub mod promote_consts;
@@ -453,6 +454,7 @@ fn run_optimization_passes<'tcx>(
453454

454455
// The main optimizations that we do on MIR.
455456
let optimizations: &[&dyn MirPass<'tcx>] = &[
457+
&multiple_return_terminators::MultipleReturnTerminators,
456458
&instcombine::InstCombine,
457459
&match_branches::MatchBranchSimplification,
458460
&const_prop::ConstProp,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//! This pass removes jumps to basic blocks containing only a return, and replaces them with a
2+
//! return instead.
3+
4+
use crate::transform::{simplify, MirPass, MirSource};
5+
use rustc_index::bit_set::BitSet;
6+
use rustc_middle::mir::*;
7+
use rustc_middle::ty::TyCtxt;
8+
9+
pub struct MultipleReturnTerminators;
10+
11+
impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators {
12+
fn run_pass(&self, _: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
13+
// find basic blocks with no statement and a return terminator
14+
let mut bbs_simple_returns = BitSet::new_empty(body.basic_blocks().len());
15+
let bbs = body.basic_blocks_mut();
16+
for idx in bbs.indices() {
17+
if bbs[idx].statements.is_empty()
18+
&& bbs[idx].terminator().kind == TerminatorKind::Return
19+
{
20+
bbs_simple_returns.insert(idx);
21+
}
22+
}
23+
24+
for bb in bbs {
25+
if let TerminatorKind::Goto { target } = bb.terminator().kind {
26+
if bbs_simple_returns.contains(target) {
27+
bb.terminator_mut().kind = TerminatorKind::Return;
28+
}
29+
}
30+
}
31+
32+
simplify::remove_dead_blocks(body)
33+
}
34+
}

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
_0 = const (); // scope 0 at $DIR/issue-73223.rs:4:17: 4:23
107107
StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7
108108
StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2
109-
goto -> bb3; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23
109+
return; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23
110110
}
111111

112112
bb2: {
@@ -153,14 +153,10 @@
153153
StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
154154
_15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
155155
StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
156-
switchInt(_15) -> [false: bb4, otherwise: bb5]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
156+
switchInt(_15) -> [false: bb3, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
157157
}
158158

159159
bb3: {
160-
return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2
161-
}
162-
163-
bb4: {
164160
_8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
165161
StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
166162
StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -170,10 +166,10 @@
170166
_0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2
171167
StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2
172168
StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2
173-
goto -> bb3; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2
169+
return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2
174170
}
175171

176-
bb5: {
172+
bb4: {
177173
StorageLive(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
178174
StorageLive(_20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
179175
StorageLive(_21); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
@@ -224,24 +220,24 @@
224220
StorageLive(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
225221
StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
226222
_47 = _40; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
227-
_46 = std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
223+
_46 = std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
228224
// mir::Constant
229225
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
230226
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar(<ZST>)) }
231227
}
232228

233-
bb6: {
229+
bb5: {
234230
StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
235231
StorageLive(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
236232
StorageLive(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
237233
_49 = _39; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
238-
_48 = std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb7; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
234+
_48 = std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
239235
// mir::Constant
240236
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
241237
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar(<ZST>)) }
242238
}
243239

244-
bb7: {
240+
bb6: {
245241
StorageDead(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
246242
(_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
247243
(_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
@@ -260,24 +256,24 @@
260256
StorageLive(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
261257
StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
262258
_51 = _43; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
263-
_50 = std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
259+
_50 = std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
264260
// mir::Constant
265261
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
266262
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar(<ZST>)) }
267263
}
268264

269-
bb8: {
265+
bb7: {
270266
StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
271267
StorageLive(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
272268
StorageLive(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
273269
_53 = _42; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
274-
_52 = std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb9; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
270+
_52 = std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
275271
// mir::Constant
276272
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
277273
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar(<ZST>)) }
278274
}
279275

280-
bb9: {
276+
bb8: {
281277
StorageDead(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
282278
(_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
283279
(_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@
1313

1414
bb1: {
1515
_0 = const 1_u8; // scope 0 at $DIR/matches_u8.rs:14:17: 14:18
16-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:12:5: 15:6
16+
return; // scope 0 at $DIR/matches_u8.rs:12:5: 15:6
1717
}
1818

1919
bb2: {
2020
_0 = const 0_u8; // scope 0 at $DIR/matches_u8.rs:13:17: 13:18
21-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:12:5: 15:6
22-
}
23-
24-
bb3: {
25-
return; // scope 0 at $DIR/matches_u8.rs:16:2: 16:2
21+
return; // scope 0 at $DIR/matches_u8.rs:12:5: 15:6
2622
}
2723
}
2824

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@
1313

1414
bb1: {
1515
_0 = const 1_i8; // scope 0 at $DIR/matches_u8.rs:22:17: 22:18
16-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:20:5: 23:6
16+
return; // scope 0 at $DIR/matches_u8.rs:20:5: 23:6
1717
}
1818

1919
bb2: {
2020
_0 = const 0_i8; // scope 0 at $DIR/matches_u8.rs:21:17: 21:18
21-
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:20:5: 23:6
22-
}
23-
24-
bb3: {
25-
return; // scope 0 at $DIR/matches_u8.rs:24:2: 24:2
21+
return; // scope 0 at $DIR/matches_u8.rs:20:5: 23:6
2622
}
2723
}
2824

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// EMIT_MIR multiple_return_terminators.test.MultipleReturnTerminators.diff
2+
3+
fn test(x: bool) {
4+
if x {
5+
// test
6+
} else {
7+
// test
8+
}
9+
}
10+
11+
fn main() {
12+
test(true)
13+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
- // MIR for `test` before MultipleReturnTerminators
2+
+ // MIR for `test` after MultipleReturnTerminators
3+
4+
fn test(_1: bool) -> () {
5+
debug x => _1; // in scope 0 at $DIR/multiple_return_terminators.rs:3:9: 3:10
6+
let mut _0: (); // return place in scope 0 at $DIR/multiple_return_terminators.rs:3:18: 3:18
7+
let mut _2: bool; // in scope 0 at $DIR/multiple_return_terminators.rs:4:8: 4:9
8+
9+
bb0: {
10+
StorageLive(_2); // scope 0 at $DIR/multiple_return_terminators.rs:4:8: 4:9
11+
_2 = _1; // scope 0 at $DIR/multiple_return_terminators.rs:4:8: 4:9
12+
switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/multiple_return_terminators.rs:4:5: 8:6
13+
}
14+
15+
bb1: {
16+
_0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:6:12: 8:6
17+
goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:4:5: 8:6
18+
}
19+
20+
bb2: {
21+
_0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:4:10: 6:6
22+
goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:4:5: 8:6
23+
}
24+
25+
bb3: {
26+
StorageDead(_2); // scope 0 at $DIR/multiple_return_terminators.rs:9:1: 9:2
27+
return; // scope 0 at $DIR/multiple_return_terminators.rs:9:2: 9:2
28+
}
29+
}
30+

src/test/mir-opt/simplify_arm.id.SimplifyArmIdentity.diff

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
bb1: {
2121
discriminant(_0) = 0; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21
22-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6
22+
return; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6
2323
}
2424

2525
bb2: {
@@ -36,11 +36,7 @@
3636
- StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:11:26: 11:27
3737
- StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27
3838
+ _0 = move _1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27
39-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6
40-
}
41-
42-
bb4: {
43-
return; // scope 0 at $DIR/simplify-arm.rs:14:2: 14:2
39+
return; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6
4440
}
4541
}
4642

src/test/mir-opt/simplify_arm.id.SimplifyBranchSame.diff

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
bb1: {
2121
- discriminant(_0) = 0; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21
22-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6
22+
- return; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6
2323
- }
2424
-
2525
- bb2: {
@@ -28,13 +28,7 @@
2828
-
2929
- bb3: {
3030
_0 = move _1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27
31-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6
32-
+ goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6
33-
}
34-
35-
- bb4: {
36-
+ bb2: {
37-
return; // scope 0 at $DIR/simplify-arm.rs:14:2: 14:2
31+
return; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6
3832
}
3933
}
4034

src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
- StorageDead(_6); // scope 2 at $DIR/simplify-arm.rs:19:24: 19:25
3434
- StorageDead(_5); // scope 0 at $DIR/simplify-arm.rs:19:24: 19:25
3535
+ _0 = move _1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25
36-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6
36+
return; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6
3737
}
3838

3939
bb2: {
@@ -50,11 +50,7 @@
5050
- StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:18:22: 18:23
5151
- StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23
5252
+ _0 = move _1; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23
53-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6
54-
}
55-
56-
bb4: {
57-
return; // scope 0 at $DIR/simplify-arm.rs:21:2: 21:2
53+
return; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6
5854
}
5955
}
6056

src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
bb1: {
2626
- _0 = move _1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25
27-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6
27+
- return; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6
2828
- }
2929
-
3030
- bb2: {
@@ -33,13 +33,7 @@
3333
-
3434
- bb3: {
3535
_0 = move _1; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23
36-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6
37-
+ goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6
38-
}
39-
40-
- bb4: {
41-
+ bb2: {
42-
return; // scope 0 at $DIR/simplify-arm.rs:21:2: 21:2
36+
return; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6
4337
}
4438
}
4539

src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
- discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:25:5: 25:10
6868
- StorageDead(_11); // scope 1 at $DIR/simplify-arm.rs:25:9: 25:10
6969
StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2
70-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2
70+
return; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2
7171
}
7272

7373
bb2: {
@@ -92,11 +92,7 @@
9292
+ _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
9393
StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16
9494
StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2
95-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
96-
}
97-
98-
bb4: {
99-
return; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2
95+
return; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
10096
}
10197
}
10298

src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,18 @@
5454
_0 = move _3; // scope 1 at $DIR/simplify-arm.rs:25:5: 25:10
5555
StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16
5656
StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2
57-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2
58-
+ goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2
59-
}
60-
61-
bb2: {
57+
return; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2
58+
- }
59+
-
60+
- bb2: {
6261
- unreachable; // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15
6362
- }
6463
-
6564
- bb3: {
6665
- _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
6766
- StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16
6867
- StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2
69-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
70-
- }
71-
-
72-
- bb4: {
73-
return; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2
68+
- return; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
7469
}
7570
}
7671

0 commit comments

Comments
 (0)