summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2010-10-19 16:47:23 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2010-10-19 16:47:23 +0000
commit2072db24ed41a2c3d23092a926b5d003fb868870 (patch)
tree5d7b2fe2199c8eaeeb2ec0abfd1d3a1327ce3e0f /llvm/lib/Transforms
parent245916496b708c5bcd892666553f4d037204753c (diff)
downloadbcm5719-llvm-2072db24ed41a2c3d23092a926b5d003fb868870.tar.gz
bcm5719-llvm-2072db24ed41a2c3d23092a926b5d003fb868870.zip
GlobalOpt: EvaluateFunction() must not evaluate stores to weak_odr globals.
Fixes PR8389. llvm-svn: 116812
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index c1a175fce74..213f9caf817 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1944,8 +1944,9 @@ GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) {
FTy->isVarArg() || FTy->getNumParams() != 0)
return 0;
- // Verify that the initializer is simple enough for us to handle.
- if (!I->hasDefinitiveInitializer()) return 0;
+ // Verify that the initializer is simple enough for us to handle. We are
+ // only allowed to optimize the initializer if it is unique.
+ if (!I->hasUniqueInitializer()) return 0;
ConstantArray *CA = dyn_cast<ConstantArray>(I->getInitializer());
if (!CA) return 0;
for (User::op_iterator i = CA->op_begin(), e = CA->op_end(); i != e; ++i)
@@ -2062,9 +2063,9 @@ static bool isSimpleEnoughPointerToCommit(Constant *C) {
return false;
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
- // Do not allow weak/linkonce/dllimport/dllexport linkage or
+ // Do not allow weak/*_odr/linkonce/dllimport/dllexport linkage or
// external globals.
- return GV->hasDefinitiveInitializer();
+ return GV->hasUniqueInitializer();
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
// Handle a constantexpr gep.
@@ -2072,9 +2073,9 @@ static bool isSimpleEnoughPointerToCommit(Constant *C) {
isa<GlobalVariable>(CE->getOperand(0)) &&
cast<GEPOperator>(CE)->isInBounds()) {
GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
- // Do not allow weak/linkonce/dllimport/dllexport linkage or
+ // Do not allow weak/*_odr/linkonce/dllimport/dllexport linkage or
// external globals.
- if (!GV->hasDefinitiveInitializer())
+ if (!GV->hasUniqueInitializer())
return false;
// The first index must be zero.
OpenPOWER on IntegriCloud