forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#106850 - cjgillot:issue-106141, r=oli-obk
Make the inlining destination a Local. Fixes rust-lang#106141
- Loading branch information
Showing
4 changed files
with
118 additions
and
31 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
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,55 @@ | ||
- // MIR for `outer` before Inline | ||
+ // MIR for `outer` after Inline | ||
|
||
fn outer() -> usize { | ||
let mut _0: usize; // return place in scope 0 at $DIR/issue_106141.rs:+0:19: +0:24 | ||
+ scope 1 (inlined inner) { // at $DIR/issue_106141.rs:2:5: 2:12 | ||
+ let mut _1: bool; // in scope 1 at $DIR/issue_106141.rs:13:8: 13:21 | ||
+ let mut _2: bool; // in scope 1 at $DIR/issue_106141.rs:13:8: 13:21 | ||
+ let mut _3: &[bool; 1]; // in scope 1 at $DIR/issue_106141.rs:11:18: 11:25 | ||
+ scope 2 { | ||
+ debug buffer => _3; // in scope 2 at $DIR/issue_106141.rs:11:9: 11:15 | ||
+ scope 3 { | ||
+ debug index => _0; // in scope 3 at $DIR/issue_106141.rs:12:9: 12:14 | ||
+ } | ||
+ } | ||
+ } | ||
|
||
bb0: { | ||
- _0 = inner() -> bb1; // scope 0 at $DIR/issue_106141.rs:+1:5: +1:12 | ||
+ StorageLive(_3); // scope 0 at $DIR/issue_106141.rs:+1:5: +1:12 | ||
+ _3 = const _; // scope 1 at $DIR/issue_106141.rs:11:18: 11:25 | ||
// mir::Constant | ||
- // + span: $DIR/issue_106141.rs:2:5: 2:10 | ||
- // + literal: Const { ty: fn() -> usize {inner}, val: Value(<ZST>) } | ||
+ // + span: $DIR/issue_106141.rs:11:18: 11:25 | ||
+ // + literal: Const { ty: &[bool; 1], val: Unevaluated(inner, [], Some(promoted[0])) } | ||
+ _0 = index() -> bb1; // scope 2 at $DIR/issue_106141.rs:12:17: 12:24 | ||
+ // mir::Constant | ||
+ // + span: $DIR/issue_106141.rs:12:17: 12:22 | ||
+ // + literal: Const { ty: fn() -> usize {index}, val: Value(<ZST>) } | ||
} | ||
|
||
bb1: { | ||
+ StorageLive(_1); // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 | ||
+ _2 = Lt(_0, const 1_usize); // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 | ||
+ assert(move _2, "index out of bounds: the length is {} but the index is {}", const 1_usize, _0) -> bb2; // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 | ||
+ } | ||
+ | ||
+ bb2: { | ||
+ _1 = (*_3)[_0]; // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 | ||
+ switchInt(move _1) -> [0: bb3, otherwise: bb4]; // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 | ||
+ } | ||
+ | ||
+ bb3: { | ||
+ _0 = const 0_usize; // scope 3 at $DIR/issue_106141.rs:16:9: 16:10 | ||
+ goto -> bb4; // scope 3 at $DIR/issue_106141.rs:13:5: 17:6 | ||
+ } | ||
+ | ||
+ bb4: { | ||
+ StorageDead(_1); // scope 3 at $DIR/issue_106141.rs:17:5: 17:6 | ||
+ StorageDead(_3); // scope 0 at $DIR/issue_106141.rs:+1:5: +1:12 | ||
return; // scope 0 at $DIR/issue_106141.rs:+2:2: +2:2 | ||
} | ||
} | ||
|
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,24 @@ | ||
pub fn outer() -> usize { | ||
inner() | ||
} | ||
|
||
fn index() -> usize { | ||
loop {} | ||
} | ||
|
||
#[inline] | ||
fn inner() -> usize { | ||
let buffer = &[true]; | ||
let index = index(); | ||
if buffer[index] { | ||
index | ||
} else { | ||
0 | ||
} | ||
} | ||
|
||
fn main() { | ||
outer(); | ||
} | ||
|
||
// EMIT_MIR issue_106141.outer.Inline.diff |