[llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Jan 1 08:02:24 PST 2005
Changes in directory llvm/lib/Transforms/Utils:
SimplifyCFG.cpp updated: 1.61 -> 1.62
---
Log message:
Implement SimplifyCFG/DeadSetCC.ll
SimplifyCFG is one of those passes that we use for final cleanup: it should
not rely on other passes to clean up its garbage. This fixes the "why are
trivially dead setcc's in the output of gccas" problem.
---
Diffs of the changes: (+8 -0)
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.61 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.62
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.61 Fri Dec 10 11:42:31 2004
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Sat Jan 1 10:02:12 2005
@@ -521,8 +521,16 @@
SwitchInst *NewSI = new SwitchInst(CV, PredDefault, PTI);
for (unsigned i = 0, e = PredCases.size(); i != e; ++i)
NewSI->addCase(PredCases[i].first, PredCases[i].second);
+
+ Instruction *DeadCond = 0;
+ if (BranchInst *BI = dyn_cast<BranchInst>(PTI))
+ // If PTI is a branch, remember the condition.
+ DeadCond = dyn_cast<Instruction>(BI->getCondition());
Pred->getInstList().erase(PTI);
+ // If the condition is dead now, remove the instruction tree.
+ if (DeadCond) ErasePossiblyDeadInstructionTree(DeadCond);
+
// Okay, last check. If BB is still a successor of PSI, then we must
// have an infinite loop case. If so, add an infinitely looping block
// to handle the case to preserve the behavior of the code.
More information about the llvm-commits
mailing list