diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 61da0d998fc..846c3bf9d9a 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1370,7 +1370,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { new UnwindInst(Pred); // Use unwind. Changed = true; } - } else if (InvokeInst *II = dyn_cast(Pred->getTerminator())) + } else if (InvokeInst *II = dyn_cast(Pred->getTerminator())) { if (II->getUnwindDest() == BB) { // Insert a new branch instruction before the invoke, because this // is now a fall through... @@ -1388,6 +1388,9 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { delete II; Changed = true; } + } else if (Pred->getUnwindDest() == BB) { + Pred->setUnwindDest(NULL); + } Preds.pop_back(); } diff --git a/test/Transforms/SimplifyCFG/unwindto.ll b/test/Transforms/SimplifyCFG/unwindto.ll index e42a831766c..28d9d1e6e39 100644 --- a/test/Transforms/SimplifyCFG/unwindto.ll +++ b/test/Transforms/SimplifyCFG/unwindto.ll @@ -33,3 +33,11 @@ bb4: unwind_to %cleanup cleanup: ret i32 1 } + +define i32 @f3() { +entry: unwind_to %cleanup + call void @g(i32 0) + ret i32 0 +cleanup: + unwind +}