llvm.org GIT mirror llvm / df7c2a2
[LLVM-C] Redo unnamed_address attribute bindings Summary: The old bindings should have used an enum instead of a boolean. This deprecates LLVMHasUnnamedAddr and LLVMSetUnnamedAddr , replacing them with LLVMGetUnnamedAddress and LLVMSetUnnamedAddress respectively that do. Though it is unlikely LLVM will gain more supported global value linker hints, the new API can scale to accommodate this. Reviewers: deadalnix, whitequark Reviewed By: whitequark Subscribers: llvm-commits, harlanhaskins Differential Revision: https://reviews.llvm.org/D43448 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327479 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 2 years ago
4 changed file(s) with 37 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
184184 LLVMHiddenVisibility, /**< The GV is hidden */
185185 LLVMProtectedVisibility /**< The GV is protected */
186186 } LLVMVisibility;
187
188 typedef enum {
189 LLVMNoUnnamedAddr, /**< Address of the GV is significant. */
190 LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
191 LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
192 } LLVMUnnamedAddr;
187193
188194 typedef enum {
189195 LLVMDefaultStorageClass = 0,
18431849 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
18441850 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
18451851 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
1852 LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
1853 void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
1854
1855 /** Deprecated: Use LLVMGetUnnamedAddress instead. */
18461856 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1857 /** Deprecated: Use LLVMSetUnnamedAddress instead. */
18471858 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
18481859
18491860 /**
16061606 static_cast(Class));
16071607 }
16081608
1609 LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global) {
1610 switch (unwrap(Global)->getUnnamedAddr()) {
1611 case GlobalVariable::UnnamedAddr::None:
1612 return LLVMNoUnnamedAddr;
1613 case GlobalVariable::UnnamedAddr::Local:
1614 return LLVMLocalUnnamedAddr;
1615 case GlobalVariable::UnnamedAddr::Global:
1616 return LLVMGlobalUnnamedAddr;
1617 }
1618 }
1619
1620 void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr) {
1621 GlobalValue *GV = unwrap(Global);
1622
1623 switch (UnnamedAddr) {
1624 case LLVMNoUnnamedAddr:
1625 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::None);
1626 case LLVMLocalUnnamedAddr:
1627 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Local);
1628 case LLVMGlobalUnnamedAddr:
1629 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Global);
1630 }
1631 }
1632
16091633 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global) {
16101634 return unwrap(Global)->hasGlobalUnnamedAddr();
16111635 }
1313 @tl = thread_local global { i64, %S* } { i64 1, %S* @cst }
1414 @arr = linkonce_odr global [5 x i8] [ i8 2, i8 3, i8 5, i8 7, i8 11 ]
1515 @str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
16 @locStr = private local_unnamed_addr constant [13 x i8] c"hello world\0A\00"
1617 @hidden = hidden global i32 7
1718 @protected = protected global i32 23
1819 @section = global i32 27, section ".custom"
863863 LLVMSetLinkage(G, LLVMGetLinkage(Cur));
864864 LLVMSetSection(G, LLVMGetSection(Cur));
865865 LLVMSetVisibility(G, LLVMGetVisibility(Cur));
866 LLVMSetUnnamedAddr(G, LLVMHasUnnamedAddr(Cur));
866 LLVMSetUnnamedAddress(G, LLVMGetUnnamedAddress(Cur));
867867 LLVMSetAlignment(G, LLVMGetAlignment(Cur));
868868
869869 Next = LLVMGetNextGlobal(Cur);