aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/IPO/GlobalOpt.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2012-02-12 00:47:24 +0000
committerNick Lewycky <nicholas@mxc.ca>2012-02-12 00:47:24 +0000
commit8e4ba6b954d58bd60b342770dfca62de4cf4eb6e (patch)
tree5856edaa961c4581fc3a62fea938ef18676db465 /lib/Transforms/IPO/GlobalOpt.cpp
parent1f2fa99b2ab6e29270d7d72e20153d933469287d (diff)
downloadexternal_llvm-8e4ba6b954d58bd60b342770dfca62de4cf4eb6e.zip
external_llvm-8e4ba6b954d58bd60b342770dfca62de4cf4eb6e.tar.gz
external_llvm-8e4ba6b954d58bd60b342770dfca62de4cf4eb6e.tar.bz2
Don't traverse the PHI nodes twice. No functionality change!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150319 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 9d7477a..b7a5b51 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2294,7 +2294,7 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
/// EvaluateBlock - Evaluate all instructions in block BB, returning true if
/// successful, false if we can't evaluate it. NewBB returns the next BB that
/// control flows into, or null upon return.
-static bool EvaluateBlock(BasicBlock *BB, BasicBlock *&NextBB,
+static bool EvaluateBlock(BasicBlock::iterator CurInst, BasicBlock *&NextBB,
std::vector<Function*> &CallStack,
DenseMap<Value*, Constant*> &Values,
DenseMap<Constant*, Constant*> &MutatedMemory,
@@ -2302,9 +2302,6 @@ static bool EvaluateBlock(BasicBlock *BB, BasicBlock *&NextBB,
SmallPtrSet<Constant*, 8> &SimpleConstants,
const TargetData *TD,
const TargetLibraryInfo *TLI) {
- // CurInst - The current instruction we're evaluating.
- BasicBlock::iterator CurInst = BB->getFirstNonPHI();
-
// This is the main evaluation loop.
while (1) {
Constant *InstResult = 0;
@@ -2538,9 +2535,11 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
// CurBB - The current basic block we're evaluating.
BasicBlock *CurBB = F->begin();
+ BasicBlock::iterator CurInst = CurBB->begin();
+
while (1) {
BasicBlock *NextBB;
- if (!EvaluateBlock(CurBB, NextBB, CallStack, Values, MutatedMemory,
+ if (!EvaluateBlock(CurInst, NextBB, CallStack, Values, MutatedMemory,
AllocaTmps, SimpleConstants, TD, TLI))
return false;
@@ -2564,8 +2563,8 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
// are any PHI nodes. If so, evaluate them with information about where
// we came from.
PHINode *PN = 0;
- for (BasicBlock::iterator Inst = NextBB->begin();
- (PN = dyn_cast<PHINode>(Inst)); ++Inst)
+ for (CurInst = NextBB->begin();
+ (PN = dyn_cast<PHINode>(CurInst)); ++CurInst)
Values[PN] = getVal(Values, PN->getIncomingValueForBlock(CurBB));
// Advance to the next block.