aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-06-29 23:13:42 +0000
committerDevang Patel <dpatel@apple.com>2007-06-29 23:13:42 +0000
commit1a957d563fe894c797e0eba00bf069fbe7ecba77 (patch)
tree693e5005e405924415c28d5ef87b5e53ae44e4e3
parentd933fa9507e1af7a0e27546d19c77dd8cc65f6e0 (diff)
Add loop info verification mechanism.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37822 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/LoopPass.h5
-rw-r--r--lib/Analysis/LoopPass.cpp14
2 files changed, 18 insertions, 1 deletions
diff --git a/include/llvm/Analysis/LoopPass.h b/include/llvm/Analysis/LoopPass.h
index 76a3018578..7a820ccc5d 100644
--- a/include/llvm/Analysis/LoopPass.h
+++ b/include/llvm/Analysis/LoopPass.h
@@ -114,6 +114,11 @@ public:
// queue. This allows LoopPass to change loop nest for the loop. This
// utility may send LPPassManager into infinite loops so use caution.
void redoLoop(Loop *L);
+
+private:
+ /// verifyLoopInfo - Verify loop nest.
+ void verifyLoopInfo();
+
private:
std::deque<Loop *> LQ;
bool skipThisLoop;
diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp
index ab64c3cf92..a5496a01f0 100644
--- a/lib/Analysis/LoopPass.cpp
+++ b/lib/Analysis/LoopPass.cpp
@@ -157,6 +157,18 @@ void LPPassManager::getAnalysisUsage(AnalysisUsage &Info) const {
Info.setPreservesAll();
}
+/// verifyLoopInfo - Verify loop nest.
+void LPPassManager::verifyLoopInfo() {
+ assert (LI && "Loop Info is missing");
+
+ for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) {
+ Loop *L = *I;
+ assert (L->getHeader() && "Loop header is missing");
+ assert (L->getLoopPreheader() && "Loop preheader is missing");
+ assert (L->getLoopLatch() && "Loop latch is missing");
+ }
+}
+
/// run - Execute all of the passes scheduled for execution. Keep track of
/// whether any of the passes modifies the function, and if so, return true.
bool LPPassManager::runOnFunction(Function &F) {
@@ -202,6 +214,7 @@ bool LPPassManager::runOnFunction(Function &F) {
LoopPass *LP = dynamic_cast<LoopPass *>(P);
assert (LP && "Invalid LPPassManager member");
LP->runOnLoop(CurrentLoop, *this);
+ verifyLoopInfo();
StopPassTimer(P);
if (Changed)
@@ -302,4 +315,3 @@ void LoopPass::assignPassManager(PMStack &PMS,
LPPM->add(this);
}
-