Skip to content

Commit ddbeda1

Browse files
authored
Rollup merge of #96090 - JakobDegen:mir-tests, r=nagisa
Implement MIR opt unit tests This implements rust-lang/compiler-team#502 . There's not much to say here, this implementation does everything as proposed. I also added the flag to a bunch of existing tests (mostly those to which I could add it without causing huge diffs due to changes in line numbers). Summarizing the changes to test outputs: - Every time an `MirPatch` is created, it adds a cleanup block to the body if it did not exist already. If this block is unused (as is usually the case), it usually gets removed soon after by some pass calling `SimplifyCFG` for unrelated reasons (in many cases this cycle happens quite a few times for a single body). We now run `SimplifyCFG` less often, so those blocks end up in some of our outputs. I looked at changing `MirPatch` to not do this, but that seemed too complicated for this PR. I may still do that in a follow-up. - The `InstCombine` test had set `-C opt-level=0` in its flags and so there were no storage markers. I don't really see a good motivation for doing this, so bringing it back in line with what everything else does seems correct. - One of the `EarlyOtherwiseBranch` tests had `UnreachableProp` running on it. Preventing that kind of thing is the goal of this feature, so this seems fine. For the remaining tests for which this feature might be useful, we can gradually migrate them as opportunities present themselves. In terms of documentation, I plan on submitting a PR to the rustc dev guide in the near future documenting this and other recent changes to MIR. If there's any other places to update, do let me know r? `@nagisa`
2 parents 76aa9e5 + 4534188 commit ddbeda1

30 files changed

+172
-38
lines changed

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ fn test_debugging_options_tracking_hash() {
752752
tracked!(location_detail, LocationDetail { file: true, line: false, column: false });
753753
tracked!(merge_functions, Some(MergeFunctions::Disabled));
754754
tracked!(mir_emit_retag, true);
755+
tracked!(mir_enable_passes, vec![("DestProp".to_string(), false)]);
755756
tracked!(mir_opt_level, Some(4));
756757
tracked!(move_size_limit, Some(4096));
757758
tracked!(mutable_noalias, Some(true));

compiler/rustc_mir_transform/src/pass_manager.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,30 @@ pub fn run_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, passes: &[&dyn
7777
let mut cnt = 0;
7878

7979
let validate = tcx.sess.opts.debugging_opts.validate_mir;
80+
let overridden_passes = &tcx.sess.opts.debugging_opts.mir_enable_passes;
81+
trace!(?overridden_passes);
8082

8183
if validate {
8284
validate_body(tcx, body, format!("start of phase transition from {:?}", start_phase));
8385
}
8486

8587
for pass in passes {
86-
if !pass.is_enabled(&tcx.sess) {
87-
continue;
88-
}
89-
9088
let name = pass.name();
89+
90+
if let Some((_, polarity)) = overridden_passes.iter().rev().find(|(s, _)| s == &*name) {
91+
trace!(
92+
pass = %name,
93+
"{} as requested by flag",
94+
if *polarity { "Running" } else { "Not running" },
95+
);
96+
if !polarity {
97+
continue;
98+
}
99+
} else {
100+
if !pass.is_enabled(&tcx.sess) {
101+
continue;
102+
}
103+
}
91104
let dump_enabled = pass.is_mir_dump_enabled();
92105

93106
if dump_enabled {

compiler/rustc_session/src/options.rs

+19
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ mod desc {
368368
pub const parse_opt_langid: &str = "a language identifier";
369369
pub const parse_opt_pathbuf: &str = "a path";
370370
pub const parse_list: &str = "a space-separated list of strings";
371+
pub const parse_list_with_polarity: &str =
372+
"a comma-separated list of strings, with elements beginning with + or -";
371373
pub const parse_opt_comma_list: &str = "a comma-separated list of strings";
372374
pub const parse_number: &str = "a number";
373375
pub const parse_opt_number: &str = parse_number;
@@ -529,6 +531,19 @@ mod parse {
529531
}
530532
}
531533

534+
crate fn parse_list_with_polarity(slot: &mut Vec<(String, bool)>, v: Option<&str>) -> bool {
535+
match v {
536+
Some(s) => {
537+
for s in s.split(",") {
538+
let Some(pass_name) = s.strip_prefix(&['+', '-'][..]) else { return false };
539+
slot.push((pass_name.to_string(), &s[..1] == "+"));
540+
}
541+
true
542+
}
543+
None => false,
544+
}
545+
}
546+
532547
crate fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool {
533548
if let Some(v) = v {
534549
ld.line = false;
@@ -1318,6 +1333,10 @@ options! {
13181333
mir_emit_retag: bool = (false, parse_bool, [TRACKED],
13191334
"emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
13201335
(default: no)"),
1336+
mir_enable_passes: Vec<(String, bool)> = (Vec::new(), parse_list_with_polarity, [TRACKED],
1337+
"use like `-Zmir-enable-passes=+DestProp,-InstCombine`. Forces the specified passes to be \
1338+
enabled, overriding all other checks. Passes that are not specified are enabled or \
1339+
disabled by other flags as usual."),
13211340
mir_opt_level: Option<usize> = (None, parse_opt_number, [TRACKED],
13221341
"MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
13231342
move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],

src/test/mir-opt/combine_clone_of_primitives.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -C opt-level=0 -Z inline_mir=no
1+
// unit-test: InstCombine
22
// ignore-wasm32 compiled with panic=abort by default
33

44
// EMIT_MIR combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff

src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff

+24
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@
2323
}
2424

2525
bb0: {
26+
StorageLive(_2); // scope 0 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9
2627
_2 = &((*_1).0: T); // scope 0 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9
28+
StorageLive(_3); // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11
2729
_3 = &((*_1).1: u64); // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11
30+
StorageLive(_4); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16
2831
_4 = &((*_1).2: [f32; 3]); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16
32+
StorageLive(_5); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9
33+
StorageLive(_6); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9
34+
StorageLive(_7); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9
2935
- _7 = &(*_2); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9
3036
- _6 = &(*_7); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9
3137
+ _7 = _2; // scope 1 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9
@@ -37,6 +43,10 @@
3743
}
3844

3945
bb1: {
46+
StorageDead(_6); // scope 1 at $DIR/combine_clone_of_primitives.rs:8:8: 8:9
47+
StorageLive(_8); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11
48+
StorageLive(_9); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11
49+
StorageLive(_10); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11
4050
- _10 = &(*_3); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11
4151
- _9 = &(*_10); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11
4252
- _8 = <u64 as Clone>::clone(move _9) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11
@@ -50,6 +60,10 @@
5060
}
5161

5262
bb2: {
63+
StorageDead(_9); // scope 1 at $DIR/combine_clone_of_primitives.rs:9:10: 9:11
64+
StorageLive(_11); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16
65+
StorageLive(_12); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16
66+
StorageLive(_13); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16
5367
- _13 = &(*_4); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16
5468
- _12 = &(*_13); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16
5569
- _11 = <[f32; 3] as Clone>::clone(move _12) -> [return: bb3, unwind: bb4]; // scope 1 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16
@@ -63,10 +77,20 @@
6377
}
6478

6579
bb3: {
80+
StorageDead(_12); // scope 1 at $DIR/combine_clone_of_primitives.rs:10:15: 10:16
6681
Deinit(_0); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:10: 6:15
6782
(_0.0: T) = move _5; // scope 1 at $DIR/combine_clone_of_primitives.rs:6:10: 6:15
6883
(_0.1: u64) = move _8; // scope 1 at $DIR/combine_clone_of_primitives.rs:6:10: 6:15
6984
(_0.2: [f32; 3]) = move _11; // scope 1 at $DIR/combine_clone_of_primitives.rs:6:10: 6:15
85+
StorageDead(_13); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15
86+
StorageDead(_11); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15
87+
StorageDead(_10); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15
88+
StorageDead(_8); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15
89+
StorageDead(_7); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15
90+
StorageDead(_5); // scope 1 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15
91+
StorageDead(_4); // scope 0 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15
92+
StorageDead(_3); // scope 0 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15
93+
StorageDead(_2); // scope 0 at $DIR/combine_clone_of_primitives.rs:6:14: 6:15
7094
return; // scope 0 at $DIR/combine_clone_of_primitives.rs:6:15: 6:15
7195
}
7296

src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@
6868
+ bb3: {
6969
StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch.rs:8:1: 8:2
7070
return; // scope 0 at $DIR/early_otherwise_branch.rs:8:2: 8:2
71-
+ }
72-
+
71+
}
72+
73+
- bb5 (cleanup): {
74+
- resume; // scope 0 at $DIR/early_otherwise_branch.rs:3:1: 8:2
7375
+ bb4: {
7476
+ StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 4:17
7577
+ switchInt(_7) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 4:17

src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch.rs:12:16: 12:17
3333
StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch.rs:12:16: 12:17
3434
_8 = discriminant((_3.0: std::option::Option<u32>)); // scope 0 at $DIR/early_otherwise_branch.rs:12:11: 12:17
35-
- switchInt(move _8) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb7]; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17
35+
- switchInt(move _8) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17
3636
+ StorageLive(_11); // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17
3737
+ _11 = discriminant((_3.1: std::option::Option<u32>)); // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17
3838
+ StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17
@@ -84,8 +84,8 @@
8484
return; // scope 0 at $DIR/early_otherwise_branch.rs:17:2: 17:2
8585
}
8686

87-
- bb7: {
88-
- unreachable; // scope 0 at $DIR/early_otherwise_branch.rs:15:14: 15:15
87+
- bb7 (cleanup): {
88+
- resume; // scope 0 at $DIR/early_otherwise_branch.rs:11:1: 17:2
8989
+ bb5: {
9090
+ StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17
9191
+ switchInt(_8) -> [0_isize: bb3, 1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 12:17

src/test/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@
6868
+ bb3: {
6969
StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch.rs:26:1: 26:2
7070
return; // scope 0 at $DIR/early_otherwise_branch.rs:26:2: 26:2
71-
+ }
72-
+
71+
}
72+
73+
- bb5 (cleanup): {
74+
- resume; // scope 0 at $DIR/early_otherwise_branch.rs:21:1: 26:2
7375
+ bb4: {
7476
+ StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17
7577
+ switchInt(_7) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17

src/test/mir-opt/early_otherwise_branch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts
1+
// unit-test: EarlyOtherwiseBranch
22
// EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
33
fn opt1(x: Option<u32>, y: Option<u32>) -> u32 {
44
match (x, y) {

src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@
9090
+ bb4: {
9191
StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:9:1: 9:2
9292
return; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:9:2: 9:2
93-
+ }
94-
+
93+
}
94+
95+
- bb6 (cleanup): {
96+
- resume; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:4:1: 9:2
9597
+ bb5: {
9698
+ StorageDead(_15); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 5:20
9799
+ switchInt(_10) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 5:20

src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts
1+
// unit-test: EarlyOtherwiseBranch
22

33
// EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
44
fn opt1(x: Option<u32>, y: Option<u32>, z: Option<u32>) -> u32 {

src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff

+19-11
Original file line numberDiff line numberDiff line change
@@ -38,54 +38,62 @@
3838
StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:16: 8:17
3939
StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:16: 8:17
4040
_8 = discriminant((_3.0: std::option::Option<u32>)); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17
41-
switchInt(move _8) -> [0_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17
41+
switchInt(move _8) -> [0_isize: bb1, 1_isize: bb4, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17
4242
}
4343

4444
bb1: {
4545
_6 = discriminant((_3.1: std::option::Option<u32>)); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17
46-
switchInt(move _6) -> [0_isize: bb2, otherwise: bb6]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17
46+
switchInt(move _6) -> [0_isize: bb2, 1_isize: bb7, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17
4747
}
4848

4949
bb2: {
5050
_0 = const 3_u32; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:12:25: 12:26
51-
goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:12:25: 12:26
51+
goto -> bb8; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:12:25: 12:26
5252
}
5353

5454
bb3: {
55-
_7 = discriminant((_3.1: std::option::Option<u32>)); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17
56-
switchInt(move _7) -> [0_isize: bb5, otherwise: bb4]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17
55+
unreachable; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17
5756
}
5857

5958
bb4: {
59+
_7 = discriminant((_3.1: std::option::Option<u32>)); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:11: 8:17
60+
switchInt(move _7) -> [0_isize: bb6, 1_isize: bb5, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 8:17
61+
}
62+
63+
bb5: {
6064
StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16
6165
_9 = (((_3.0: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16
6266
StorageLive(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25
6367
_10 = (((_3.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25
6468
_0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32
6569
StorageDead(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32
6670
StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32
67-
goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32
71+
goto -> bb8; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32
6872
}
6973

70-
bb5: {
74+
bb6: {
7175
StorageLive(_11); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:15: 10:16
7276
_11 = (((_3.0: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:15: 10:16
7377
_0 = const 1_u32; // scope 2 at $DIR/early_otherwise_branch_noopt.rs:10:28: 10:29
7478
StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:28: 10:29
75-
goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:28: 10:29
79+
goto -> bb8; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:10:28: 10:29
7680
}
7781

78-
bb6: {
82+
bb7: {
7983
StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:21: 11:22
8084
_12 = (((_3.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:21: 11:22
8185
_0 = const 2_u32; // scope 3 at $DIR/early_otherwise_branch_noopt.rs:11:28: 11:29
8286
StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:28: 11:29
83-
goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:28: 11:29
87+
goto -> bb8; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:11:28: 11:29
8488
}
8589

86-
bb7: {
90+
bb8: {
8791
StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:14:1: 14:2
8892
return; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:14:2: 14:2
8993
}
94+
95+
bb9 (cleanup): {
96+
resume; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:7:1: 14:2
97+
}
9098
}
9199

src/test/mir-opt/early_otherwise_branch_noopt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts
1+
// unit-test: EarlyOtherwiseBranch
22

33
// must not optimize as it does not follow the pattern of
44
// left and right hand side being the same variant

src/test/mir-opt/early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff

+11-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
bb1: {
2121
_0 = const 0_i32; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:25:14: 25:15
22-
return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:25:14: 25:15
22+
goto -> bb5; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:25:14: 25:15
2323
}
2424

2525
bb2: {
@@ -29,15 +29,23 @@
2929

3030
bb3: {
3131
_0 = const 0_i32; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:23:18: 23:19
32-
return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:23:18: 23:19
32+
goto -> bb5; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:23:18: 23:19
3333
}
3434

3535
bb4: {
3636
StorageLive(_5); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:22:18: 22:19
3737
_5 = (((*_2) as Some).0: i32); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:22:18: 22:19
3838
_0 = _5; // scope 1 at $DIR/early_otherwise_branch_soundness.rs:22:24: 22:25
3939
StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:22:24: 22:25
40-
return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:22:24: 22:25
40+
goto -> bb5; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:22:24: 22:25
41+
}
42+
43+
bb5: {
44+
return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:27:2: 27:2
45+
}
46+
47+
bb6 (cleanup): {
48+
resume; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:18:1: 27:2
4149
}
4250
}
4351

src/test/mir-opt/early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff

+10-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@
1919

2020
bb2: {
2121
_0 = const 1_u32; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:38: 13:39
22-
return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:5: 13:52
22+
goto -> bb4; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:5: 13:52
2323
}
2424

2525
bb3: {
2626
_0 = const 2_u32; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:49: 13:50
27-
return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:5: 13:52
27+
goto -> bb4; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:5: 13:52
28+
}
29+
30+
bb4: {
31+
return; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:14:2: 14:2
32+
}
33+
34+
bb5 (cleanup): {
35+
resume; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:12:1: 14:2
2836
}
2937
}
3038

0 commit comments

Comments
 (0)