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

Itay Bookstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 03:37:19 PDT 2020


nextsilicon-itay-bookstein updated this revision to Diff 270093.
nextsilicon-itay-bookstein added a comment.
Herald added a subscriber: hiraditya.

Changed the fix to push the ThreadLocalMode copying from derived class GlobalVariable down to base class GlobalValue.
Added an appropriate test under llvm/test/Linker.


Repository:
  rG LLVM Github Monorepo

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,7 @@
+; RUN: llvm-link %s %p/Inputs/alias-threadlocal-defs.ll -S -o - | FileCheck %s
+; PR81605
+
+; 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.270093.patch
Type: text/x-patch
Size: 1593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200611/841e0c9f/attachment.bin>


More information about the llvm-commits mailing list