Switch module-internal calls (i.e. all user code) to fastcall. Still returning via explicit outptr. Activate glue works by accident.

This commit is contained in:
Graydon Hoare 2010-11-14 12:28:07 -08:00
parent a7af86155d
commit 640d167037

View File

@ -341,15 +341,25 @@ fn C_tydesc(TypeRef t) -> ValueRef {
C_null(T_opaque()))); // is_stateful
}
fn decl_cdecl_fn(ModuleRef llmod, str name,
vec[TypeRef] inputs, TypeRef output) -> ValueRef {
fn decl_fn(ModuleRef llmod, str name,
uint cc, vec[TypeRef] inputs, TypeRef output) -> ValueRef {
let TypeRef llty = T_fn(inputs, output);
let ValueRef llfn =
llvm.LLVMAddFunction(llmod, _str.buf(name), llty);
llvm.LLVMSetFunctionCallConv(llfn, lib.llvm.LLVMCCallConv);
llvm.LLVMSetFunctionCallConv(llfn, cc);
ret llfn;
}
fn decl_cdecl_fn(ModuleRef llmod, str name,
vec[TypeRef] inputs, TypeRef output) -> ValueRef {
ret decl_fn(llmod, name, lib.llvm.LLVMCCallConv, inputs, output);
}
fn decl_fastcall_fn(ModuleRef llmod, str name,
vec[TypeRef] inputs, TypeRef output) -> ValueRef {
ret decl_fn(llmod, name, lib.llvm.LLVMFastCallConv, inputs, output);
}
fn decl_glue(ModuleRef llmod, str s) -> ValueRef {
ret decl_cdecl_fn(llmod, s, vec(T_taskptr()), T_void());
}
@ -947,6 +957,8 @@ impure fn trans_expr(@block_ctxt cx, &ast.expr e) -> result {
cx.fcx.lltaskptr);
llargs += args_res._1;
auto call_val = args_res._0.build.Call(f_res._0.val, llargs);
llvm.LLVMSetInstructionCallConv(call_val,
lib.llvm.LLVMFastCallConv);
ret res(args_res._0,
args_res._0.build.Load(outptr));
}
@ -1246,7 +1258,7 @@ fn collect_item(&@trans_ctxt cx, @ast.item i) -> @trans_ctxt {
args += T_explicit_args;
let str s = cx.names.next("_rust_fn") + "." + name;
let ValueRef llfn = decl_cdecl_fn(cx.llmod, s, args, T_void());
let ValueRef llfn = decl_fastcall_fn(cx.llmod, s, args, T_void());
cx.fn_ids.insert(fid, llfn);
}