[llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Jul 19 18:17:48 PDT 2004
Changes in directory llvm/lib/Transforms/Utils:
SimplifyCFG.cpp updated: 1.47 -> 1.48
---
Log message:
Implement SimplifyCFG/BrUnwind.ll
---
Diffs of the changes: (+9 -2)
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.47 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.48
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.47 Sat Jul 17 19:32:14 2004
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Mon Jul 19 20:17:38 2004
@@ -764,12 +764,19 @@
} 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...
More information about the llvm-commits
mailing list