aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/ConstantMerge.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-01-11 22:06:46 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-01-11 22:06:46 +0000
commitb31c627be151d3720e1ab86ae3d6bf0f6b1f400b (patch)
treef847cb26defbaf3780472a3377e15c1dd7c24f8e /llvm/lib/Transforms/IPO/ConstantMerge.cpp
parent9ac4562bea718636a1831158aa3344ba47017706 (diff)
downloadllvm-b31c627be151d3720e1ab86ae3d6bf0f6b1f400b.zip
llvm-b31c627be151d3720e1ab86ae3d6bf0f6b1f400b.tar.gz
llvm-b31c627be151d3720e1ab86ae3d6bf0f6b1f400b.tar.bz2
Re-fix the issue Bill fixed in r147899 in a slightly different way, which doesn't abuse the semantics of linker_private. We don't really want to merge any string constant with a weak_odr global.
llvm-svn: 147971
Diffstat (limited to 'llvm/lib/Transforms/IPO/ConstantMerge.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/ConstantMerge.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/ConstantMerge.cpp b/llvm/lib/Transforms/IPO/ConstantMerge.cpp
index 268a281..d8fae8a 100644
--- a/llvm/lib/Transforms/IPO/ConstantMerge.cpp
+++ b/llvm/lib/Transforms/IPO/ConstantMerge.cpp
@@ -140,8 +140,11 @@ bool ConstantMerge::runOnModule(Module &M) {
UsedGlobals.count(GV))
continue;
- // Ignore any constants which may be removed by the linker.
- if (GV->mayBeRemovedByLinker())
+ // This transformation is legal for weak ODR globals in the sense it
+ // doesn't change semantics, but we really don't want to perform it
+ // anyway; it's likely to pessimize code generation, and some tools
+ // (like the Darwin linker in cases involving CFString) don't expect it.
+ if (GV->isWeakForLinker())
continue;
Constant *Init = GV->getInitializer();
@@ -172,9 +175,8 @@ bool ConstantMerge::runOnModule(Module &M) {
UsedGlobals.count(GV))
continue;
- // We can only replace constants with local linkage and which aren't
- // removed by the linker.
- if (!GV->hasLocalLinkage() || GV->mayBeRemovedByLinker())
+ // We can only replace constant with local linkage.
+ if (!GV->hasLocalLinkage())
continue;
Constant *Init = GV->getInitializer();