[PATCH] D81605: [IR] Add missing GlobalAlias copying of ThreadLocalMode attribute

Itay Bookstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 02:08:09 PDT 2020


nextsilicon-itay-bookstein updated this revision to Diff 270330.
nextsilicon-itay-bookstein added a comment.

Updated title and description.
Added description for test, created PR in bugzilla, corrected PR reference to point at it.

While creating this PR, I noted that this looks eerily similar to https://bugs.llvm.org/show_bug.cgi?id=33846, but I am yet to check whether this is a true duplicate or not.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81605/new/

https://reviews.llvm.org/D81605

Files:
  llvm/lib/IR/Globals.cpp
  llvm/test/Linker/Inputs/alias-threadlocal-defs.ll
  llvm/test/Linker/alias-threadlocal.ll


Index: llvm/test/Linker/alias-threadlocal.ll
===================================================================
--- /dev/null
+++ llvm/test/Linker/alias-threadlocal.ll
@@ -0,0 +1,9 @@
+; RUN: llvm-link %s %p/Inputs/alias-threadlocal-defs.ll -S -o - | FileCheck %s
+
+; PR46297
+; Verify that linking GlobalAliases preserves the thread_local attribute
+
+; CHECK: @tlsvar1 = thread_local global i32 0, align 4
+; CHECK: @tlsvar2 = hidden thread_local alias i32, i32* @tlsvar1
+
+ at tlsvar2 = external thread_local global i32, align 4
Index: llvm/test/Linker/Inputs/alias-threadlocal-defs.ll
===================================================================
--- /dev/null
+++ llvm/test/Linker/Inputs/alias-threadlocal-defs.ll
@@ -0,0 +1,2 @@
+ at tlsvar1 = thread_local global i32 0, align 4
+ at tlsvar2 = hidden thread_local alias i32, i32* @tlsvar1
Index: llvm/lib/IR/Globals.cpp
===================================================================
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -65,6 +65,7 @@
 void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
   setVisibility(Src->getVisibility());
   setUnnamedAddr(Src->getUnnamedAddr());
+  setThreadLocalMode(Src->getThreadLocalMode());
   setDLLStorageClass(Src->getDLLStorageClass());
   setDSOLocal(Src->isDSOLocal());
   setPartition(Src->getPartition());
@@ -419,7 +420,6 @@
 /// from the GlobalVariable Src to this one.
 void GlobalVariable::copyAttributesFrom(const GlobalVariable *Src) {
   GlobalObject::copyAttributesFrom(Src);
-  setThreadLocalMode(Src->getThreadLocalMode());
   setExternallyInitialized(Src->isExternallyInitialized());
   setAttributes(Src->getAttributes());
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81605.270330.patch
Type: text/x-patch
Size: 1669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200612/51812bb9/attachment.bin>


More information about the llvm-commits mailing list