Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[mir-opt] Handle const-prop for the return place
- Loading branch information
1 parent
0d5264a
commit 8316701
Showing
2 changed files
with
87 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// compile-flags: -C overflow-checks=on | ||
|
||
fn add() -> u32 { | ||
2 + 2 | ||
} | ||
|
||
fn main() { | ||
add(); | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.add.ConstProp.before.mir | ||
// fn add() -> u32 { | ||
// let mut _0: u32; | ||
// let mut _1: (u32, bool); | ||
// bb0: { | ||
// _1 = CheckedAdd(const 2u32, const 2u32); | ||
// assert(!move (_1.1: bool), "attempt to add with overflow") -> bb1; | ||
// } | ||
// bb1: { | ||
// _0 = move (_1.0: u32); | ||
// return; | ||
// } | ||
// bb2 (cleanup): { | ||
// resume; | ||
// } | ||
// } | ||
// END rustc.add.ConstProp.before.mir | ||
// START rustc.add.ConstProp.after.mir | ||
// fn add() -> u32 { | ||
// let mut _0: u32; | ||
// let mut _1: (u32, bool); | ||
// bb0: { | ||
// _1 = (const 4u32, const false); | ||
// assert(!const false, "attempt to add with overflow") -> bb1; | ||
// } | ||
// bb1: { | ||
// _0 = const 4u32; | ||
// return; | ||
// } | ||
// bb2 (cleanup): { | ||
// resume; | ||
// } | ||
// } | ||
// END rustc.add.ConstProp.after.mir | ||
// START rustc.add.PreCodegen.before.mir | ||
// fn add() -> u32 { | ||
// let mut _0: u32; | ||
// let mut _1: (u32, bool); | ||
// bb0: { | ||
// (_1.0: u32) = const 4u32; | ||
// (_1.1: bool) = const false; | ||
// _0 = const 4u32; | ||
// return; | ||
// } | ||
// } | ||
// END rustc.add.PreCodegen.before.mir |