Skip to content

Commit d86dfbd

Browse files
committed
---
yaml --- r: 150931 b: refs/heads/try2 c: 50fb57b h: refs/heads/master i: 150929: 2b30d34 150927: 132fd32 v: v3
1 parent e64ad30 commit d86dfbd

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ba25fecfeffdbc96d31172f483bd20cffa635b3e
8+
refs/heads/try2: 50fb57bb107b302f7d164e22aa75c8c2a2d48756
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/lib/llvm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ pub mod llvm {
709709
pub fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
710710
pub fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint);
711711
pub fn LLVMAddFunctionAttrString(Fn: ValueRef, Name: *c_char);
712+
pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, Name: *c_char);
712713
pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
713714

714715
pub fn LLVMAddReturnAttribute(Fn: ValueRef, PA: c_uint);

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv,
199199
lib::llvm::SetFunctionCallConv(llfn, cc);
200200
// Function addresses in Rust are never significant, allowing functions to be merged.
201201
lib::llvm::SetUnnamedAddr(llfn, true);
202+
set_split_stack(llfn);
202203

203204
llfn
204205
}
@@ -445,8 +446,8 @@ pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
445446
}
446447

447448
// Add the no-split-stack attribute if requested
448-
if !contains_name(attrs, "no_split_stack") {
449-
set_split_stack(llfn);
449+
if contains_name(attrs, "no_split_stack") {
450+
unset_split_stack(llfn);
450451
}
451452

452453
if contains_name(attrs, "cold") {
@@ -464,6 +465,12 @@ pub fn set_split_stack(f: ValueRef) {
464465
})
465466
}
466467

468+
pub fn unset_split_stack(f: ValueRef) {
469+
"split-stack".with_c_str(|buf| {
470+
unsafe { llvm::LLVMRemoveFunctionAttrString(f, buf); }
471+
})
472+
}
473+
467474
// Double-check that we never ask LLVM to declare the same symbol twice. It
468475
// silently mangles such symbols, breaking our linkage model.
469476
pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: ~str) {

branches/try2/src/rustllvm/RustWrapper.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ extern "C" void LLVMAddFunctionAttrString(LLVMValueRef fn, const char *Name) {
7777
unwrap<Function>(fn)->addFnAttr(Name);
7878
}
7979

80+
extern "C" void LLVMRemoveFunctionAttrString(LLVMValueRef fn, const char *Name) {
81+
Function *f = unwrap<Function>(fn);
82+
LLVMContext &C = f->getContext();
83+
AttrBuilder B;
84+
B.addAttribute(Name);
85+
AttributeSet to_remove = AttributeSet::get(C, AttributeSet::FunctionIndex, B);
86+
87+
AttributeSet attrs = f->getAttributes();
88+
f->setAttributes(attrs.removeAttributes(f->getContext(),
89+
AttributeSet::FunctionIndex,
90+
to_remove));
91+
}
8092

8193
extern "C" void LLVMAddReturnAttribute(LLVMValueRef Fn, LLVMAttribute PA) {
8294
Function *A = unwrap<Function>(Fn);

0 commit comments

Comments
 (0)