diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-20 01:17:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-20 01:17:38 +0000 |
commit | 5823ac1c213ecba98fe03fd738dff658ccede1d0 (patch) | |
tree | 324d3c4f744cabef2bec1ed0255b1dcf3ec2df33 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | d4cecb9e2f099b2d680a6714bb354a99526067c9 (diff) | |
download | bcm5719-llvm-5823ac1c213ecba98fe03fd738dff658ccede1d0.tar.gz bcm5719-llvm-5823ac1c213ecba98fe03fd738dff658ccede1d0.zip |
Implement SimplifyCFG/BrUnwind.ll
llvm-svn: 15022
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index cc28e54c374..2cf4ab9cded 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -764,12 +764,19 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { } else if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->begin())) { // Check to see if the first instruction in this block is just an unwind. // If so, replace any invoke instructions which use this as an exception - // destination with call instructions. + // destination with call instructions, and any unconditional branch + // predecessor with an 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 (BranchInst *BI = dyn_cast<BranchInst>(Pred->getTerminator())) { + if (BI->isUnconditional()) { + Pred->getInstList().pop_back(); // nuke uncond branch + new UnwindInst(Pred); // Use unwind. + Changed = true; + } + } 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... |