summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-18 05:38:05 +0000
committerChris Lattner <sabre@nondot.org>2004-04-18 05:38:05 +0000
commit1472c63fb95f76491b4f732fff95e0c3d4da05e3 (patch)
tree4e0086c280dd6e1015c3e1eb383147247743f819 /llvm/lib/Analysis/LoopInfo.cpp
parentc9de38d316797f3657a584b8c5da72a31620197b (diff)
downloadbcm5719-llvm-1472c63fb95f76491b4f732fff95e0c3d4da05e3.tar.gz
bcm5719-llvm-1472c63fb95f76491b4f732fff95e0c3d4da05e3.zip
Add a new method, add a check missing that caused a segfault if a loop didn't
have a canonical indvar llvm-svn: 13032
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 87c0723312d..38b9c669999 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -315,6 +315,19 @@ void LoopInfo::changeTopLevelLoop(Loop *OldLoop, Loop *NewLoop) {
"Loops already embedded into a subloop!");
}
+/// removeLoop - This removes the specified top-level loop from this loop info
+/// object. The loop is not deleted, as it will presumably be inserted into
+/// another loop.
+Loop *LoopInfo::removeLoop(iterator I) {
+ assert(I != end() && "Cannot remove end iterator!");
+ Loop *L = *I;
+ assert(L->getParentLoop() == 0 && "Not a top-level loop!");
+ TopLevelLoops.erase(TopLevelLoops.begin() + (I-begin()));
+ return L;
+}
+
+
+
//===----------------------------------------------------------------------===//
// APIs for simple analysis of the loop.
//
@@ -409,6 +422,7 @@ Value *Loop::getTripCount() const {
// Canonical loops will end with a 'setne I, V', where I is the incremented
// canonical induction variable and V is the trip count of the loop.
Instruction *Inc = getCanonicalInductionVariableIncrement();
+ if (Inc == 0) return 0;
PHINode *IV = cast<PHINode>(Inc->getOperand(0));
BasicBlock *BackedgeBlock =
OpenPOWER on IntegriCloud