[llvm-commits] [llvm] r48106 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Nick Lewycky
nicholas at mxc.ca
Sun Mar 9 00:50:23 PST 2008
Author: nicholas
Date: Sun Mar 9 03:50:23 2008
New Revision: 48106
URL: http://llvm.org/viewvc/llvm-project?rev=48106&view=rev
Log:
Don't eliminate blocks that are only reachable by unwind_to.
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=48106&r1=48105&r2=48106&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar 9 03:50:23 2008
@@ -10796,11 +10796,15 @@
// Recursively visit successors. If this is a branch or switch on a
// constant, only visit the reachable successor.
+ if (BB->getUnwindDest())
+ Worklist.push_back(BB->getUnwindDest());
TerminatorInst *TI = BB->getTerminator();
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
if (BI->isConditional() && isa<ConstantInt>(BI->getCondition())) {
bool CondVal = cast<ConstantInt>(BI->getCondition())->getZExtValue();
- Worklist.push_back(BI->getSuccessor(!CondVal));
+ BasicBlock *ReachableBB = BI->getSuccessor(!CondVal);
+ if (ReachableBB != BB->getUnwindDest())
+ Worklist.push_back(ReachableBB);
continue;
}
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
@@ -10808,7 +10812,9 @@
// See if this is an explicit destination.
for (unsigned i = 1, e = SI->getNumSuccessors(); i != e; ++i)
if (SI->getCaseValue(i) == Cond) {
- Worklist.push_back(SI->getSuccessor(i));
+ BasicBlock *ReachableBB = SI->getSuccessor(i);
+ if (ReachableBB != BB->getUnwindDest())
+ Worklist.push_back(ReachableBB);
continue;
}
More information about the llvm-commits
mailing list