[llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp

Devang Patel dpatel at apple.com
Thu Feb 22 00:56:34 PST 2007



Changes in directory llvm/lib/Analysis:

LoopPass.cpp added (r1.1)
---
Log message:

Add Loop Pass Manager.


---
Diffs of the changes:  (+69 -0)

 LoopPass.cpp |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+)


Index: llvm/lib/Analysis/LoopPass.cpp
diff -c /dev/null llvm/lib/Analysis/LoopPass.cpp:1.1
*** /dev/null	Thu Feb 22 02:56:27 2007
--- llvm/lib/Analysis/LoopPass.cpp	Thu Feb 22 02:56:17 2007
***************
*** 0 ****
--- 1,69 ----
+ //===- LoopPass.cpp - Loop Pass and Loop Pass Manager ---------------------===//
+ //
+ //                     The LLVM Compiler Infrastructure
+ //
+ // This file was developed by Devang Patel and is distributed under
+ // the University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This file implements LoopPass and LPPassManager. All loop optimization
+ // and transformation passes are derived from LoopPass. LPPassManager is
+ // responsible for managing LoopPasses.
+ //
+ //===----------------------------------------------------------------------===//
+ 
+ #include "llvm/Analysis/LoopPass.h"
+ using namespace llvm;
+ 
+ //===----------------------------------------------------------------------===//
+ // LPPassManager
+ //
+ /// LPPassManager manages FPPassManagers and CalLGraphSCCPasses.
+ 
+ /// 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) {
+   LoopInfo &LI = getAnalysis<LoopInfo>();
+   bool Changed = false;
+ 
+   std::string Msg1 = "Executing Pass '";
+   std::string Msg3 = "' Made Modification '";
+ 
+   // Walk Loops
+   for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I) {
+ 
+     Loop *L  = *I;
+     // Run all passes on current SCC
+     for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {  
+ 
+       Pass *P = getContainedPass(Index);
+       AnalysisUsage AnUsage;
+       P->getAnalysisUsage(AnUsage);
+ 
+       std::string Msg2 = "' on Loop ...\n'";
+       dumpPassInfo(P, Msg1, Msg2);
+       dumpAnalysisSetInfo("Required", P, AnUsage.getRequiredSet());
+ 
+       initializeAnalysisImpl(P);
+ 
+       StartPassTimer(P);
+       LoopPass *LP = dynamic_cast<LoopPass *>(P);
+       assert (LP && "Invalid LPPassManager member");
+       LP->runOnLoop(*L, *this);
+       StopPassTimer(P);
+ 
+       if (Changed)
+ 	dumpPassInfo(P, Msg3, Msg2);
+       dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet());
+       
+       removeNotPreservedAnalysis(P);
+       recordAvailableAnalysis(P);
+       removeDeadPasses(P, Msg2);
+     }
+   }
+ 
+   return Changed;
+ }
+ 
+ 






More information about the llvm-commits mailing list