-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Use probe-stack=inline-asm in LLVM 11+ #77885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// min-llvm-version: 11.0.1 | ||
// revisions: x86_64 i686 | ||
// assembly-output: emit-asm | ||
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu | ||
//[i686] compile-flags: --target i686-unknown-linux-gnu | ||
// compile-flags: -C llvm-args=--x86-asm-syntax=intel | ||
|
||
#![feature(no_core, lang_items)] | ||
#![crate_type = "lib"] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
#[lang = "copy"] | ||
trait Copy {} | ||
|
||
impl Copy for u8 {} | ||
|
||
// Check that inline-asm stack probes are generated correctly. | ||
// To avoid making this test fragile to slight asm changes, | ||
// we only check that the stack pointer is decremented by a page at a time, | ||
// instead of matching the whole probe sequence. | ||
|
||
// CHECK-LABEL: small_stack_probe: | ||
#[no_mangle] | ||
pub fn small_stack_probe(x: u8, f: fn([u8; 8192])) { | ||
// CHECK-NOT: __rust_probestack | ||
// x86_64: sub rsp, 4096 | ||
// i686: sub esp, 4096 | ||
let a = [x; 8192]; | ||
f(a); | ||
} | ||
|
||
// CHECK-LABEL: big_stack_probe: | ||
#[no_mangle] | ||
pub fn big_stack_probe(x: u8, f: fn([u8; 65536])) { | ||
// CHECK-NOT: __rust_probestack | ||
// x86_64: sub rsp, 4096 | ||
// i686: sub esp, 4096 | ||
let a = [x; 65536]; | ||
f(a); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,12 @@ | |
// ignore-emscripten | ||
// ignore-windows | ||
// compile-flags: -C no-prepopulate-passes | ||
// min-llvm-version: 11.0.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. by the way, doesn't adding this mean that we are effectively no longer unit-testing our old stack-probe strategy, since we will just skip this test if the LLVM version is not sufficiently new? Maybe we should have two files, one for LLVM < 11.0.1 and one for LLVM >= 11.0.1? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't generally test very meticulously the setups that use LLVM versions outside of what is in the Rust repository. This is reflected in e.g. tests for all our (oft backported) soundness fixes only being applicable to the newest LLVM versions and our fork. So far it has been the unwritten policy that it is up to the users who build with alternative LLVM versions to ensure that their builds do what they expect. (This is also another of those things that I should eventually look into codifying in some document outlining our LLVM support strategy) |
||
|
||
#![crate_type = "lib"] | ||
|
||
#[no_mangle] | ||
pub fn foo() { | ||
// CHECK: @foo() unnamed_addr #0 | ||
// CHECK: attributes #0 = { {{.*}}"probe-stack"="__rust_probestack"{{.*}} } | ||
// CHECK: attributes #0 = { {{.*}}"probe-stack"="inline-asm"{{.*}} } | ||
} |
Uh oh!
There was an error while loading. Please reload this page.