forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct the unsoundness in the
EarlyOtherwiseBranch
mir opt
This optimization pass previously made excessive assumptions as to the nature of the blocks being optimized. We remove those assumptions and make sure to rigorously justify all changes that are made to the MIR. Details can be found in the file.
- Loading branch information
1 parent
229d0a9
commit 709c94a
Showing
10 changed files
with
421 additions
and
371 deletions.
There are no files selected for viewing
581 changes: 307 additions & 274 deletions
581
compiler/rustc_mir_transform/src/early_otherwise_branch.rs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/test/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
- // MIR for `opt3` before EarlyOtherwiseBranch | ||
+ // MIR for `opt3` after EarlyOtherwiseBranch | ||
|
||
fn opt3(_1: Option<u32>, _2: Option<bool>) -> u32 { | ||
debug x => _1; // in scope 0 at $DIR/early_otherwise_branch.rs:21:9: 21:10 | ||
debug y => _2; // in scope 0 at $DIR/early_otherwise_branch.rs:21:25: 21:26 | ||
let mut _0: u32; // return place in scope 0 at $DIR/early_otherwise_branch.rs:21:45: 21:48 | ||
let mut _3: (std::option::Option<u32>, std::option::Option<bool>); // in scope 0 at $DIR/early_otherwise_branch.rs:22:11: 22:17 | ||
let mut _4: std::option::Option<u32>; // in scope 0 at $DIR/early_otherwise_branch.rs:22:12: 22:13 | ||
let mut _5: std::option::Option<bool>; // in scope 0 at $DIR/early_otherwise_branch.rs:22:15: 22:16 | ||
let mut _6: isize; // in scope 0 at $DIR/early_otherwise_branch.rs:23:19: 23:26 | ||
let mut _7: isize; // in scope 0 at $DIR/early_otherwise_branch.rs:23:10: 23:17 | ||
let _8: u32; // in scope 0 at $DIR/early_otherwise_branch.rs:23:15: 23:16 | ||
let _9: bool; // in scope 0 at $DIR/early_otherwise_branch.rs:23:24: 23:25 | ||
+ let mut _10: isize; // in scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
+ let mut _11: bool; // in scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
scope 1 { | ||
debug a => _8; // in scope 1 at $DIR/early_otherwise_branch.rs:23:15: 23:16 | ||
debug b => _9; // in scope 1 at $DIR/early_otherwise_branch.rs:23:24: 23:25 | ||
} | ||
|
||
bb0: { | ||
StorageLive(_3); // scope 0 at $DIR/early_otherwise_branch.rs:22:11: 22:17 | ||
StorageLive(_4); // scope 0 at $DIR/early_otherwise_branch.rs:22:12: 22:13 | ||
_4 = _1; // scope 0 at $DIR/early_otherwise_branch.rs:22:12: 22:13 | ||
StorageLive(_5); // scope 0 at $DIR/early_otherwise_branch.rs:22:15: 22:16 | ||
_5 = _2; // scope 0 at $DIR/early_otherwise_branch.rs:22:15: 22:16 | ||
(_3.0: std::option::Option<u32>) = move _4; // scope 0 at $DIR/early_otherwise_branch.rs:22:11: 22:17 | ||
(_3.1: std::option::Option<bool>) = move _5; // scope 0 at $DIR/early_otherwise_branch.rs:22:11: 22:17 | ||
StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch.rs:22:16: 22:17 | ||
StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch.rs:22:16: 22:17 | ||
_7 = discriminant((_3.0: std::option::Option<u32>)); // scope 0 at $DIR/early_otherwise_branch.rs:22:11: 22:17 | ||
- switchInt(move _7) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
+ StorageLive(_10); // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
+ _10 = discriminant((_3.1: std::option::Option<bool>)); // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
+ StorageLive(_11); // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
+ _11 = Ne(_7, move _10); // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
+ StorageDead(_10); // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
+ switchInt(move _11) -> [false: bb4, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
} | ||
|
||
bb1: { | ||
+ StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch.rs:24:14: 24:15 | ||
_0 = const 1_u32; // scope 0 at $DIR/early_otherwise_branch.rs:24:14: 24:15 | ||
- goto -> bb4; // scope 0 at $DIR/early_otherwise_branch.rs:24:14: 24:15 | ||
+ goto -> bb3; // scope 0 at $DIR/early_otherwise_branch.rs:24:14: 24:15 | ||
} | ||
|
||
bb2: { | ||
- _6 = discriminant((_3.1: std::option::Option<bool>)); // scope 0 at $DIR/early_otherwise_branch.rs:22:11: 22:17 | ||
- switchInt(move _6) -> [1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
- } | ||
- | ||
- bb3: { | ||
StorageLive(_8); // scope 0 at $DIR/early_otherwise_branch.rs:23:15: 23:16 | ||
_8 = (((_3.0: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:23:15: 23:16 | ||
StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch.rs:23:24: 23:25 | ||
_9 = (((_3.1: std::option::Option<bool>) as Some).0: bool); // scope 0 at $DIR/early_otherwise_branch.rs:23:24: 23:25 | ||
_0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch.rs:23:31: 23:32 | ||
StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch.rs:23:31: 23:32 | ||
StorageDead(_8); // scope 0 at $DIR/early_otherwise_branch.rs:23:31: 23:32 | ||
- goto -> bb4; // scope 0 at $DIR/early_otherwise_branch.rs:23:31: 23:32 | ||
+ goto -> bb3; // scope 0 at $DIR/early_otherwise_branch.rs:23:31: 23:32 | ||
} | ||
|
||
- bb4: { | ||
+ bb3: { | ||
StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch.rs:26:1: 26:2 | ||
return; // scope 0 at $DIR/early_otherwise_branch.rs:26:2: 26:2 | ||
+ } | ||
+ | ||
+ bb4: { | ||
+ StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
+ switchInt(_7) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch.rs:22:5: 22:17 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.