Extract the code for inserting a loop into the loop queue into
authorDan Gohman <gohman@apple.com>
Sun, 27 Sep 2009 23:49:43 +0000 (23:49 +0000)
committerDan Gohman <gohman@apple.com>
Sun, 27 Sep 2009 23:49:43 +0000 (23:49 +0000)
a separate function.

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

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

index 7659b5bf458de40e8f1d461cdea6c9f758b1b2f9..2eb329f7f0e3faecbe8756e0f0e5681200c82fb2 100644 (file)
@@ -111,9 +111,13 @@ public:
   // Delete loop from the loop queue and loop nest (LoopInfo).
   void deleteLoopFromQueue(Loop *L);
 
-  // Insert loop into the loop nest(LoopInfo) and loop queue(LQ).
+  // Insert loop into the loop queue and add it as a child of the
+  // given parent.
   void insertLoop(Loop *L, Loop *ParentLoop);
 
+  // Insert a loop into the loop queue.
+  void insertLoopIntoQueue(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.
index 4f7018da1ace83b66584a80e5094347e2feb95fd..4ed802cb3ff243c7d9d0515851d8a81896b87631 100644 (file)
@@ -110,17 +110,21 @@ void LPPassManager::insertLoop(Loop *L, Loop *ParentLoop) {
   else
     LI->addTopLevelLoop(L);
 
+  insertLoopIntoQueue(L);
+}
+
+void LPPassManager::insertLoopIntoQueue(Loop *L) {
   // Insert L into loop queue
   if (L == CurrentLoop) 
     redoLoop(L);
-  else if (!ParentLoop)
+  else if (!L->getParentLoop())
     // This is top level loop. 
     LQ.push_front(L);
   else {
-    // Insert L after ParentLoop
+    // Insert L after the parent loop.
     for (std::deque<Loop *>::iterator I = LQ.begin(),
            E = LQ.end(); I != E; ++I) {
-      if (*I == ParentLoop) {
+      if (*I == L->getParentLoop()) {
         // deque does not support insert after.
         ++I;
         LQ.insert(I, 1, L);