[PATCH] D100322: [ConstantMerge] Don't merge thread_local constants

Amanieu d'Antras via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 12 10:50:34 PDT 2021


Amanieu updated this revision to Diff 336902.
Amanieu added a comment.

Merge thread_locals only if they use the same TLS mode


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100322

Files:
  llvm/lib/Transforms/IPO/ConstantMerge.cpp
  llvm/test/Transforms/ConstantMerge/dont-merge.ll


Index: llvm/test/Transforms/ConstantMerge/dont-merge.ll
===================================================================
--- llvm/test/Transforms/ConstantMerge/dont-merge.ll
+++ llvm/test/Transforms/ConstantMerge/dont-merge.ll
@@ -80,3 +80,15 @@
         store i32* @T4D2, i32** %P8
         ret void
 }
+
+; CHECK: @T5tls
+; CHECK: @T5ua
+
+ at T5tls = private thread_local constant i32 555
+ at T5ua = private unnamed_addr constant i32 555
+
+define void @test5(i32** %P1, i32** %P2) {
+        store i32* @T5tls, i32** %P1
+        store i32* @T5ua, i32** %P2
+        ret void
+}
Index: llvm/lib/Transforms/IPO/ConstantMerge.cpp
===================================================================
--- llvm/lib/Transforms/IPO/ConstantMerge.cpp
+++ llvm/lib/Transforms/IPO/ConstantMerge.cpp
@@ -105,6 +105,8 @@
     return CanMerge::No;
   if (hasMetadataOtherThanDebugLoc(Old))
     return CanMerge::No;
+  if (Old->getThreadLocalMode() != New->getThreadLocalMode())
+    return CanMerge::No;
   assert(!hasMetadataOtherThanDebugLoc(New));
   if (!Old->hasGlobalUnnamedAddr())
     New->setUnnamedAddr(GlobalValue::UnnamedAddr::None);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100322.336902.patch
Type: text/x-patch
Size: 1135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210412/1f05a224/attachment.bin>


More information about the llvm-commits mailing list