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

Amanieu d'Antras via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 28 15:44:34 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad9ce8142dd5: [ConstantMerge] Don't merge thread_local constants with non-thread_local… (authored by Amanieu).

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
@@ -95,6 +95,8 @@
   // Only process constants with initializers in the default address space.
   return !GV->isConstant() || !GV->hasDefinitiveInitializer() ||
          GV->getType()->getAddressSpace() != 0 || GV->hasSection() ||
+         // Don't touch thread-local variables.
+         GV->isThreadLocal() ||
          // Don't touch values marked with attribute(used).
          UsedGlobals.count(GV);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100322.341335.patch
Type: text/x-patch
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210428/9578044e/attachment.bin>


More information about the llvm-commits mailing list