summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-27 04:50:03 +0000
committerChris Lattner <sabre@nondot.org>2005-09-27 04:50:03 +0000
commit29b2780c8afef53cc2a71ac64a77e57b645a7ca3 (patch)
tree75f115e029336c791743d332bdb160b5312ad2b6 /llvm/lib
parent65a3a0918f9560fbe7b2019963df1617d0784661 (diff)
downloadbcm5719-llvm-29b2780c8afef53cc2a71ac64a77e57b645a7ca3.tar.gz
bcm5719-llvm-29b2780c8afef53cc2a71ac64a77e57b645a7ca3.zip
Fix a bug where we would evaluate stores into linkonce objects which could be
potentially replaced at link-time. llvm-svn: 23463
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 6170bfcac64..a3cd8d4f15d 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1239,13 +1239,18 @@ static Constant *getVal(std::map<Value*, Constant*> &ComputedValues,
/// we punt. We basically just support direct accesses to globals and GEP's of
/// globals. This should be kept up to date with CommitValueTo.
static bool isSimpleEnoughPointerToCommit(Constant *C) {
- if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
+ if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
+ if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
+ return false; // do not allow weak/linkonce linkage.
return !GV->isExternal(); // reject external globals.
+ }
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
// Handle a constantexpr gep.
if (CE->getOpcode() == Instruction::GetElementPtr &&
isa<GlobalVariable>(CE->getOperand(0))) {
GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
+ if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
+ return false; // do not allow weak/linkonce linkage.
return GV->hasInitializer() &&
ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE);
}
OpenPOWER on IntegriCloud