forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#92419 - erikdesjardins:coldland, r=nagisa
Mark drop calls in landing pads `cold` instead of `noinline` Now that deferred inlining has been disabled in LLVM (rust-lang#92110), this shouldn't cause catastrophic size blowup. I confirmed that the test cases from rust-lang#41696 (comment) still compile quickly (<1s) after this change. ~Although note that I wasn't able to reproduce the original issue using a recent rustc/llvm with deferred inlining enabled, so those tests may no longer be representative. I was also unable to create a modified test case that reproduced the original issue.~ (edit: I reproduced it on CI by accident--the first commit timed out on the LLVM 12 builder, because I forgot to make it conditional on LLVM version) r? `@nagisa` cc `@arielb1` (this effectively reverts rust-lang#42771 "mark calls in the unwind path as !noinline") cc `@RalfJung` (fixes rust-lang#46515) edit: also fixes rust-lang#87055
- Loading branch information
Showing
9 changed files
with
80 additions
and
9 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
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,15 @@ | ||
// no-system-llvm: needs #92110 | ||
// compile-flags: -Cno-prepopulate-passes | ||
#![crate_type = "lib"] | ||
|
||
// This test checks that drop calls in unwind landing pads | ||
// get the `cold` attribute. | ||
|
||
// CHECK-LABEL: @check_cold | ||
// CHECK: call void {{.+}}drop_in_place{{.+}} [[ATTRIBUTES:#[0-9]+]] | ||
// CHECK: attributes [[ATTRIBUTES]] = { cold } | ||
#[no_mangle] | ||
pub fn check_cold(f: fn(), x: Box<u32>) { | ||
// this may unwind | ||
f(); | ||
} |
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,37 @@ | ||
// no-system-llvm: needs #92110 + patch for Rust alloc/dealloc functions | ||
// compile-flags: -Copt-level=3 | ||
#![crate_type = "lib"] | ||
|
||
// This test checks that we can inline drop_in_place in | ||
// unwind landing pads. | ||
|
||
// Without inlining, the box pointers escape via the call to drop_in_place, | ||
// and LLVM will not optimize out the pointer comparison. | ||
// With inlining, everything should be optimized out. | ||
// See https://github.com/rust-lang/rust/issues/46515 | ||
// CHECK-LABEL: @check_no_escape_in_landingpad | ||
// CHECK: start: | ||
// CHECK-NEXT: ret void | ||
#[no_mangle] | ||
pub fn check_no_escape_in_landingpad(f: fn()) { | ||
let x = &*Box::new(0); | ||
let y = &*Box::new(0); | ||
|
||
if x as *const _ == y as *const _ { | ||
f(); | ||
} | ||
} | ||
|
||
// Without inlining, the compiler can't tell that | ||
// dropping an empty string (in a landing pad) does nothing. | ||
// With inlining, the landing pad should be optimized out. | ||
// See https://github.com/rust-lang/rust/issues/87055 | ||
// CHECK-LABEL: @check_eliminate_noop_drop | ||
// CHECK: start: | ||
// CHECK-NEXT: call void %g() | ||
// CHECK-NEXT: ret void | ||
#[no_mangle] | ||
pub fn check_eliminate_noop_drop(g: fn()) { | ||
let _var = String::new(); | ||
g(); | ||
} |