diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-13 18:13:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-13 18:13:05 +0000 |
commit | b8a7d3e1a68fce4b087e39e67176fe3c36039bd9 (patch) | |
tree | 0815e2d46bc510117a3be44213454991e3e83222 /lib | |
parent | 5afeae814f97bea55783376496dc92afaf65f3e0 (diff) | |
download | external_llvm-b8a7d3e1a68fce4b087e39e67176fe3c36039bd9.zip external_llvm-b8a7d3e1a68fce4b087e39e67176fe3c36039bd9.tar.gz external_llvm-b8a7d3e1a68fce4b087e39e67176fe3c36039bd9.tar.bz2 |
change simplifycfg to not duplicate 'unwind' instructions. Hopefully
this will increase the likelihood of common code getting sunk towards
the unwind.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83996 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 92b1335..6fd7d7b 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1860,33 +1860,26 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { } else if (isa<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, and any unconditional branch - // predecessor with an unwind. + // destination with call instructions. // SmallVector<BasicBlock*, 8> Preds(pred_begin(BB), pred_end(BB)); while (!Preds.empty()) { BasicBlock *Pred = Preds.back(); - if (BranchInst *BI = dyn_cast<BranchInst>(Pred->getTerminator())) { - if (BI->isUnconditional()) { - Pred->getInstList().pop_back(); // nuke uncond branch - new UnwindInst(Pred->getContext(), Pred); // Use unwind. - Changed = true; - } - } else if (InvokeInst *II = dyn_cast<InvokeInst>(Pred->getTerminator())) + 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... + // is now a fall through. BranchInst *BI = BranchInst::Create(II->getNormalDest(), II); Pred->getInstList().remove(II); // Take out of symbol table - // Insert the call now... + // Insert the call now. SmallVector<Value*,8> Args(II->op_begin()+3, II->op_end()); CallInst *CI = CallInst::Create(II->getCalledValue(), Args.begin(), Args.end(), II->getName(), BI); CI->setCallingConv(II->getCallingConv()); CI->setAttributes(II->getAttributes()); - // If the invoke produced a value, the Call now does instead + // If the invoke produced a value, the Call now does instead. II->replaceAllUsesWith(CI); delete II; Changed = true; |