From c37308604f00f9129c6ac3358d7b6f3465880483 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 27 Feb 2003 22:37:44 +0000 Subject: [PATCH] Change behavior of changeExitBlock function to replace all instances of exit block llvm-svn: 5661 --- include/llvm/Analysis/LoopInfo.h | 4 ++-- lib/Analysis/LoopInfo.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 535cfd9ab72..d4a6224398b 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -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); diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 035f92c33c3..a54d659dc8e 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -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); + } }