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 | 42eb7524ef3a994f184924e583871406cf5d1ed6 (patch) | |
tree | 6a5a3f03a0f32342144d6b1477d0ea6908eac26d /lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 07b5c9d68f5b9759fcca63aec9c6e298bad90ec3 (diff) |
Fix Transforms/SimplifyCFG/switch-simplify-crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22158 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 15ea761f2c..ad78506ad4 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/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); |