Change behavior of changeExitBlock function to replace all instances of exit block
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5661 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index 035f92c..a54d659 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -235,8 +235,8 @@
}
}
-/// 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 @@
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);
+ }
}