aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-09-08 19:44:26 +0000
committerChris Lattner <sabre@nondot.org>2003-09-08 19:44:26 +0000
commitee5457cbe88b7f691f774de8515d9a94226d1b00 (patch)
treeac7e19c81aba3447b8446f1b4d29c5f5e6db01b8 /lib/Transforms/Utils/SimplifyCFG.cpp
parentda73beac201091653d9e2b900d2207c31ed97a0e (diff)
Eliminate support for the llvm.unwind intrinisic, using the Unwind instruction instead
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8411 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp49
1 files changed, 24 insertions, 25 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index f47c840518..1d5e4ec8af 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -101,32 +101,31 @@ bool SimplifyCFG(BasicBlock *BB) {
// 'llvm.unwind'. If so, replace any invoke instructions which use this as an
// exception destination with call instructions.
//
- if (CallInst *CI = dyn_cast<CallInst>(&BB->front()))
- if (Function *F = CI->getCalledFunction())
- if (F->getIntrinsicID() == LLVMIntrinsic::unwind) {
- std::vector<BasicBlock*> Preds(pred_begin(BB), pred_end(BB));
- while (!Preds.empty()) {
- BasicBlock *Pred = Preds.back();
- if (InvokeInst *II = dyn_cast<InvokeInst>(Pred->getTerminator()))
- if (II->getExceptionalDest() == BB) {
- // Insert a new branch instruction before the invoke, because this
- // is now a fall through...
- BranchInst *BI = new BranchInst(II->getNormalDest(), II);
- Pred->getInstList().remove(II); // Take out of symbol table
-
- // Insert the call now...
- std::vector<Value*> Args(II->op_begin()+3, II->op_end());
- CallInst *CI = new CallInst(II->getCalledValue(), Args,
- II->getName(), BI);
- // If the invoke produced a value, the Call now does instead
- II->replaceAllUsesWith(CI);
- delete II;
- Changed = true;
- }
-
- Preds.pop_back();
- }
+ if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->getTerminator()))
+ if (BB->begin() == BasicBlock::iterator(UI)) { // Empty block?
+ std::vector<BasicBlock*> Preds(pred_begin(BB), pred_end(BB));
+ while (!Preds.empty()) {
+ BasicBlock *Pred = Preds.back();
+ if (InvokeInst *II = dyn_cast<InvokeInst>(Pred->getTerminator()))
+ if (II->getExceptionalDest() == BB) {
+ // Insert a new branch instruction before the invoke, because this
+ // is now a fall through...
+ BranchInst *BI = new BranchInst(II->getNormalDest(), II);
+ Pred->getInstList().remove(II); // Take out of symbol table
+
+ // Insert the call now...
+ std::vector<Value*> Args(II->op_begin()+3, II->op_end());
+ CallInst *CI = new CallInst(II->getCalledValue(), Args,
+ II->getName(), BI);
+ // If the invoke produced a value, the Call now does instead
+ II->replaceAllUsesWith(CI);
+ delete II;
+ Changed = true;
+ }
+
+ Preds.pop_back();
}
+ }
// Remove basic blocks that have no predecessors... which are unreachable.
if (pred_begin(BB) == pred_end(BB) &&