Skip to content

Commit 268f786

Browse files
committed
Add test for multiple terminator optimization
1 parent f0d407e commit 268f786

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Z mir-opt-level=3
2+
// EMIT_MIR multiple_return_terminators.test.MultipleReturnTerminators.diff
3+
4+
fn test(x: bool) {
5+
if x {
6+
// test
7+
} else {
8+
// test
9+
}
10+
}
11+
12+
fn main() {
13+
test(true)
14+
}
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:4:9: 4:10
6+
let mut _0: (); // return place in scope 0 at $DIR/multiple_return_terminators.rs:4:18: 4:18
7+
let mut _2: bool; // in scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9
8+
9+
bb0: {
10+
StorageLive(_2); // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9
11+
_2 = _1; // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9
12+
switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6
13+
}
14+
15+
bb1: {
16+
_0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:7:12: 9:6
17+
goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6
18+
}
19+
20+
bb2: {
21+
_0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:5:10: 7:6
22+
goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6
23+
}
24+
25+
bb3: {
26+
StorageDead(_2); // scope 0 at $DIR/multiple_return_terminators.rs:10:1: 10:2
27+
return; // scope 0 at $DIR/multiple_return_terminators.rs:10:2: 10:2
28+
}
29+
}
30+

0 commit comments

Comments
 (0)