summaryrefslogtreecommitdiffstats
path: root/lib/Analysis/LoopPass.cpp
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-10-14 17:57:32 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-10-14 17:57:32 +0000
commitcd749a9c07f1de2fb8affde90537efa4bc3e7c54 (patch)
treeb21f6de4e08b89bb7931806bab798fc2a5e3a686 /lib/Analysis/LoopPass.cpp
parent72621d11de5b873f1695f391eb95f0b336c3d2d4 (diff)
downloadFreeBSD-src-cd749a9c07f1de2fb8affde90537efa4bc3e7c54.zip
FreeBSD-src-cd749a9c07f1de2fb8affde90537efa4bc3e7c54.tar.gz
Update llvm to r84119.
Diffstat (limited to 'lib/Analysis/LoopPass.cpp')
-rw-r--r--lib/Analysis/LoopPass.cpp60
1 files changed, 44 insertions, 16 deletions
diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp
index ee03556..43463cd 100644
--- a/lib/Analysis/LoopPass.cpp
+++ b/lib/Analysis/LoopPass.cpp
@@ -21,7 +21,6 @@ using namespace llvm;
//
char LPPassManager::ID = 0;
-/// LPPassManager manages FPPassManagers and CalLGraphSCCPasses.
LPPassManager::LPPassManager(int Depth)
: FunctionPass(&ID), PMDataManager(Depth) {
@@ -111,17 +110,21 @@ void LPPassManager::insertLoop(Loop *L, Loop *ParentLoop) {
else
LI->addTopLevelLoop(L);
+ insertLoopIntoQueue(L);
+}
+
+void LPPassManager::insertLoopIntoQueue(Loop *L) {
// Insert L into loop queue
if (L == CurrentLoop)
redoLoop(L);
- else if (!ParentLoop)
+ else if (!L->getParentLoop())
// This is top level loop.
LQ.push_front(L);
else {
- // Insert L after ParentLoop
+ // Insert L after the parent loop.
for (std::deque<Loop *>::iterator I = LQ.begin(),
E = LQ.end(); I != E; ++I) {
- if (*I == ParentLoop) {
+ if (*I == L->getParentLoop()) {
// deque does not support insert after.
++I;
LQ.insert(I, 1, L);
@@ -217,41 +220,66 @@ bool LPPassManager::runOnFunction(Function &F) {
skipThisLoop = false;
redoThisLoop = false;
- // Run all passes on current SCC
+ // Run all passes on the current Loop.
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
Pass *P = getContainedPass(Index);
- dumpPassInfo(P, EXECUTION_MSG, ON_LOOP_MSG, "");
+ dumpPassInfo(P, EXECUTION_MSG, ON_LOOP_MSG,
+ CurrentLoop->getHeader()->getNameStr());
dumpRequiredSet(P);
initializeAnalysisImpl(P);
LoopPass *LP = dynamic_cast<LoopPass *>(P);
+ assert(LP && "Invalid LPPassManager member");
{
PassManagerPrettyStackEntry X(LP, *CurrentLoop->getHeader());
- StartPassTimer(P);
- assert(LP && "Invalid LPPassManager member");
+ Timer *T = StartPassTimer(P);
Changed |= LP->runOnLoop(CurrentLoop, *this);
- StopPassTimer(P);
+ StopPassTimer(P, T);
}
if (Changed)
- dumpPassInfo(P, MODIFICATION_MSG, ON_LOOP_MSG, "");
+ dumpPassInfo(P, MODIFICATION_MSG, ON_LOOP_MSG,
+ skipThisLoop ? "<deleted>" :
+ CurrentLoop->getHeader()->getNameStr());
dumpPreservedSet(P);
- verifyPreservedAnalysis(LP);
+ if (!skipThisLoop) {
+ // Manually check that this loop is still healthy. This is done
+ // instead of relying on LoopInfo::verifyLoop since LoopInfo
+ // is a function pass and it's really expensive to verify every
+ // loop in the function every time. That level of checking can be
+ // enabled with the -verify-loop-info option.
+ Timer *T = StartPassTimer(LI);
+ CurrentLoop->verifyLoop();
+ StopPassTimer(LI, T);
+
+ // Then call the regular verifyAnalysis functions.
+ verifyPreservedAnalysis(LP);
+ }
+
removeNotPreservedAnalysis(P);
recordAvailableAnalysis(P);
- removeDeadPasses(P, "", ON_LOOP_MSG);
-
- // If dominator information is available then verify the info if requested.
- verifyDomInfo(*LP, F);
+ removeDeadPasses(P,
+ skipThisLoop ? "<deleted>" :
+ CurrentLoop->getHeader()->getNameStr(),
+ ON_LOOP_MSG);
if (skipThisLoop)
// Do not run other passes on this loop.
break;
}
+ // If the loop was deleted, release all the loop passes. This frees up
+ // some memory, and avoids trouble with the pass manager trying to call
+ // verifyAnalysis on them.
+ if (skipThisLoop)
+ for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
+ Pass *P = getContainedPass(Index);
+ freePass(P, "<deleted>", ON_LOOP_MSG);
+ }
+
// Pop the loop from queue after running all passes.
LQ.pop_back();
@@ -272,7 +300,7 @@ bool LPPassManager::runOnFunction(Function &F) {
/// Print passes managed by this manager
void LPPassManager::dumpPassStructure(unsigned Offset) {
- llvm::cerr << std::string(Offset*2, ' ') << "Loop Pass Manager\n";
+ errs().indent(Offset*2) << "Loop Pass Manager\n";
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
Pass *P = getContainedPass(Index);
P->dumpPassStructure(Offset + 1);
OpenPOWER on IntegriCloud