[PATCH] D43448: [LLVM-C] Redo unnamed_address attribute bindings

Robert Widmann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 13 23:50:10 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL327479: [LLVM-C] Redo unnamed_address attribute bindings (authored by CodaFi, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43448?vs=134849&id=138304#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43448

Files:
  llvm/trunk/include/llvm-c/Core.h
  llvm/trunk/lib/IR/Core.cpp
  llvm/trunk/test/Bindings/llvm-c/echo.ll
  llvm/trunk/tools/llvm-c-test/echo.cpp


Index: llvm/trunk/test/Bindings/llvm-c/echo.ll
===================================================================
--- llvm/trunk/test/Bindings/llvm-c/echo.ll
+++ llvm/trunk/test/Bindings/llvm-c/echo.ll
@@ -14,6 +14,7 @@
 @tl = thread_local global { i64, %S* } { i64 1, %S* @cst }
 @arr = linkonce_odr global [5 x i8] [ i8 2, i8 3, i8 5, i8 7, i8 11 ]
 @str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
+ at locStr = private local_unnamed_addr constant [13 x i8] c"hello world\0A\00"
 @hidden = hidden global i32 7
 @protected = protected global i32 23
 @section = global i32 27, section ".custom"
Index: llvm/trunk/lib/IR/Core.cpp
===================================================================
--- llvm/trunk/lib/IR/Core.cpp
+++ llvm/trunk/lib/IR/Core.cpp
@@ -1607,6 +1607,30 @@
       static_cast<GlobalValue::DLLStorageClassTypes>(Class));
 }
 
+LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global) {
+  switch (unwrap<GlobalValue>(Global)->getUnnamedAddr()) {
+  case GlobalVariable::UnnamedAddr::None:
+    return LLVMNoUnnamedAddr;
+  case GlobalVariable::UnnamedAddr::Local:
+    return LLVMLocalUnnamedAddr;
+  case GlobalVariable::UnnamedAddr::Global:
+    return LLVMGlobalUnnamedAddr;
+  }
+}
+
+void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr) {
+  GlobalValue *GV = unwrap<GlobalValue>(Global);
+
+  switch (UnnamedAddr) {
+  case LLVMNoUnnamedAddr:
+    return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::None);
+  case LLVMLocalUnnamedAddr:
+    return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Local);
+  case LLVMGlobalUnnamedAddr:
+    return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Global);
+  }
+}
+
 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global) {
   return unwrap<GlobalValue>(Global)->hasGlobalUnnamedAddr();
 }
Index: llvm/trunk/tools/llvm-c-test/echo.cpp
===================================================================
--- llvm/trunk/tools/llvm-c-test/echo.cpp
+++ llvm/trunk/tools/llvm-c-test/echo.cpp
@@ -864,7 +864,7 @@
     LLVMSetLinkage(G, LLVMGetLinkage(Cur));
     LLVMSetSection(G, LLVMGetSection(Cur));
     LLVMSetVisibility(G, LLVMGetVisibility(Cur));
-    LLVMSetUnnamedAddr(G, LLVMHasUnnamedAddr(Cur));
+    LLVMSetUnnamedAddress(G, LLVMGetUnnamedAddress(Cur));
     LLVMSetAlignment(G, LLVMGetAlignment(Cur));
 
     Next = LLVMGetNextGlobal(Cur);
Index: llvm/trunk/include/llvm-c/Core.h
===================================================================
--- llvm/trunk/include/llvm-c/Core.h
+++ llvm/trunk/include/llvm-c/Core.h
@@ -187,6 +187,12 @@
 } LLVMVisibility;
 
 typedef enum {
+  LLVMNoUnnamedAddr,    /**< Address of the GV is significant. */
+  LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
+  LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
+} LLVMUnnamedAddr;
+
+typedef enum {
   LLVMDefaultStorageClass   = 0,
   LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
   LLVMDLLExportStorageClass = 2  /**< Function to be accessible from DLL. */
@@ -1844,7 +1850,12 @@
 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
+LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
+void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
+
+/** Deprecated: Use LLVMGetUnnamedAddress instead. */
 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
+/** Deprecated: Use LLVMSetUnnamedAddress instead. */
 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
 
 /**


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43448.138304.patch
Type: text/x-patch
Size: 3670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180314/b417d9b6/attachment.bin>


More information about the llvm-commits mailing list