1 //===- LoopPass.cpp - Loop Pass and Loop Pass Manager ---------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Devang Patel and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements LoopPass and LPPassManager. All loop optimization
11 // and transformation passes are derived from LoopPass. LPPassManager is
12 // responsible for managing LoopPasses.
14 //===----------------------------------------------------------------------===//
16 #include "llvm/Analysis/LoopPass.h"
19 //===----------------------------------------------------------------------===//
22 /// LPPassManager manages FPPassManagers and CalLGraphSCCPasses.
24 /// run - Execute all of the passes scheduled for execution. Keep track of
25 /// whether any of the passes modifies the function, and if so, return true.
26 bool LPPassManager::runOnFunction(Function &F) {
27 LoopInfo &LI = getAnalysis<LoopInfo>();
30 std::string Msg1 = "Executing Pass '";
31 std::string Msg3 = "' Made Modification '";
34 for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I) {
37 // Run all passes on current SCC
38 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
40 Pass *P = getContainedPass(Index);
41 AnalysisUsage AnUsage;
42 P->getAnalysisUsage(AnUsage);
44 std::string Msg2 = "' on Loop ...\n'";
45 dumpPassInfo(P, Msg1, Msg2);
46 dumpAnalysisSetInfo("Required", P, AnUsage.getRequiredSet());
48 initializeAnalysisImpl(P);
51 LoopPass *LP = dynamic_cast<LoopPass *>(P);
52 assert (LP && "Invalid LPPassManager member");
53 LP->runOnLoop(*L, *this);
57 dumpPassInfo(P, Msg3, Msg2);
58 dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet());
60 removeNotPreservedAnalysis(P);
61 recordAvailableAnalysis(P);
62 removeDeadPasses(P, Msg2);