[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
sabre at nondot.org
Fri Mar 2 18:05:07 PST 2007
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.640 -> 1.641
---
Log message:
add a top-level iteration loop to instcombine. This means that it will never
finish without combining something it is capable of.
---
Diffs of the changes: (+21 -4)
InstructionCombining.cpp | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.640 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.641
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.640 Fri Mar 2 15:28:56 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Mar 2 20:04:50 2007
@@ -141,6 +141,8 @@
public:
virtual bool runOnFunction(Function &F);
+
+ bool DoOneIteration(Function &F, unsigned ItNum);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetData>();
@@ -9164,9 +9166,12 @@
AddReachableCodeToWorklist(TI->getSuccessor(i), Visited, IC, TD);
}
-bool InstCombiner::runOnFunction(Function &F) {
+bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
bool Changed = false;
TD = &getAnalysis<TargetData>();
+
+ DEBUG(DOUT << "\n\nINSTCOMBINE ITERATION #" << Iteration << " on "
+ << F.getNameStr() << "\n");
{
// Do a depth-first traversal of the function, populate the worklist with
@@ -9295,24 +9300,36 @@
if (isInstructionTriviallyDead(I)) {
// Make sure we process all operands now that we are reducing their
// use counts.
- AddUsesToWorkList(*I);;
+ AddUsesToWorkList(*I);
// Instructions may end up in the worklist more than once. Erase all
// occurrences of this instruction.
RemoveFromWorkList(I);
I->eraseFromParent();
} else {
- AddToWorkList(Result);
- AddUsersToWorkList(*Result);
+ AddToWorkList(I);
+ AddUsersToWorkList(*I);
}
}
Changed = true;
}
}
+ assert(WorklistMap.empty() && "Worklist empty, but map not?");
return Changed;
}
+
+bool InstCombiner::runOnFunction(Function &F) {
+ bool EverMadeChange = false;
+
+ // Iterate while there is work to do.
+ unsigned Iteration = 0;
+ while (DoOneIteration(F, Iteration++))
+ EverMadeChange = true;
+ return EverMadeChange;
+}
+
FunctionPass *llvm::createInstructionCombiningPass() {
return new InstCombiner();
}
More information about the llvm-commits
mailing list