Skip to content

Commit ecec992

Browse files
committed
Use stack probes instead of segmented stack support on x86
Fixes rust-lang#13259 and rust-lang#14742
1 parent 4444aec commit ecec992

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ pub fn decl_fn(ccx: &CrateContext, name: &str, cc: llvm::CallConv,
210210
// Function addresses in Rust are never significant, allowing functions to be merged.
211211
llvm::SetUnnamedAddr(llfn, true);
212212

213-
if ccx.is_split_stack_supported() {
213+
if ccx.is_probe_stack_supported() {
214+
set_probe_stack(llfn);
215+
} else if ccx.is_split_stack_supported() {
214216
set_split_stack(llfn);
215217
}
216218

@@ -478,6 +480,12 @@ pub fn set_always_inline(f: ValueRef) {
478480
llvm::SetFunctionAttribute(f, llvm::AlwaysInlineAttribute)
479481
}
480482

483+
pub fn set_probe_stack(f: ValueRef) {
484+
"probe-stack".with_c_str(|buf| {
485+
unsafe { llvm::LLVMAddFunctionAttrString(f, llvm::FunctionIndex as c_uint, buf); }
486+
})
487+
}
488+
481489
pub fn set_split_stack(f: ValueRef) {
482490
"split-stack".with_c_str(|buf| {
483491
unsafe { llvm::LLVMAddFunctionAttrString(f, llvm::FunctionIndex as c_uint, buf); }

src/librustc/middle/trans/context.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ impl CrateContext {
286286
let ref cfg = self.sess().targ_cfg;
287287
cfg.os != abi::OsiOS || cfg.arch != abi::Arm
288288
}
289+
290+
pub fn is_probe_stack_supported(&self) -> bool {
291+
match self.sess().targ_cfg.arch {
292+
abi::X86 | abi::X86_64 => true,
293+
_ => false
294+
}
295+
}
289296
}
290297

291298
fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef> {

0 commit comments

Comments
 (0)