Fix Transforms/SimplifyCFG/switch-simplify-crash.ll

llvm-svn: 22158
This commit is contained in:
Chris Lattner 2005-05-20 22:19:54 +00:00
parent 7e9e2e0ea9
commit 19f9f32a5c
1 changed files with 7 additions and 0 deletions

View File

@ -1236,6 +1236,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
for (unsigned i = 1, e = SI->getNumCases(); i != e; ++i)
if (SI->getSuccessor(i) == BB) {
BB->removePredecessor(SI->getParent());
SI->removeCase(i);
--i; --e;
Changed = true;
@ -1263,6 +1264,12 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
SI->setSuccessor(0, MaxBlock);
Changed = true;
// If MaxBlock has phinodes in it, remove MaxPop-1 entries from
// it.
if (isa<PHINode>(MaxBlock->begin()))
for (unsigned i = 0; i != MaxPop-1; ++i)
MaxBlock->removePredecessor(SI->getParent());
for (unsigned i = 1, e = SI->getNumCases(); i != e; ++i)
if (SI->getSuccessor(i) == MaxBlock) {
SI->removeCase(i);