[llvm-commits] [llvm] r79441 - in /llvm/trunk/lib: Analysis/IPA/Andersens.cpp Analysis/ScalarEvolution.cpp Analysis/ValueTracking.cpp Transforms/IPO/ConstantMerge.cpp Transforms/IPO/GlobalOpt.cpp Transforms/IPO/InlineSimple.cpp
Dan Gohman
gohman at apple.com
Wed Aug 19 11:20:44 PDT 2009
Author: djg
Date: Wed Aug 19 13:20:44 2009
New Revision: 79441
URL: http://llvm.org/viewvc/llvm-project?rev=79441&view=rev
Log:
Use hasDefinitiveInitializer() instead of testing the same thing
by hand, and fix a few places that were using hasInitializer() that
appear to depend on the initializer value.
Modified:
llvm/trunk/lib/Analysis/IPA/Andersens.cpp
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
Modified: llvm/trunk/lib/Analysis/IPA/Andersens.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/Andersens.cpp?rev=79441&r1=79440&r2=79441&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/IPA/Andersens.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/Andersens.cpp Wed Aug 19 13:20:44 2009
@@ -1061,7 +1061,7 @@
Constraints.push_back(Constraint(Constraint::AddressOf, getNodeValue(*I),
ObjectIndex));
- if (I->hasInitializer()) {
+ if (I->hasDefinitiveInitializer()) {
AddGlobalInitializerConstraints(ObjectIndex, I->getInitializer());
} else {
// If it doesn't have an initializer (i.e. it's defined in another
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=79441&r1=79440&r2=79441&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Aug 19 13:20:44 2009
@@ -3638,7 +3638,7 @@
// Make sure that it is really a constant global we are gepping, with an
// initializer, and make sure the first IDX is really 0.
GlobalVariable *GV = dyn_cast<GlobalVariable>(GEP->getOperand(0));
- if (!GV || !GV->isConstant() || !GV->hasInitializer() ||
+ if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer() ||
GEP->getNumOperands() < 3 || !isa<Constant>(GEP->getOperand(1)) ||
!cast<Constant>(GEP->getOperand(1))->isNullValue())
return getCouldNotCompute();
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=79441&r1=79440&r2=79441&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Wed Aug 19 13:20:44 2009
@@ -1061,8 +1061,7 @@
// variable that is a constant and is initialized. The referenced constant
// initializer is the array that we'll use for optimization.
GlobalVariable* GV = dyn_cast<GlobalVariable>(V);
- if (!GV || !GV->isConstant() || !GV->hasInitializer() ||
- GV->mayBeOverridden())
+ if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer())
return false;
Constant *GlobalInit = GV->getInitializer();
Modified: llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp?rev=79441&r1=79440&r2=79441&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp Wed Aug 19 13:20:44 2009
@@ -78,7 +78,7 @@
}
// Only process constants with initializers.
- if (GV->isConstant() && GV->hasInitializer()) {
+ if (GV->isConstant() && GV->hasDefinitiveInitializer()) {
Constant *Init = GV->getInitializer();
// Check to see if the initializer is already known.
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=79441&r1=79440&r2=79441&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Wed Aug 19 13:20:44 2009
@@ -1913,7 +1913,7 @@
return 0;
// Verify that the initializer is simple enough for us to handle.
- if (!I->hasInitializer()) return 0;
+ if (!I->hasDefinitiveInitializer()) 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)
@@ -2139,7 +2139,7 @@
// Access it.
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(P)) {
- if (GV->hasInitializer())
+ if (GV->hasDefinitiveInitializer())
return GV->getInitializer();
return 0;
}
@@ -2149,7 +2149,7 @@
if (CE->getOpcode() == Instruction::GetElementPtr &&
isa<GlobalVariable>(CE->getOperand(0))) {
GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
- if (GV->hasInitializer())
+ if (GV->hasDefinitiveInitializer())
return ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE,
Context);
}
Modified: llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=79441&r1=79440&r2=79441&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp Wed Aug 19 13:20:44 2009
@@ -78,7 +78,7 @@
return false;
// Don't crash on invalid code
- if (!GV->hasInitializer())
+ if (!GV->hasDefinitiveInitializer())
return false;
const ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());
More information about the llvm-commits
mailing list