@@ -172,12 +172,12 @@ impl<'a> Drop for StatRecorder<'a> {
172
172
}
173
173
174
174
// 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 ,
176
176
ty : Type , output : ty:: t ) -> ValueRef {
177
177
178
178
let llfn: ValueRef = name. with_c_str ( |buf| {
179
179
unsafe {
180
- llvm:: LLVMGetOrInsertFunction ( llmod, buf, ty. to_ref ( ) )
180
+ llvm:: LLVMGetOrInsertFunction ( ccx . llmod , buf, ty. to_ref ( ) )
181
181
}
182
182
} ) ;
183
183
@@ -196,17 +196,20 @@ fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv,
196
196
lib:: llvm:: SetFunctionCallConv ( llfn, cc) ;
197
197
// Function addresses in Rust are never significant, allowing functions to be merged.
198
198
lib:: llvm:: SetUnnamedAddr ( llfn, true ) ;
199
- set_split_stack ( llfn) ;
199
+
200
+ if ccx. is_split_stack_supported ( ) {
201
+ set_split_stack ( llfn) ;
202
+ }
200
203
201
204
llfn
202
205
}
203
206
204
207
// 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 ,
206
209
name : & str ,
207
210
ty : Type ,
208
211
output : ty:: t ) -> ValueRef {
209
- decl_fn ( llmod , name, lib:: llvm:: CCallConv , ty, output)
212
+ decl_fn ( ccx , name, lib:: llvm:: CCallConv , ty, output)
210
213
}
211
214
212
215
// 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,
221
224
Some ( n) => return * n,
222
225
None => { }
223
226
}
224
- let f = decl_fn ( ccx. llmod , name, cc, ty, output) ;
227
+ let f = decl_fn ( ccx, name, cc, ty, output) ;
225
228
externs. insert ( name. to_string ( ) , f) ;
226
229
f
227
230
}
@@ -250,7 +253,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str) -> ValueRef {
250
253
} ;
251
254
252
255
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) ;
254
257
let attrs = get_fn_llvm_attributes ( ccx, fn_ty) ;
255
258
for & ( idx, attr) in attrs. iter ( ) {
256
259
unsafe {
@@ -1877,7 +1880,7 @@ pub fn register_fn_llvmty(ccx: &CrateContext,
1877
1880
llfty: Type ) -> ValueRef {
1878
1881
debug!( "register_fn_llvmty id={} sym={}" , node_id, sym) ;
1879
1882
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( ) ) ;
1881
1884
finish_register_fn( ccx, sp, sym, node_id, llfn) ;
1882
1885
llfn
1883
1886
}
@@ -1909,7 +1912,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
1909
1912
let llfty = Type :: func( [ ccx. int_type, Type :: i8p( ccx) . ptr_to( ) ] ,
1910
1913
& ccx. int_type) ;
1911
1914
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( ) ) ;
1913
1916
let llbb = "top" . with_c_str( |buf| {
1914
1917
unsafe {
1915
1918
llvm:: LLVMAppendBasicBlockInContext ( ccx. llcx, llfn, buf)
0 commit comments