[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 13:43:44 PDT 2021
Amanieu updated this revision to Diff 341307.
Amanieu added a comment.
Don't merge thread-local constants
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.341307.patch
Type: text/x-patch
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210428/06408132/attachment.bin>
More information about the llvm-commits
mailing list