Change behavior of changeExitBlock function to replace all instances of exit block
authorChris Lattner <sabre@nondot.org>
Thu, 27 Feb 2003 22:37:44 +0000 (22:37 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 27 Feb 2003 22:37:44 +0000 (22:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5661 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 535cfd9ab72edf162bae94cbd3eb9baca4101502..d4a6224398bb5ce308dc2c5af977b38eb6d40206 100644 (file)
@@ -89,8 +89,8 @@ public:
   ///
   void addBasicBlockToLoop(BasicBlock *NewBB, LoopInfo &LI);
 
-  /// changeExitBlock - This method is used to update loop information.  One
-  /// instance of the specified Old basic block is removed from the exit list
+  /// changeExitBlock - This method is used to update loop information.  All
+  /// instances of the specified Old basic block are removed from the exit list
   /// and replaced with New.
   ///
   void changeExitBlock(BasicBlock *Old, BasicBlock *New);
index 035f92c33c3b37aa10f50a2fd40a9f4b6a4eca58..a54d659dc8e893aeba8b4d51d0725fb977ca900e 100644 (file)
@@ -235,8 +235,8 @@ void Loop::addBasicBlockToLoop(BasicBlock *NewBB, LoopInfo &LI) {
   }
 }
 
-/// changeExitBlock - This method is used to update loop information.  One
-/// instance of the specified Old basic block is removed from the exit list
+/// changeExitBlock - This method is used to update loop information.  All
+/// instances of the specified Old basic block are removed from the exit list
 /// and replaced with New.
 ///
 void Loop::changeExitBlock(BasicBlock *Old, BasicBlock *New) {
@@ -246,4 +246,10 @@ void Loop::changeExitBlock(BasicBlock *Old, BasicBlock *New) {
     std::find(ExitBlocks.begin(), ExitBlocks.end(), Old);
   assert(I != ExitBlocks.end() && "Old exit block not found!");
   *I = New;
+
+  I = std::find(I+1, ExitBlocks.end(), Old);
+  while (I != ExitBlocks.end()) {
+    *I = New;
+    I = std::find(I+1, ExitBlocks.end(), Old);
+  }
 }