Add facility that allows LoopPass to re-insert a loop into
authorDevang Patel <dpatel@apple.com>
Fri, 23 Feb 2007 00:16:44 +0000 (00:16 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 23 Feb 2007 00:16:44 +0000 (00:16 +0000)
Loop Pass Manager's queue.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34509 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopPass.h
lib/Analysis/LoopPass.cpp

index 046da6f13d82aed839abcd1083e5b2ad8a3d6cb3..b3d4c6e89721017734220b172c7ffd2139a45e05 100644 (file)
@@ -85,10 +85,15 @@ public:
   // Delete loop from the loop queue. This is used by Loop pass to inform
   // Loop Pass Manager that it should skip rest of the passes for this loop.
   void deleteLoopFromQueue(Loop *L);
+
+  // Reoptimize this loop. LPPassManager will re-insert this loop into the
+  // queue. This allows LoopPass to change loop nest for the loop. This
+  // utility may send LPPassManager into infinite loops so use caution.
+  void redoLoop(Loop *L);
 private:
   LoopQueue *LQ;
   bool skipThisLoop;
-
+  bool redoThisLoop;
 };
 
 } // End llvm namespace
index 22d542b05ba11cfeef6e1c952693f11be746a267..dc5c5683fb218d72b844796b5080f4b4aff7bbb8 100644 (file)
@@ -50,6 +50,8 @@ private:
 /// LPPassManager manages FPPassManagers and CalLGraphSCCPasses.
 
 LPPassManager::LPPassManager(int Depth) : PMDataManager(Depth) { 
+  skipThisLoop = false;
+  redoThisLoop = false;
   LQ = new LoopQueue(); 
 }
 
@@ -64,6 +66,13 @@ void LPPassManager::deleteLoopFromQueue(Loop *L) {
   skipThisLoop = true;
 }
 
+// Reoptimize this loop. LPPassManager will re-insert this loop into the
+// queue. This allows LoopPass to change loop nest for the loop. This
+// utility may send LPPassManager into infinite loops so use caution.
+void LPPassManager::redoLoop(Loop *L) {
+  redoThisLoop = true;
+}
+
 // 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)
@@ -89,6 +98,7 @@ bool LPPassManager::runOnFunction(Function &F) {
       
     Loop *L  = LQ->top();
     skipThisLoop = false;
+    redoThisLoop = false;
 
     // Run all passes on current SCC
     for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {  
@@ -124,6 +134,9 @@ bool LPPassManager::runOnFunction(Function &F) {
     
     // Pop the loop from queue after running all passes.
     LQ->pop();
+    
+    if (redoThisLoop)
+      LQ->push(L);
   }
 
   return Changed;