Don't use PN->replaceUsesOfWith() to change a PHINode's incoming blocks,

because it won't work after my phi operand changes, because the incoming
blocks will no longer be Uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133512 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jay Foad 2011-06-21 10:02:43 +00:00
parent 80be2a2654
commit 69254f67a5

View File

@ -190,7 +190,9 @@ bool LoopDeletion::runOnLoop(Loop* L, LPPassManager& LPM) {
BasicBlock* exitingBlock = exitingBlocks[0];
BasicBlock::iterator BI = exitBlock->begin();
while (PHINode* P = dyn_cast<PHINode>(BI)) {
P->replaceUsesOfWith(exitingBlock, preheader);
int j = P->getBasicBlockIndex(exitingBlock);
assert(j >= 0 && "Can't find exiting block in exit block's phi node!");
P->setIncomingBlock(j, preheader);
for (unsigned i = 1; i < exitingBlocks.size(); ++i)
P->removeIncomingValue(exitingBlocks[i]);
++BI;