mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 12:13:43 +00:00
rustllvm: Add a GetOrInsertFunction wrapper
Fixes issue #1161 Test-case-by: Brian Anderson <banderson@mozilla.com> Signed-off-by: Haitao Li <lihaitao@gmail.com>
This commit is contained in:
parent
453168d917
commit
b8dd148444
@ -448,6 +448,8 @@ native "cdecl" mod llvm = "rustllvm" {
|
||||
fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
|
||||
fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
|
||||
fn LLVMDeleteFunction(Fn: ValueRef);
|
||||
fn LLVMGetOrInsertFunction(M: ModuleRef, Name: sbuf, FunctionTy: TypeRef)
|
||||
-> ValueRef;
|
||||
fn LLVMGetIntrinsicID(Fn: ValueRef) -> uint;
|
||||
fn LLVMGetFunctionCallConv(Fn: ValueRef) -> uint;
|
||||
fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: uint);
|
||||
|
@ -301,7 +301,8 @@ fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timeval,
|
||||
|
||||
fn decl_fn(llmod: ModuleRef, name: str, cc: uint, llty: TypeRef) -> ValueRef {
|
||||
let llfn: ValueRef =
|
||||
str::as_buf(name, {|buf| llvm::LLVMAddFunction(llmod, buf, llty) });
|
||||
str::as_buf(name, {|buf|
|
||||
llvm::LLVMGetOrInsertFunction(llmod, buf, llty) });
|
||||
llvm::LLVMSetFunctionCallConv(llfn, cc);
|
||||
ret llfn;
|
||||
}
|
||||
|
@ -141,3 +141,9 @@ extern "C" void LLVMRustEnableSegmentedStacks() {
|
||||
EnableSegmentedStacks = true;
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M,
|
||||
const char* Name,
|
||||
LLVMTypeRef FunctionTy) {
|
||||
return wrap(unwrap(M)->getOrInsertFunction(Name,
|
||||
unwrap<FunctionType>(FunctionTy)));
|
||||
}
|
||||
|
@ -364,6 +364,7 @@ LLVMGetNextParam
|
||||
LLVMGetNextUse
|
||||
LLVMGetNumOperands
|
||||
LLVMGetOperand
|
||||
LLVMGetOrInsertFunction
|
||||
LLVMGetParam
|
||||
LLVMGetParamParent
|
||||
LLVMGetParamTypes
|
||||
|
12
src/test/run-pass/native-dupe.rs
Normal file
12
src/test/run-pass/native-dupe.rs
Normal file
@ -0,0 +1,12 @@
|
||||
native "cdecl" mod rustrt1 = "rustrt" {
|
||||
fn pin_task();
|
||||
}
|
||||
|
||||
native "cdecl" mod rustrt2 = "rustrt" {
|
||||
fn pin_task();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
rustrt1::pin_task();
|
||||
rustrt2::pin_task();
|
||||
}
|
Loading…
Reference in New Issue
Block a user