@@ -341,15 +341,25 @@ fn C_tydesc(TypeRef t) -> ValueRef {
341
341
C_null ( T_opaque ( ) ) ) ) ; // is_stateful
342
342
}
343
343
344
- fn decl_cdecl_fn ( ModuleRef llmod, str name ,
345
- vec[ TypeRef ] inputs , TypeRef output) -> ValueRef {
344
+ fn decl_fn ( ModuleRef llmod, str name ,
345
+ uint cc , vec[ TypeRef ] inputs , TypeRef output) -> ValueRef {
346
346
let TypeRef llty = T_fn ( inputs, output) ;
347
347
let ValueRef llfn =
348
348
llvm. LLVMAddFunction ( llmod, _str. buf ( name) , llty) ;
349
- llvm. LLVMSetFunctionCallConv ( llfn, lib . llvm . LLVMCCallConv ) ;
349
+ llvm. LLVMSetFunctionCallConv ( llfn, cc ) ;
350
350
ret llfn;
351
351
}
352
352
353
+ fn decl_cdecl_fn ( ModuleRef llmod, str name ,
354
+ vec[ TypeRef ] inputs , TypeRef output) -> ValueRef {
355
+ ret decl_fn ( llmod, name, lib. llvm . LLVMCCallConv , inputs, output) ;
356
+ }
357
+
358
+ fn decl_fastcall_fn ( ModuleRef llmod, str name ,
359
+ vec[ TypeRef ] inputs , TypeRef output) -> ValueRef {
360
+ ret decl_fn ( llmod, name, lib. llvm . LLVMFastCallConv , inputs, output) ;
361
+ }
362
+
353
363
fn decl_glue ( ModuleRef llmod, str s) -> ValueRef {
354
364
ret decl_cdecl_fn ( llmod, s, vec ( T_taskptr ( ) ) , T_void ( ) ) ;
355
365
}
@@ -947,6 +957,8 @@ impure fn trans_expr(@block_ctxt cx, &ast.expr e) -> result {
947
957
cx. fcx . lltaskptr ) ;
948
958
llargs += args_res. _1 ;
949
959
auto call_val = args_res. _0 . build . Call ( f_res. _0 . val , llargs) ;
960
+ llvm. LLVMSetInstructionCallConv ( call_val,
961
+ lib. llvm . LLVMFastCallConv ) ;
950
962
ret res( args_res. _0 ,
951
963
args_res. _0 . build . Load ( outptr) ) ;
952
964
}
@@ -1246,7 +1258,7 @@ fn collect_item(&@trans_ctxt cx, @ast.item i) -> @trans_ctxt {
1246
1258
args += T_explicit_args ;
1247
1259
1248
1260
let str s = cx. names . next ( "_rust_fn" ) + "." + name;
1249
- let ValueRef llfn = decl_cdecl_fn ( cx. llmod , s, args, T_void ( ) ) ;
1261
+ let ValueRef llfn = decl_fastcall_fn ( cx. llmod , s, args, T_void ( ) ) ;
1250
1262
cx. fn_ids . insert ( fid, llfn) ;
1251
1263
}
1252
1264
0 commit comments