-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #78873 - tmiasko:inline-opts, r=oli-obk
Add flags customizing behaviour of MIR inlining * `-Zinline-mir-threshold` to change the default threshold. * `-Zinline-mir-hint-threshold` to change the threshold used by functions with inline hint. Having those as configurable flags makes it possible to experiment with with different inlining thresholds and substantially increase test coverage of MIR inlining when used with increased thresholds (for example, necessary to test #78844).
- Loading branch information
Showing
5 changed files
with
86 additions
and
4 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
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,19 @@ | ||
// Checks that inlining threshold can be controlled with | ||
// inline-mir-threshold and inline-hint-threshold options. | ||
// | ||
// compile-flags: -Zinline-mir-threshold=90 | ||
// compile-flags: -Zinline-mir-hint-threshold=50 | ||
|
||
// EMIT_MIR inline_options.main.Inline.after.mir | ||
fn main() { | ||
not_inlined(); | ||
inlined::<u32>(); | ||
} | ||
|
||
// Cost is approximately 3 * 25 + 5 = 80. | ||
#[inline] | ||
pub fn not_inlined() { g(); g(); g(); } | ||
pub fn inlined<T>() { g(); g(); g(); } | ||
|
||
#[inline(never)] | ||
fn g() {} |
56 changes: 56 additions & 0 deletions
56
src/test/mir-opt/inline/inline_options.main.Inline.after.mir
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,56 @@ | ||
// MIR for `main` after Inline | ||
|
||
fn main() -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/inline-options.rs:8:11: 8:11 | ||
let _1: (); // in scope 0 at $DIR/inline-options.rs:9:5: 9:18 | ||
let _2: (); // in scope 0 at $DIR/inline-options.rs:10:5: 10:21 | ||
scope 1 (inlined inlined::<u32>) { // at $DIR/inline-options.rs:10:5: 10:21 | ||
let _3: (); // in scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
let _4: (); // in scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
let _5: (); // in scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); // scope 0 at $DIR/inline-options.rs:9:5: 9:18 | ||
_1 = not_inlined() -> bb1; // scope 0 at $DIR/inline-options.rs:9:5: 9:18 | ||
// mir::Constant | ||
// + span: $DIR/inline-options.rs:9:5: 9:16 | ||
// + literal: Const { ty: fn() {not_inlined}, val: Value(Scalar(<ZST>)) } | ||
} | ||
|
||
bb1: { | ||
StorageDead(_1); // scope 0 at $DIR/inline-options.rs:9:18: 9:19 | ||
StorageLive(_2); // scope 0 at $DIR/inline-options.rs:10:5: 10:21 | ||
StorageLive(_3); // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
_3 = g() -> bb2; // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
// mir::Constant | ||
// + span: $DIR/inline-options.rs:10:5: 10:21 | ||
// + literal: Const { ty: fn() {g}, val: Value(Scalar(<ZST>)) } | ||
} | ||
|
||
bb2: { | ||
StorageDead(_3); // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
StorageLive(_4); // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
_4 = g() -> bb3; // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
// mir::Constant | ||
// + span: $DIR/inline-options.rs:10:5: 10:21 | ||
// + literal: Const { ty: fn() {g}, val: Value(Scalar(<ZST>)) } | ||
} | ||
|
||
bb3: { | ||
StorageDead(_4); // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
StorageLive(_5); // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
_5 = g() -> bb4; // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
// mir::Constant | ||
// + span: $DIR/inline-options.rs:10:5: 10:21 | ||
// + literal: Const { ty: fn() {g}, val: Value(Scalar(<ZST>)) } | ||
} | ||
|
||
bb4: { | ||
StorageDead(_5); // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
_2 = const (); // scope 1 at $DIR/inline-options.rs:10:5: 10:21 | ||
StorageDead(_2); // scope 0 at $DIR/inline-options.rs:10:21: 10:22 | ||
_0 = const (); // scope 0 at $DIR/inline-options.rs:8:11: 11:2 | ||
return; // scope 0 at $DIR/inline-options.rs:11:2: 11:2 | ||
} | ||
} |