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#117783 - tmiasko:inline-ret, r=cjgillot
Fix insertion of statements to be executed along return edge in inlining Inlining creates additional statements to be executed along the return edge: an assignment to the destination, storage end for temporaries. Previously those statements where inserted directly into a call target, but this is incorrect when the target has other predecessors. Avoid the issue by creating a new dedicated block for those statements. When the block happens to be redundant it will be removed by CFG simplification that follows inlining. Fixes rust-lang#117355
- Loading branch information
Showing
13 changed files
with
356 additions
and
725 deletions.
There are no files selected for viewing
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
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,42 @@ | ||
// Test for inlining with an indirect destination place. | ||
// | ||
// unit-test: Inline | ||
// edition: 2021 | ||
// needs-unwind | ||
#![crate_type = "lib"] | ||
#![feature(custom_mir, core_intrinsics)] | ||
use core::intrinsics::mir::*; | ||
|
||
#[custom_mir(dialect = "runtime", phase = "initial")] | ||
// CHECK-LABEL: fn f( | ||
// CHECK: bb1: { | ||
// CHECK-NEXT: StorageLive([[A:.*]]); | ||
// CHECK-NEXT: [[A]] = &mut (*_1); | ||
// CHECK-NEXT: StorageLive([[B:.*]]); | ||
// CHECK-NEXT: [[B]] = const 42_u8; | ||
// CHECK-NEXT: (*[[A]]) = move [[B]]; | ||
// CHECK-NEXT: StorageDead([[B]]); | ||
// CHECK-NEXT: StorageDead([[A]]); | ||
// CHECK-NEXT: goto -> bb1; | ||
// CHECK-NEXT: } | ||
pub fn f(a: *mut u8) { | ||
mir! { | ||
{ | ||
Goto(bb1) | ||
} | ||
bb1 = { | ||
Call(*a = g(), bb1, UnwindUnreachable()) | ||
} | ||
} | ||
} | ||
|
||
#[custom_mir(dialect = "runtime", phase = "initial")] | ||
#[inline(always)] | ||
fn g() -> u8 { | ||
mir! { | ||
{ | ||
RET = 42; | ||
Return() | ||
} | ||
} | ||
} |
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.