@@ -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) ;
@@ -436,7 +436,7 @@ pub fn set_inline_hint(f: ValueRef) {
436
436
llvm:: SetFunctionAttribute ( f, llvm:: InlineHintAttribute )
437
437
}
438
438
439
- pub fn set_llvm_fn_attrs ( attrs : & [ ast:: Attribute ] , llfn : ValueRef ) {
439
+ pub fn set_llvm_fn_attrs ( ccx : & CrateContext , attrs : & [ ast:: Attribute ] , llfn : ValueRef ) {
440
440
use syntax:: attr:: * ;
441
441
// Set the inline hint if there is one
442
442
match find_inline_attr ( attrs) {
@@ -446,16 +446,24 @@ pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
446
446
InlineNone => { /* fallthrough */ }
447
447
}
448
448
449
- // Add the no-split-stack attribute if requested
450
- if contains_name ( attrs, "no_split_stack" ) {
451
- unset_split_stack ( llfn) ;
452
- }
453
-
454
- if contains_name ( attrs, "cold" ) {
455
- unsafe {
456
- llvm:: LLVMAddFunctionAttribute ( llfn,
457
- llvm:: FunctionIndex as c_uint ,
458
- llvm:: ColdAttribute as uint64_t )
449
+ for attr in attrs. iter ( ) {
450
+ let mut used = true ;
451
+ match attr. name ( ) . get ( ) {
452
+ "no_stack_check" => unset_split_stack ( llfn) ,
453
+ "no_split_stack" => {
454
+ unset_split_stack ( llfn) ;
455
+ ccx. sess ( ) . span_warn ( attr. span ,
456
+ "no_split_stack is a deprecated synonym for no_stack_check" ) ;
457
+ }
458
+ "cold" => unsafe {
459
+ llvm:: LLVMAddFunctionAttribute ( llfn,
460
+ llvm:: FunctionIndex as c_uint ,
461
+ llvm:: ColdAttribute as uint64_t )
462
+ } ,
463
+ _ => used = false ,
464
+ }
465
+ if used {
466
+ attr:: mark_used ( attr) ;
459
467
}
460
468
}
461
469
}
@@ -2751,7 +2759,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2751
2759
sym,
2752
2760
i. id )
2753
2761
} ;
2754
- set_llvm_fn_attrs ( i. attrs . as_slice ( ) , llfn) ;
2762
+ set_llvm_fn_attrs ( ccx , i. attrs . as_slice ( ) , llfn) ;
2755
2763
llfn
2756
2764
}
2757
2765
@@ -2893,7 +2901,7 @@ fn register_method(ccx: &CrateContext, id: ast::NodeId,
2893
2901
let sym = exported_name ( ccx, id, mty, m. attrs . as_slice ( ) ) ;
2894
2902
2895
2903
let llfn = register_fn ( ccx, m. span , sym, id, mty) ;
2896
- set_llvm_fn_attrs ( m. attrs . as_slice ( ) , llfn) ;
2904
+ set_llvm_fn_attrs ( ccx , m. attrs . as_slice ( ) , llfn) ;
2897
2905
llfn
2898
2906
}
2899
2907
0 commit comments