In upgrading LLVM, only rust functions had the "split-stack" attribute added.
This commit changes the addition of LLVM's "split-stack" attribute to *always*
occur and then we remove it sometimes if the "no_split_stack" rust attribute is
present.
Closes #13625
pub fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
pub fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint);
pub fn LLVMAddFunctionAttrString(Fn: ValueRef, Name: *c_char);
+ pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, Name: *c_char);
pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
pub fn LLVMAddReturnAttribute(Fn: ValueRef, PA: c_uint);
lib::llvm::SetFunctionCallConv(llfn, cc);
// Function addresses in Rust are never significant, allowing functions to be merged.
lib::llvm::SetUnnamedAddr(llfn, true);
+ set_split_stack(llfn);
llfn
}
}
// Add the no-split-stack attribute if requested
- if !contains_name(attrs, "no_split_stack") {
- set_split_stack(llfn);
+ if contains_name(attrs, "no_split_stack") {
+ unset_split_stack(llfn);
}
if contains_name(attrs, "cold") {
})
}
+pub fn unset_split_stack(f: ValueRef) {
+ "split-stack".with_c_str(|buf| {
+ unsafe { llvm::LLVMRemoveFunctionAttrString(f, buf); }
+ })
+}
+
// Double-check that we never ask LLVM to declare the same symbol twice. It
// silently mangles such symbols, breaking our linkage model.
pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: ~str) {
unwrap<Function>(fn)->addFnAttr(Name);
}
+extern "C" void LLVMRemoveFunctionAttrString(LLVMValueRef fn, const char *Name) {
+ Function *f = unwrap<Function>(fn);
+ LLVMContext &C = f->getContext();
+ AttrBuilder B;
+ B.addAttribute(Name);
+ AttributeSet to_remove = AttributeSet::get(C, AttributeSet::FunctionIndex, B);
+
+ AttributeSet attrs = f->getAttributes();
+ f->setAttributes(attrs.removeAttributes(f->getContext(),
+ AttributeSet::FunctionIndex,
+ to_remove));
+}
extern "C" void LLVMAddReturnAttribute(LLVMValueRef Fn, LLVMAttribute PA) {
Function *A = unwrap<Function>(Fn);