[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:11:09 PDT 2021
Amanieu created this revision.
Herald added a subscriber: hiraditya.
Amanieu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Fixes PR49932
Repository:
rG LLVM Github Monorepo
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.336880.patch
Type: text/x-patch
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210412/a07c2ce4/attachment.bin>
More information about the llvm-commits
mailing list