forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#127113 - scottmcm:retune-inlining-again, r=ol…
…i-obk Avoid MIR bloat in inlining In rust-lang#126578 we ended up with more binary size increases than expected. This change attempts to avoid inlining large things into small things, to avoid that kind of increase, in cases when top-down inlining will still be able to do that inlining later. r? ghost
- Loading branch information
Showing
17 changed files
with
384 additions
and
845 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
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
22 changes: 22 additions & 0 deletions
22
...ir-opt/inline/inline_more_in_non_inline.marked_inline_direct.Inline.after.panic-abort.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,22 @@ | ||
// MIR for `marked_inline_direct` after Inline | ||
|
||
fn marked_inline_direct(_1: i32) -> () { | ||
debug x => _1; | ||
let mut _0: (); | ||
let _2: (); | ||
let mut _3: i32; | ||
|
||
bb0: { | ||
StorageLive(_2); | ||
StorageLive(_3); | ||
_3 = _1; | ||
_2 = call_twice(move _3) -> [return: bb1, unwind unreachable]; | ||
} | ||
|
||
bb1: { | ||
StorageDead(_3); | ||
StorageDead(_2); | ||
_0 = const (); | ||
return; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...r-opt/inline/inline_more_in_non_inline.marked_inline_direct.Inline.after.panic-unwind.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,22 @@ | ||
// MIR for `marked_inline_direct` after Inline | ||
|
||
fn marked_inline_direct(_1: i32) -> () { | ||
debug x => _1; | ||
let mut _0: (); | ||
let _2: (); | ||
let mut _3: i32; | ||
|
||
bb0: { | ||
StorageLive(_2); | ||
StorageLive(_3); | ||
_3 = _1; | ||
_2 = call_twice(move _3) -> [return: bb1, unwind continue]; | ||
} | ||
|
||
bb1: { | ||
StorageDead(_3); | ||
StorageDead(_2); | ||
_0 = const (); | ||
return; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...-opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-abort.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,27 @@ | ||
// MIR for `marked_inline_indirect` after Inline | ||
|
||
fn marked_inline_indirect(_1: i32) -> () { | ||
debug x => _1; | ||
let mut _0: (); | ||
let _2: (); | ||
let mut _3: i32; | ||
scope 1 (inlined marked_inline_direct) { | ||
let _4: (); | ||
} | ||
|
||
bb0: { | ||
StorageLive(_2); | ||
StorageLive(_3); | ||
_3 = _1; | ||
StorageLive(_4); | ||
_4 = call_twice(move _3) -> [return: bb1, unwind unreachable]; | ||
} | ||
|
||
bb1: { | ||
StorageDead(_4); | ||
StorageDead(_3); | ||
StorageDead(_2); | ||
_0 = const (); | ||
return; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-unwind.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,27 @@ | ||
// MIR for `marked_inline_indirect` after Inline | ||
|
||
fn marked_inline_indirect(_1: i32) -> () { | ||
debug x => _1; | ||
let mut _0: (); | ||
let _2: (); | ||
let mut _3: i32; | ||
scope 1 (inlined marked_inline_direct) { | ||
let _4: (); | ||
} | ||
|
||
bb0: { | ||
StorageLive(_2); | ||
StorageLive(_3); | ||
_3 = _1; | ||
StorageLive(_4); | ||
_4 = call_twice(move _3) -> [return: bb1, unwind continue]; | ||
} | ||
|
||
bb1: { | ||
StorageDead(_4); | ||
StorageDead(_3); | ||
StorageDead(_2); | ||
_0 = const (); | ||
return; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...-opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-abort.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,34 @@ | ||
// MIR for `monomorphic_not_inline` after Inline | ||
|
||
fn monomorphic_not_inline(_1: i32) -> () { | ||
debug x => _1; | ||
let mut _0: (); | ||
let _2: (); | ||
let mut _3: i32; | ||
scope 1 (inlined call_twice) { | ||
let _4: (); | ||
let _5: (); | ||
} | ||
|
||
bb0: { | ||
StorageLive(_2); | ||
StorageLive(_3); | ||
_3 = _1; | ||
StorageLive(_4); | ||
StorageLive(_5); | ||
_4 = other_thing(_3) -> [return: bb2, unwind unreachable]; | ||
} | ||
|
||
bb1: { | ||
StorageDead(_5); | ||
StorageDead(_4); | ||
StorageDead(_3); | ||
StorageDead(_2); | ||
_0 = const (); | ||
return; | ||
} | ||
|
||
bb2: { | ||
_5 = other_thing(move _3) -> [return: bb1, unwind unreachable]; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-unwind.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,34 @@ | ||
// MIR for `monomorphic_not_inline` after Inline | ||
|
||
fn monomorphic_not_inline(_1: i32) -> () { | ||
debug x => _1; | ||
let mut _0: (); | ||
let _2: (); | ||
let mut _3: i32; | ||
scope 1 (inlined call_twice) { | ||
let _4: (); | ||
let _5: (); | ||
} | ||
|
||
bb0: { | ||
StorageLive(_2); | ||
StorageLive(_3); | ||
_3 = _1; | ||
StorageLive(_4); | ||
StorageLive(_5); | ||
_4 = other_thing(_3) -> [return: bb2, unwind continue]; | ||
} | ||
|
||
bb1: { | ||
StorageDead(_5); | ||
StorageDead(_4); | ||
StorageDead(_3); | ||
StorageDead(_2); | ||
_0 = const (); | ||
return; | ||
} | ||
|
||
bb2: { | ||
_5 = other_thing(move _3) -> [return: bb1, unwind continue]; | ||
} | ||
} |
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,46 @@ | ||
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY | ||
//@ compile-flags: -O --crate-type lib | ||
|
||
// To avoid MIR blow-up, don't inline large callees into simple shim callers, | ||
// but *do* inline other trivial things. | ||
|
||
extern "Rust" { | ||
fn other_thing(x: i32); | ||
} | ||
|
||
#[inline] | ||
unsafe fn call_twice(x: i32) { | ||
unsafe { | ||
other_thing(x); | ||
other_thing(x); | ||
} | ||
} | ||
|
||
// EMIT_MIR inline_more_in_non_inline.monomorphic_not_inline.Inline.after.mir | ||
#[no_mangle] | ||
pub unsafe fn monomorphic_not_inline(x: i32) { | ||
// CHECK-LABEL: monomorphic_not_inline | ||
// CHECK: other_thing | ||
// CHECK: other_thing | ||
unsafe { call_twice(x) }; | ||
} | ||
|
||
// EMIT_MIR inline_more_in_non_inline.marked_inline_direct.Inline.after.mir | ||
#[inline] | ||
pub unsafe fn marked_inline_direct(x: i32) { | ||
// CHECK-LABEL: marked_inline_direct | ||
// CHECK-NOT: other_thing | ||
// CHECK: call_twice | ||
// CHECK-NOT: other_thing | ||
unsafe { call_twice(x) }; | ||
} | ||
|
||
// EMIT_MIR inline_more_in_non_inline.marked_inline_indirect.Inline.after.mir | ||
#[inline] | ||
pub unsafe fn marked_inline_indirect(x: i32) { | ||
// CHECK-LABEL: marked_inline_indirect | ||
// CHECK-NOT: other_thing | ||
// CHECK: call_twice | ||
// CHECK-NOT: other_thing | ||
unsafe { marked_inline_direct(x) }; | ||
} |
Oops, something went wrong.