-
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.
Mark drop calls in landing pads cold instead of noinline
Now that deferred inlining has been disabled in LLVM, this shouldn't cause catastrophic size blowup.
- Loading branch information
1 parent
7ae5508
commit 2b66221
Showing
6 changed files
with
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// 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,22 @@ | ||
// no-system-llvm: needs 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 this, the box pointers escape, | ||
// and LLVM will not optimize out the pointer comparison. | ||
// See https://github.com/rust-lang/rust/issues/46515 | ||
|
||
// Everything should be optimized out. | ||
// 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(); | ||
} | ||
} |