Skip to content

Commit

Permalink
Use stack probes instead of segmented stack support on x86
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Aug 21, 2014
1 parent 4444aec commit ecec992
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ pub fn decl_fn(ccx: &CrateContext, name: &str, cc: llvm::CallConv,
// Function addresses in Rust are never significant, allowing functions to be merged.
llvm::SetUnnamedAddr(llfn, true);

if ccx.is_split_stack_supported() {
if ccx.is_probe_stack_supported() {
set_probe_stack(llfn);
} else if ccx.is_split_stack_supported() {
set_split_stack(llfn);
}

Expand Down Expand Up @@ -478,6 +480,12 @@ pub fn set_always_inline(f: ValueRef) {
llvm::SetFunctionAttribute(f, llvm::AlwaysInlineAttribute)
}

pub fn set_probe_stack(f: ValueRef) {
"probe-stack".with_c_str(|buf| {
unsafe { llvm::LLVMAddFunctionAttrString(f, llvm::FunctionIndex as c_uint, buf); }
})
}

pub fn set_split_stack(f: ValueRef) {
"split-stack".with_c_str(|buf| {
unsafe { llvm::LLVMAddFunctionAttrString(f, llvm::FunctionIndex as c_uint, buf); }
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/middle/trans/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ impl CrateContext {
let ref cfg = self.sess().targ_cfg;
cfg.os != abi::OsiOS || cfg.arch != abi::Arm
}

pub fn is_probe_stack_supported(&self) -> bool {
match self.sess().targ_cfg.arch {
abi::X86 | abi::X86_64 => true,
_ => false
}
}
}

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

0 comments on commit ecec992

Please sign in to comment.