@@ -245,7 +245,7 @@ fn get_extern_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str, did: ast::De
245245 let f = decl_rust_fn ( ccx, fn_ty, name) ;
246246
247247 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)
249249 } ) ;
250250
251251 ccx. externs ( ) . borrow_mut ( ) . insert ( name. to_string ( ) , f) ;
@@ -436,7 +436,7 @@ pub fn set_inline_hint(f: ValueRef) {
436436 llvm:: SetFunctionAttribute ( f, llvm:: InlineHintAttribute )
437437}
438438
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 ) {
440440 use syntax:: attr:: * ;
441441 // Set the inline hint if there is one
442442 match find_inline_attr ( attrs) {
@@ -446,16 +446,24 @@ pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
446446 InlineNone => { /* fallthrough */ }
447447 }
448448
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) ;
459467 }
460468 }
461469}
@@ -2751,7 +2759,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
27512759 sym,
27522760 i. id )
27532761 } ;
2754- set_llvm_fn_attrs ( i. attrs . as_slice ( ) , llfn) ;
2762+ set_llvm_fn_attrs ( ccx , i. attrs . as_slice ( ) , llfn) ;
27552763 llfn
27562764 }
27572765
@@ -2893,7 +2901,7 @@ fn register_method(ccx: &CrateContext, id: ast::NodeId,
28932901 let sym = exported_name ( ccx, id, mty, m. attrs . as_slice ( ) ) ;
28942902
28952903 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) ;
28972905 llfn
28982906}
28992907
0 commit comments