mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
VMCore/BasicBlock.cpp: Don't assume BasicBlock::iterator might end with a non-PHInode Instruction in successors.
Frontends(eg. clang) might pass incomplete form of IR, to step off the way beyond iterator end. In the case I had met, it took infinite loop due to meeting bogus PHInode. Thanks to Jay Foad and John McCall. llvm-svn: 137175
This commit is contained in:
parent
9c7aa146af
commit
604b538820
@ -336,8 +336,12 @@ void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) {
|
||||
return;
|
||||
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) {
|
||||
BasicBlock *Succ = TI->getSuccessor(i);
|
||||
for (iterator II = Succ->begin(); PHINode *PN = dyn_cast<PHINode>(II);
|
||||
++II) {
|
||||
// N.B. Succ might not be a complete BasicBlock, so don't assume
|
||||
// that it ends with a non-phi instruction.
|
||||
for (iterator II = Succ->begin(), IE = Succ->end(); II != IE; ++II) {
|
||||
PHINode *PN = dyn_cast<PHINode>(II);
|
||||
if (!PN)
|
||||
break;
|
||||
int i;
|
||||
while ((i = PN->getBasicBlockIndex(this)) >= 0)
|
||||
PN->setIncomingBlock(i, New);
|
||||
|
Loading…
Reference in New Issue
Block a user