From 22a1cf9d3a5c829d260bcf44ffe6b34ecf16076c Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 6 Mar 2007 01:06:16 +0000 Subject: [PATCH] Add preparePassManager() hook. This allows each pass to check whether 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 | 5 +++++ lib/VMCore/PassManager.cpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index af15516c72b..601420eb37e 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -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; } diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 23a26130fc3..25353082433 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -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 &RequiredSet = AnUsage.getRequiredSet(); -- 2.34.1