Add preparePassManager() hook. This allows each pass to check whether
authorDevang Patel <dpatel@apple.com>
Tue, 6 Mar 2007 01:06:16 +0000 (01:06 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 6 Mar 2007 01:06:16 +0000 (01:06 +0000)
current active pass manager is appropriate or not.

A loop pass may consider current LPPassManager in appropraite if loop
pass is not preserving analysis information that is used by other
passes managed by current LPPassManager. In such situation, loop pass
can pop current LPPassManager from the PMStack using this  hook
and use new LPPassManager for itself.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34941 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Pass.h
lib/VMCore/PassManager.cpp

index af15516c72bd982ea602a981ecf2c6944453db7d..601420eb37ecbdcbded310e3859754e497cc3baf 100644 (file)
@@ -119,8 +119,13 @@ public:
   void print(std::ostream *O, const Module *M) const { if (O) print(*O, M); }
   void dump() const; // dump - call print(std::cerr, 0);
 
+  /// Each pass is responsible for assigning a pass manager to itself.
+  /// PMS is the stack of available pass manager. 
   virtual void assignPassManager(PMStack &PMS, 
                                 PassManagerType T = PMT_Unknown) {}
+  /// Check if available pass managers are suitable for this pass or not.
+  virtual void preparePassManager(PMStack &PMS) {}
+
   // Access AnalysisResolver
   inline void setResolver(AnalysisResolver *AR) { Resolver = AR; }
   inline AnalysisResolver *getResolver() { return Resolver; }
index 23a26130fc37f52c6bd34375cfbfc3bb8ea203ec..253530824338b594a7a2dce819f1b7c2f46bd053 100644 (file)
@@ -385,6 +385,9 @@ void PMTopLevelManager::schedulePass(Pass *P) {
   if (findAnalysisPass(P->getPassInfo()))
       return;
 
+  // Give pass a chance to prepare the stage.
+  P->preparePassManager(activeStack);
+
   AnalysisUsage AnUsage;
   P->getAnalysisUsage(AnUsage);
   const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();