Skip to content

Commit 640d167

Browse files
committed
Switch module-internal calls (i.e. all user code) to fastcall. Still returning via explicit outptr. Activate glue works by accident.
1 parent a7af861 commit 640d167

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/comp/middle/trans.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,25 @@ fn C_tydesc(TypeRef t) -> ValueRef {
341341
C_null(T_opaque()))); // is_stateful
342342
}
343343

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 {
346346
let TypeRef llty = T_fn(inputs, output);
347347
let ValueRef llfn =
348348
llvm.LLVMAddFunction(llmod, _str.buf(name), llty);
349-
llvm.LLVMSetFunctionCallConv(llfn, lib.llvm.LLVMCCallConv);
349+
llvm.LLVMSetFunctionCallConv(llfn, cc);
350350
ret llfn;
351351
}
352352

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+
353363
fn decl_glue(ModuleRef llmod, str s) -> ValueRef {
354364
ret decl_cdecl_fn(llmod, s, vec(T_taskptr()), T_void());
355365
}
@@ -947,6 +957,8 @@ impure fn trans_expr(@block_ctxt cx, &ast.expr e) -> result {
947957
cx.fcx.lltaskptr);
948958
llargs += args_res._1;
949959
auto call_val = args_res._0.build.Call(f_res._0.val, llargs);
960+
llvm.LLVMSetInstructionCallConv(call_val,
961+
lib.llvm.LLVMFastCallConv);
950962
ret res(args_res._0,
951963
args_res._0.build.Load(outptr));
952964
}
@@ -1246,7 +1258,7 @@ fn collect_item(&@trans_ctxt cx, @ast.item i) -> @trans_ctxt {
12461258
args += T_explicit_args;
12471259

12481260
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());
12501262
cx.fn_ids.insert(fid, llfn);
12511263
}
12521264

0 commit comments

Comments
 (0)