@@ -204,7 +204,7 @@ pub fn decl_fn(ccx: &CrateContext, name: &str, cc: llvm::CallConv,
204
204
// Function addresses in Rust are never significant, allowing functions to be merged.
205
205
llvm:: SetUnnamedAddr ( llfn, true ) ;
206
206
207
- if ccx. is_split_stack_supported ( ) {
207
+ if ccx. is_split_stack_supported ( ) && !ccx . sess ( ) . opts . cg . no_stack_check {
208
208
set_split_stack ( llfn) ;
209
209
}
210
210
@@ -245,7 +245,7 @@ fn get_extern_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str, did: ast::De
245
245
let f = decl_rust_fn ( ccx, fn_ty, name) ;
246
246
247
247
csearch:: get_item_attrs ( & ccx. sess ( ) . cstore , did, |attrs| {
248
- set_llvm_fn_attrs ( attrs. as_slice ( ) , f)
248
+ set_llvm_fn_attrs ( ccx , attrs. as_slice ( ) , f)
249
249
} ) ;
250
250
251
251
ccx. externs ( ) . borrow_mut ( ) . insert ( name. to_string ( ) , f) ;
@@ -450,7 +450,7 @@ pub fn set_inline_hint(f: ValueRef) {
450
450
llvm:: SetFunctionAttribute ( f, llvm:: InlineHintAttribute )
451
451
}
452
452
453
- pub fn set_llvm_fn_attrs ( attrs : & [ ast:: Attribute ] , llfn : ValueRef ) {
453
+ pub fn set_llvm_fn_attrs ( ccx : & CrateContext , attrs : & [ ast:: Attribute ] , llfn : ValueRef ) {
454
454
use syntax:: attr:: * ;
455
455
// Set the inline hint if there is one
456
456
match find_inline_attr ( attrs) {
@@ -460,16 +460,24 @@ pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
460
460
InlineNone => { /* fallthrough */ }
461
461
}
462
462
463
- // Add the no-split-stack attribute if requested
464
- if contains_name ( attrs, "no_split_stack" ) {
465
- unset_split_stack ( llfn) ;
466
- }
467
-
468
- if contains_name ( attrs, "cold" ) {
469
- unsafe {
470
- llvm:: LLVMAddFunctionAttribute ( llfn,
471
- llvm:: FunctionIndex as c_uint ,
472
- llvm:: ColdAttribute as uint64_t )
463
+ for attr in attrs. iter ( ) {
464
+ let mut used = true ;
465
+ match attr. name ( ) . get ( ) {
466
+ "no_stack_check" => unset_split_stack ( llfn) ,
467
+ "no_split_stack" => {
468
+ unset_split_stack ( llfn) ;
469
+ ccx. sess ( ) . span_warn ( attr. span ,
470
+ "no_split_stack is a deprecated synonym for no_stack_check" ) ;
471
+ }
472
+ "cold" => unsafe {
473
+ llvm:: LLVMAddFunctionAttribute ( llfn,
474
+ llvm:: FunctionIndex as c_uint ,
475
+ llvm:: ColdAttribute as uint64_t )
476
+ } ,
477
+ _ => used = false ,
478
+ }
479
+ if used {
480
+ attr:: mark_used ( attr) ;
473
481
}
474
482
}
475
483
}
@@ -2732,7 +2740,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2732
2740
sym,
2733
2741
i. id )
2734
2742
} ;
2735
- set_llvm_fn_attrs ( i. attrs . as_slice ( ) , llfn) ;
2743
+ set_llvm_fn_attrs ( ccx , i. attrs . as_slice ( ) , llfn) ;
2736
2744
llfn
2737
2745
}
2738
2746
@@ -2874,7 +2882,7 @@ fn register_method(ccx: &CrateContext, id: ast::NodeId,
2874
2882
let sym = exported_name ( ccx, id, mty, m. attrs . as_slice ( ) ) ;
2875
2883
2876
2884
let llfn = register_fn ( ccx, m. span , sym, id, mty) ;
2877
- set_llvm_fn_attrs ( m. attrs . as_slice ( ) , llfn) ;
2885
+ set_llvm_fn_attrs ( ccx , m. attrs . as_slice ( ) , llfn) ;
2878
2886
llfn
2879
2887
}
2880
2888
0 commit comments