summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-03-03 02:04:50 +0000
committerChris Lattner <sabre@nondot.org>2007-03-03 02:04:50 +0000
commit960a54303730a86694934cb89efe9bc501e25b91 (patch)
treec1e4a39f4d7fe683fe6ce63f97025d1192e1738b /llvm/lib/Transforms
parentc34dedf68655f1a0dbe242a938b02db984682344 (diff)
downloadbcm5719-llvm-960a54303730a86694934cb89efe9bc501e25b91.tar.gz
bcm5719-llvm-960a54303730a86694934cb89efe9bc501e25b91.zip
add a top-level iteration loop to instcombine. This means that it will never
finish without combining something it is capable of. llvm-svn: 34865
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 6eefac2033d..b20ff9711d7 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -141,6 +141,8 @@ namespace {
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 @@ static void AddReachableCodeToWorklist(BasicBlock *BB,
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 @@ bool InstCombiner::runOnFunction(Function &F) {
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();
}
OpenPOWER on IntegriCloud