diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-05-20 22:19:54 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-05-20 22:19:54 +0000 |
| commit | 19f9f32a5c2f883b3092f80d3d707250a9d918d8 (patch) | |
| tree | 5ed6a222c3fa951201ea96edbfb7d116d4ca88ff /llvm/lib | |
| parent | 7e9e2e0ea90f1c239b59a92ee7927ced3298dcdc (diff) | |
| download | bcm5719-llvm-19f9f32a5c2f883b3092f80d3d707250a9d918d8.tar.gz bcm5719-llvm-19f9f32a5c2f883b3092f80d3d707250a9d918d8.zip | |
Fix Transforms/SimplifyCFG/switch-simplify-crash.ll
llvm-svn: 22158
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 15ea761f2ce..ad78506ad42 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -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); |

