From ebc0922eeb5b728d33a68d4bea8128413f62e369 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 12 Dec 2006 23:34:33 +0000 Subject: [PATCH] Add routines to dump pass manager queue. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32513 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/PassManager.cpp | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index bc469d33115..ffa9167a4a9 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -149,6 +149,9 @@ public: IndirectPassManagers.push_back(Manager); } + // Print passes managed by this top level manager. + void dumpPasses(); + private: /// Collection of pass managers @@ -231,6 +234,21 @@ public: unsigned getDepth() { return Depth; } + // Print list of passes that are last used by P. + void dumpLastUses(Pass *P, unsigned Offset) { + + std::vector LUses; + + assert (TPM && "Top Level Manager is missing"); + TPM->collectLastUses(LUses, P); + + for (std::vector::iterator I = LUses.begin(), + E = LUses.end(); I != E; ++I) { + llvm::cerr << "--" << std::string(Offset*2, ' '); + (*I)->dumpPassStructure(0); + } + } + protected: // Collection of pass whose last user asked this manager to claim @@ -283,6 +301,16 @@ public: bool doFinalization(Module &M); bool doFinalization(Function &F); + // Print passes managed by this manager + void dumpPassStructure(unsigned Offset) { + llvm::cerr << std::string(Offset*2, ' ') << "BasicBLockPass Manager\n"; + for (std::vector::iterator I = passVectorBegin(), + E = passVectorEnd(); I != E; ++I) { + (*I)->dumpPassStructure(Offset + 1); + dumpLastUses(*I, Offset+1); + } + } + }; //===----------------------------------------------------------------------===// @@ -349,6 +377,16 @@ public: Info.setPreservesAll(); } + // Print passes managed by this manager + void dumpPassStructure(unsigned Offset) { + llvm::cerr << std::string(Offset*2, ' ') << "FunctionPass Manager\n"; + for (std::vector::iterator I = passVectorBegin(), + E = passVectorEnd(); I != E; ++I) { + (*I)->dumpPassStructure(Offset + 1); + dumpLastUses(*I, Offset+1); + } + } + private: // Active Pass Managers BasicBlockPassManager_New *activeBBPassManager; @@ -380,6 +418,16 @@ public: Info.setPreservesAll(); } + // Print passes managed by this manager + void dumpPassStructure(unsigned Offset) { + llvm::cerr << std::string(Offset*2, ' ') << "ModulePass Manager\n"; + for (std::vector::iterator I = passVectorBegin(), + E = passVectorEnd(); I != E; ++I) { + (*I)->dumpPassStructure(Offset + 1); + dumpLastUses(*I, Offset+1); + } + } + private: // Active Pass Manager FunctionPassManagerImpl_New *activeFunctionPassManager; @@ -539,6 +587,20 @@ Pass *PMTopLevelManager::findAnalysisPass(AnalysisID AID) { return P; } +// Print passes managed by this top level manager. +void PMTopLevelManager::dumpPasses() { + + // Print out the immutable passes + for (unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i) { + ImmutablePasses[i]->dumpPassStructure(0); + } + + for (std::vector::iterator I = PassManagers.begin(), + E = PassManagers.end(); I != E; ++I) + (*I)->dumpPassStructure(1); + +} + //===----------------------------------------------------------------------===// // PMDataManager implementation