summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-03-09 07:50:37 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-03-09 07:50:37 +0000
commit42445be0df9d4f85fd26632c2afd3c4d0cd9d9b0 (patch)
tree2b970ca4012d3d45be3fe8f750bc53164583f729 /llvm/lib/Transforms
parent459f5187037545d164ddad312ee04bd9d9265006 (diff)
downloadbcm5719-llvm-42445be0df9d4f85fd26632c2afd3c4d0cd9d9b0.tar.gz
bcm5719-llvm-42445be0df9d4f85fd26632c2afd3c4d0cd9d9b0.zip
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. llvm-svn: 48099
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 846c3bf9d9a..b9a9bc1c393 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/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();
}
OpenPOWER on IntegriCloud