forked from OSchip/llvm-project
Fix for PR1444: do not create two successors to the same block.
Temporarily, this breaks CodeGen/Generic/2006-02-12-InsertLibraryCall.ll by exposing an unrelated latent problem; working on that. llvm-svn: 37323
This commit is contained in:
parent
8ff9ff7975
commit
1af8c870c7
|
@ -717,12 +717,20 @@ static void ReplaceUsesOfBlockWith(MachineBasicBlock *BB,
|
||||||
I->getOperand(i).setMachineBasicBlock(New);
|
I->getOperand(i).setMachineBasicBlock(New);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the successor information.
|
// Update the successor information. If New was already a successor, just
|
||||||
|
// remove the link to Old instead of creating another one. PR 1444.
|
||||||
|
bool HadSuccessorNew = false;
|
||||||
std::vector<MachineBasicBlock*> Succs(BB->succ_begin(), BB->succ_end());
|
std::vector<MachineBasicBlock*> Succs(BB->succ_begin(), BB->succ_end());
|
||||||
|
for (int i = Succs.size()-1; i >= 0; --i)
|
||||||
|
if (Succs[i] == New) {
|
||||||
|
HadSuccessorNew = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
for (int i = Succs.size()-1; i >= 0; --i)
|
for (int i = Succs.size()-1; i >= 0; --i)
|
||||||
if (Succs[i] == Old) {
|
if (Succs[i] == Old) {
|
||||||
BB->removeSuccessor(Old);
|
BB->removeSuccessor(Old);
|
||||||
BB->addSuccessor(New);
|
if (!HadSuccessorNew)
|
||||||
|
BB->addSuccessor(New);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue