[llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp
Devang Patel
dpatel at apple.com
Thu Feb 22 15:45:32 PST 2007
Changes in directory llvm/lib/Analysis:
LoopPass.cpp updated: 1.2 -> 1.3
---
Log message:
Populate and walk loop queue.
---
Diffs of the changes: (+20 -6)
LoopPass.cpp | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
Index: llvm/lib/Analysis/LoopPass.cpp
diff -u llvm/lib/Analysis/LoopPass.cpp:1.2 llvm/lib/Analysis/LoopPass.cpp:1.3
--- llvm/lib/Analysis/LoopPass.cpp:1.2 Thu Feb 22 17:30:07 2007
+++ llvm/lib/Analysis/LoopPass.cpp Thu Feb 22 17:45:15 2007
@@ -33,11 +33,11 @@
// Loop queue used by Loop Pass Manager. This is a wrapper class
// that hides implemenation detail (use of priority_queue) inside .cpp file.
class LoopQueue {
-
+public:
inline void push(Loop *L) { LPQ.push(L); }
inline void pop() { LPQ.pop(); }
inline Loop *top() { return LPQ.top(); }
-
+ inline bool empty() { return LPQ.empty(); }
private:
std::priority_queue<Loop *, std::vector<Loop *>, LoopCompare> LPQ;
};
@@ -57,22 +57,33 @@
delete LQ;
}
+// Recurse through all subloops and all loops into LQ.
+static void addLoopIntoQueue(Loop *L, LoopQueue *LQ) {
+ for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
+ addLoopIntoQueue(*I, LQ);
+ LQ->push(L);
+}
+
/// run - Execute all of the passes scheduled for execution. Keep track of
/// whether any of the passes modifies the function, and if so, return true.
bool LPPassManager::runOnFunction(Function &F) {
LoopInfo &LI = getAnalysis<LoopInfo>();
bool Changed = false;
+ // Populate Loop Queue
+ for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I)
+ addLoopIntoQueue(*I, LQ);
+
std::string Msg1 = "Executing Pass '";
std::string Msg3 = "' Made Modification '";
// Walk Loops
- for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I) {
-
- Loop *L = *I;
+ while (!LQ->empty()) {
+
+ Loop *L = LQ->top();
// Run all passes on current SCC
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
-
+
Pass *P = getContainedPass(Index);
AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage);
@@ -97,6 +108,9 @@
recordAvailableAnalysis(P);
removeDeadPasses(P, Msg2);
}
+
+ // Pop the loop from queue after running all passes.
+ LQ->pop();
}
return Changed;
More information about the llvm-commits
mailing list