[llvm-commits] [llvm] r51777 - /llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
Owen Anderson
resistor at mac.com
Fri May 30 10:31:01 PDT 2008
Author: resistor
Date: Fri May 30 12:31:01 2008
New Revision: 51777
URL: http://llvm.org/viewvc/llvm-project?rev=51777&view=rev
Log:
Since LCSSA switched over to DenseMap, we have to be more careful to avoid iterator invalidation. Fixes PR2385.
Modified:
llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=51777&r1=51776&r2=51777&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Fri May 30 12:31:01 2008
@@ -253,8 +253,7 @@
return UndefValue::get(OrigInst->getType());
// If we have already computed this value, return the previously computed val.
- Value *&V = Phis[BB];
- if (V) return V;
+ if (Phis.count(BB)) return Phis[BB];
DomTreeNode *IDom = BB->getIDom();
@@ -272,7 +271,9 @@
if (!inLoop(IDom->getBlock())) {
// Idom is not in the loop, we must still be "below" the exit block and must
// be fully dominated by the value live in the idom.
- return V = GetValueForBlock(IDom, OrigInst, Phis);
+ Value* val = GetValueForBlock(IDom, OrigInst, Phis);
+ Phis.insert(std::make_pair(BB, val));
+ return val;
}
BasicBlock *BBN = BB->getBlock();
@@ -282,7 +283,7 @@
PHINode *PN = PHINode::Create(OrigInst->getType(),
OrigInst->getName() + ".lcssa", BBN->begin());
PN->reserveOperandSpace(std::distance(pred_begin(BBN), pred_end(BBN)));
- V = PN;
+ Phis.insert(std::make_pair(BB, PN));
// Fill in the incoming values for the block.
for (pred_iterator PI = pred_begin(BBN), E = pred_end(BBN); PI != E; ++PI)
More information about the llvm-commits
mailing list