Skip to content

Commit 317248f

Browse files
committed
expose the ability to set unnamed_addr
1 parent 05735a9 commit 317248f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/librustc/lib/llvm.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,10 @@ pub mod llvm {
19031903
Constraints: *c_char, SideEffects: Bool,
19041904
AlignStack: Bool, Dialect: c_uint)
19051905
-> ValueRef;
1906+
1907+
#[fast_ffi]
1908+
pub unsafe fn LLVMSetUnnamedAddr(Global: ValueRef, value: Bool);
1909+
19061910
}
19071911
}
19081912

@@ -1911,27 +1915,37 @@ pub fn SetInstructionCallConv(Instr: ValueRef, CC: CallConv) {
19111915
llvm::LLVMSetInstructionCallConv(Instr, CC as c_uint);
19121916
}
19131917
}
1918+
19141919
pub fn SetFunctionCallConv(Fn: ValueRef, CC: CallConv) {
19151920
unsafe {
19161921
llvm::LLVMSetFunctionCallConv(Fn, CC as c_uint);
19171922
}
19181923
}
1924+
19191925
pub fn SetLinkage(Global: ValueRef, Link: Linkage) {
19201926
unsafe {
19211927
llvm::LLVMSetLinkage(Global, Link as c_uint);
19221928
}
19231929
}
19241930

1931+
pub fn set_unnamed_addr(global: ValueRef, value: bool) {
1932+
unsafe {
1933+
llvm::LLVMSetUnnamedAddr(global, value as Bool)
1934+
}
1935+
}
1936+
19251937
pub fn ConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
19261938
unsafe {
19271939
llvm::LLVMConstICmp(Pred as c_ushort, V1, V2)
19281940
}
19291941
}
1942+
19301943
pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
19311944
unsafe {
19321945
llvm::LLVMConstFCmp(Pred as c_ushort, V1, V2)
19331946
}
19341947
}
1948+
19351949
/* Memory-managed object interface to type handles. */
19361950

19371951
pub struct TypeNames {

src/rustllvm/RustWrapper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,3 +603,8 @@ extern "C" LLVMValueRef LLVMInlineAsm(LLVMTypeRef Ty,
603603
Constraints, HasSideEffects,
604604
IsAlignStack, (InlineAsm::AsmDialect) Dialect));
605605
}
606+
607+
extern "C" void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool value) {
608+
GlobalValue *GV = unwrap<GlobalValue>(Global);
609+
GV->setUnnamedAddr(value);
610+
}

0 commit comments

Comments
 (0)