diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-03-09 07:50:37 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-03-09 07:50:37 +0000 |
commit | e5f162cce8574c539787cf42f43fb7a579b3f8e4 (patch) | |
tree | 2ecde0446598f04f84b6789224e92b6f89ce9afb /lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | f4e81e0f66e8fc640c6bc4c23d523f6237be54b9 (diff) | |
download | external_llvm-e5f162cce8574c539787cf42f43fb7a579b3f8e4.zip external_llvm-e5f162cce8574c539787cf42f43fb7a579b3f8e4.tar.gz external_llvm-e5f162cce8574c539787cf42f43fb7a579b3f8e4.tar.bz2 |
Firstly, having a BranchInst isn't exclusive with having an unwind_to.
Secondly, we have to check whether the branch is actually pointing to the block
with the unwind in it. We could have gotten here because of the unwind_to alone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48099 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 846c3bf..b9a9bc1 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1364,13 +1364,19 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { SmallVector<BasicBlock*, 8> Preds(pred_begin(BB), pred_end(BB)); while (!Preds.empty()) { BasicBlock *Pred = Preds.back(); + + if (Pred->getUnwindDest() == BB) { + Pred->setUnwindDest(NULL); + Changed = true; + } + if (BranchInst *BI = dyn_cast<BranchInst>(Pred->getTerminator())) { - if (BI->isUnconditional()) { + if (BI->isUnconditional() && BI->getSuccessor(0) == BB) { Pred->getInstList().pop_back(); // nuke uncond branch new UnwindInst(Pred); // Use unwind. Changed = true; } - } else if (InvokeInst *II = dyn_cast<InvokeInst>(Pred->getTerminator())) { + } else if (InvokeInst *II = dyn_cast<InvokeInst>(Pred->getTerminator())) if (II->getUnwindDest() == BB) { // Insert a new branch instruction before the invoke, because this // is now a fall through... @@ -1388,9 +1394,6 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { delete II; Changed = true; } - } else if (Pred->getUnwindDest() == BB) { - Pred->setUnwindDest(NULL); - } Preds.pop_back(); } |