diff options
author | Owen Anderson <resistor@mac.com> | 2008-05-30 17:31:01 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-05-30 17:31:01 +0000 |
commit | 1f59d9937f80b89da88796093142cfd16da712d5 (patch) | |
tree | 5247507052fd42037c1f9dfa6682684a44df9c88 | |
parent | a50833b695293ac9d1f8425cc3fe0e0b0dfb31b6 (diff) | |
download | bcm5719-llvm-1f59d9937f80b89da88796093142cfd16da712d5.tar.gz bcm5719-llvm-1f59d9937f80b89da88796093142cfd16da712d5.zip |
Since LCSSA switched over to DenseMap, we have to be more careful to avoid iterator invalidation. Fixes PR2385.
llvm-svn: 51777
-rw-r--r-- | llvm/lib/Transforms/Utils/LCSSA.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/LCSSA.cpp b/llvm/lib/Transforms/Utils/LCSSA.cpp index 6277265a36f..c3de7979dfb 100644 --- a/llvm/lib/Transforms/Utils/LCSSA.cpp +++ b/llvm/lib/Transforms/Utils/LCSSA.cpp @@ -253,8 +253,7 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst, 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 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst, 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 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst, 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) |