In mem2reg, for all alloca/stores that get promoted where the alloca has an associate...
[oota-llvm.git] / lib / Transforms / Utils / CloneLoop.cpp
index 34ed132b04cd2c661be088131db8642feb156f68..38928dc7cc88643f8d84c37a2906746b3c0da06f 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Devang Patel and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -79,8 +79,8 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager  *LPM, LoopInfo *LI,
   DominatorTree *DT = NULL;
   DominanceFrontier *DF = NULL;
   if (P) {
-    DT = P->getAnalysisToUpdate<DominatorTree>();
-    DF = P->getAnalysisToUpdate<DominanceFrontier>();
+    DT = P->getAnalysisIfAvailable<DominatorTree>();
+    DF = P->getAnalysisIfAvailable<DominanceFrontier>();
   }
 
   SmallVector<BasicBlock *, 16> NewBlocks;
@@ -91,9 +91,8 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager  *LPM, LoopInfo *LI,
 
 
   Loop *NewParentLoop = NULL;
-  while (!LoopNest.empty()) {
-    Loop *L = LoopNest.back();
-    LoopNest.pop_back();
+  do {
+    Loop *L = LoopNest.pop_back_val();
     Loop *NewLoop = new Loop();
 
     if (!NewParentLoop)
@@ -124,7 +123,7 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager  *LPM, LoopInfo *LI,
     // Process sub loops
     for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
       LoopNest.push_back(*I);
-  }
+  } while (!LoopNest.empty());
 
   // Remap instructions to reference operands from ValueMap.
   for(SmallVector<BasicBlock *, 16>::iterator NBItr = NewBlocks.begin(),