Skip to content

Commit deb097a

Browse files
committed
Implement LLVMGetOrInsertGlobal wrapper
1 parent cb45703 commit deb097a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/librustc_llvm/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ extern {
912912
AddressSpace: c_uint)
913913
-> ValueRef;
914914
pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
915+
pub fn LLVMGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
915916
pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
916917
pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
917918
pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;

src/rustllvm/RustWrapper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ extern "C" LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M,
8989
unwrap<FunctionType>(FunctionTy)));
9090
}
9191

92+
extern "C" LLVMValueRef LLVMGetOrInsertGlobal(LLVMModuleRef M,
93+
const char* Name,
94+
LLVMTypeRef Ty) {
95+
return wrap(unwrap(M)->getOrInsertGlobal(Name, unwrap(Ty)));
96+
}
97+
9298
extern "C" LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C) {
9399
return wrap(Type::getMetadataTy(*unwrap(C)));
94100
}

0 commit comments

Comments
 (0)