mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Since LCSSA switched over to DenseMap, we have to be more careful to avoid iterator invalidation. Fixes PR2385.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51777 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
babf11f249
commit
427de86ada
@ -253,8 +253,7 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst,
|
|||||||
return UndefValue::get(OrigInst->getType());
|
return UndefValue::get(OrigInst->getType());
|
||||||
|
|
||||||
// If we have already computed this value, return the previously computed val.
|
// If we have already computed this value, return the previously computed val.
|
||||||
Value *&V = Phis[BB];
|
if (Phis.count(BB)) return Phis[BB];
|
||||||
if (V) return V;
|
|
||||||
|
|
||||||
DomTreeNode *IDom = BB->getIDom();
|
DomTreeNode *IDom = BB->getIDom();
|
||||||
|
|
||||||
@ -272,7 +271,9 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst,
|
|||||||
if (!inLoop(IDom->getBlock())) {
|
if (!inLoop(IDom->getBlock())) {
|
||||||
// Idom is not in the loop, we must still be "below" the exit block and must
|
// 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.
|
// 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();
|
BasicBlock *BBN = BB->getBlock();
|
||||||
@ -282,7 +283,7 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst,
|
|||||||
PHINode *PN = PHINode::Create(OrigInst->getType(),
|
PHINode *PN = PHINode::Create(OrigInst->getType(),
|
||||||
OrigInst->getName() + ".lcssa", BBN->begin());
|
OrigInst->getName() + ".lcssa", BBN->begin());
|
||||||
PN->reserveOperandSpace(std::distance(pred_begin(BBN), pred_end(BBN)));
|
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.
|
// Fill in the incoming values for the block.
|
||||||
for (pred_iterator PI = pred_begin(BBN), E = pred_end(BBN); PI != E; ++PI)
|
for (pred_iterator PI = pred_begin(BBN), E = pred_end(BBN); PI != E; ++PI)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user