From 8255573835970e7130ba93271972172fb335f2ec Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 19 Aug 2009 18:20:44 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79441 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/ConstantMerge.cpp | 2 +- lib/Transforms/IPO/GlobalOpt.cpp | 6 +++--- lib/Transforms/IPO/InlineSimple.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/Transforms') diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 237e6db..c1a1045 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -78,7 +78,7 @@ bool ConstantMerge::runOnModule(Module &M) { } // 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. diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 6ec2012..f218c12 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1913,7 +1913,7 @@ GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) { 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(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 @@ static Constant *ComputeLoadResult(Constant *P, // Access it. if (GlobalVariable *GV = dyn_cast(P)) { - if (GV->hasInitializer()) + if (GV->hasDefinitiveInitializer()) return GV->getInitializer(); return 0; } @@ -2149,7 +2149,7 @@ static Constant *ComputeLoadResult(Constant *P, if (CE->getOpcode() == Instruction::GetElementPtr && isa(CE->getOperand(0))) { GlobalVariable *GV = cast(CE->getOperand(0)); - if (GV->hasInitializer()) + if (GV->hasDefinitiveInitializer()) return ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE, Context); } diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index e107a00..b7765dc 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -78,7 +78,7 @@ bool SimpleInliner::doInitialization(CallGraph &CG) { return false; // Don't crash on invalid code - if (!GV->hasInitializer()) + if (!GV->hasDefinitiveInitializer()) return false; const ConstantArray *InitList = dyn_cast(GV->getInitializer()); -- cgit v1.1