Author: Amanieu d'Antras Date: 2021-06-23T10:42:50-04:00 New Revision: 0eae129baeb589b905223a1e9c8115937bc541b7
URL: https://github.com/llvm/llvm-project/commit/0eae129baeb589b905223a1e9c8115937bc541b7 DIFF: https://github.com/llvm/llvm-project/commit/0eae129baeb589b905223a1e9c8115937bc541b7.diff LOG: [ConstantMerge] Don't merge thread_local constants with non-thread_local constants Fixes PR49932 Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D100322 (cherry picked from commit ad9ce8142dd5b90f725ad362feb054d52a35aa1f) Added: Modified: llvm/lib/Transforms/IPO/ConstantMerge.cpp llvm/test/Transforms/ConstantMerge/dont-merge.ll Removed: ################################################################################ diff --git a/llvm/lib/Transforms/IPO/ConstantMerge.cpp b/llvm/lib/Transforms/IPO/ConstantMerge.cpp index 67f1438b9b6ac..8e81f4bad4af2 100644 --- a/llvm/lib/Transforms/IPO/ConstantMerge.cpp +++ b/llvm/lib/Transforms/IPO/ConstantMerge.cpp @@ -95,6 +95,8 @@ isUnmergeableGlobal(GlobalVariable *GV, // 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); } diff --git a/llvm/test/Transforms/ConstantMerge/dont-merge.ll b/llvm/test/Transforms/ConstantMerge/dont-merge.ll index 21e390785df56..b0dab923d2cb2 100644 --- a/llvm/test/Transforms/ConstantMerge/dont-merge.ll +++ b/llvm/test/Transforms/ConstantMerge/dont-merge.ll @@ -80,3 +80,15 @@ define void @test4(i32** %P1, i32** %P2, i32** %P3, i32** %P4, i32** %P5, i32** store i32* @T4D2, i32** %P8 ret void } + +; CHECK: @T5tls +; CHECK: @T5ua + +@T5tls = private thread_local constant i32 555 +@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 +} _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits