Add loop info verification mechanism.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37822 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2007-06-29 23:13:42 +00:00
parent d933fa9507
commit 1a957d563f
2 changed files with 18 additions and 1 deletions

View File

@ -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;

View File

@ -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);
}