mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-21 19:32:16 +00:00
Fix a subtle iterator invalidation bug in a recursive algorithm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40776 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1af002d362
commit
4b55c3b0f1
@ -726,19 +726,21 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig,
|
|||||||
bool top_level) {
|
bool top_level) {
|
||||||
|
|
||||||
// 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];
|
Value *V = Phis[BB];
|
||||||
if (V && ! top_level) return V;
|
if (V && ! top_level) return V;
|
||||||
|
|
||||||
BasicBlock* singlePred = BB->getSinglePredecessor();
|
BasicBlock* singlePred = BB->getSinglePredecessor();
|
||||||
if (singlePred)
|
if (singlePred) {
|
||||||
return V = GetValueForBlock(singlePred, orig, Phis);
|
V = GetValueForBlock(singlePred, orig, Phis);
|
||||||
|
Phis[BB] = V;
|
||||||
|
return V;
|
||||||
|
}
|
||||||
// Otherwise, the idom is the loop, so we need to insert a PHI node. Do so
|
// Otherwise, the idom is the loop, so we need to insert a PHI node. Do so
|
||||||
// now, then get values to fill in the incoming values for the PHI.
|
// now, then get values to fill in the incoming values for the PHI.
|
||||||
PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle",
|
PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle",
|
||||||
BB->begin());
|
BB->begin());
|
||||||
PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
|
PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
|
||||||
V = PN;
|
Phis[BB] = PN;
|
||||||
|
|
||||||
bool all_same = true;
|
bool all_same = true;
|
||||||
Value* first = 0;
|
Value* first = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user