@@ -172,12 +172,12 @@ impl<'a> Drop for StatRecorder<'a> {
172172}
173173
174174// only use this for foreign function ABIs and glue, use `decl_rust_fn` for Rust functions
175- fn decl_fn ( llmod : ModuleRef , name : & str , cc : lib:: llvm:: CallConv ,
175+ fn decl_fn ( ccx : & CrateContext , name : & str , cc : lib:: llvm:: CallConv ,
176176 ty : Type , output : ty:: t ) -> ValueRef {
177177
178178 let llfn: ValueRef = name. with_c_str ( |buf| {
179179 unsafe {
180- llvm:: LLVMGetOrInsertFunction ( llmod, buf, ty. to_ref ( ) )
180+ llvm:: LLVMGetOrInsertFunction ( ccx . llmod , buf, ty. to_ref ( ) )
181181 }
182182 } ) ;
183183
@@ -196,17 +196,20 @@ fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv,
196196 lib:: llvm:: SetFunctionCallConv ( llfn, cc) ;
197197 // Function addresses in Rust are never significant, allowing functions to be merged.
198198 lib:: llvm:: SetUnnamedAddr ( llfn, true ) ;
199- set_split_stack ( llfn) ;
199+
200+ if ccx. is_split_stack_supported ( ) {
201+ set_split_stack ( llfn) ;
202+ }
200203
201204 llfn
202205}
203206
204207// only use this for foreign function ABIs and glue, use `decl_rust_fn` for Rust functions
205- pub fn decl_cdecl_fn ( llmod : ModuleRef ,
208+ pub fn decl_cdecl_fn ( ccx : & CrateContext ,
206209 name : & str ,
207210 ty : Type ,
208211 output : ty:: t ) -> ValueRef {
209- decl_fn ( llmod , name, lib:: llvm:: CCallConv , ty, output)
212+ decl_fn ( ccx , name, lib:: llvm:: CCallConv , ty, output)
210213}
211214
212215// only use this for foreign function ABIs and glue, use `get_extern_rust_fn` for Rust functions
@@ -221,7 +224,7 @@ pub fn get_extern_fn(ccx: &CrateContext,
221224 Some ( n) => return * n,
222225 None => { }
223226 }
224- let f = decl_fn ( ccx. llmod , name, cc, ty, output) ;
227+ let f = decl_fn ( ccx, name, cc, ty, output) ;
225228 externs. insert ( name. to_string ( ) , f) ;
226229 f
227230}
@@ -250,7 +253,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str) -> ValueRef {
250253 } ;
251254
252255 let llfty = type_of_rust_fn ( ccx, has_env, inputs. as_slice ( ) , output) ;
253- let llfn = decl_fn ( ccx. llmod , name, lib:: llvm:: CCallConv , llfty, output) ;
256+ let llfn = decl_fn ( ccx, name, lib:: llvm:: CCallConv , llfty, output) ;
254257 let attrs = get_fn_llvm_attributes ( ccx, fn_ty) ;
255258 for & ( idx, attr) in attrs. iter ( ) {
256259 unsafe {
@@ -1877,7 +1880,7 @@ pub fn register_fn_llvmty(ccx: &CrateContext,
18771880 llfty: Type ) -> ValueRef {
18781881 debug!( "register_fn_llvmty id={} sym={}" , node_id, sym) ;
18791882
1880- let llfn = decl_fn( ccx. llmod , sym. as_slice( ) , cc, llfty, ty:: mk_nil( ) ) ;
1883+ let llfn = decl_fn( ccx, sym. as_slice( ) , cc, llfty, ty:: mk_nil( ) ) ;
18811884 finish_register_fn( ccx, sp, sym, node_id, llfn) ;
18821885 llfn
18831886}
@@ -1909,7 +1912,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
19091912 let llfty = Type :: func( [ ccx. int_type, Type :: i8p( ccx) . ptr_to( ) ] ,
19101913 & ccx. int_type) ;
19111914
1912- let llfn = decl_cdecl_fn( ccx. llmod , "main" , llfty, ty:: mk_nil( ) ) ;
1915+ let llfn = decl_cdecl_fn( ccx, "main" , llfty, ty:: mk_nil( ) ) ;
19131916 let llbb = "top" . with_c_str( |buf| {
19141917 unsafe {
19151918 llvm:: LLVMAppendBasicBlockInContext ( ccx. llcx, llfn, buf)
0 commit comments