From f6d1d2135598856920f91c9d1d57e21dbc25fa9b Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 14 Dec 2006 00:25:06 +0000 Subject: [PATCH] Add debug-pass=Details support to print Required and Preserved Set info. llvm-svn: 32573 --- llvm/lib/VMCore/PassManager.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/llvm/lib/VMCore/PassManager.cpp b/llvm/lib/VMCore/PassManager.cpp index add056b280ba..95941043437f 100644 --- a/llvm/lib/VMCore/PassManager.cpp +++ b/llvm/lib/VMCore/PassManager.cpp @@ -321,6 +321,17 @@ public: cerr << Msg2; } + void dumpAnalysisSetInfo(const char *Msg, Pass *P, + const std::vector &Set) { + if (PassDebugging_New >= Details && !Set.empty()) { + cerr << (void*)P << std::string(getDepth()*2+3, ' ') << Msg << " Analyses:"; + for (unsigned i = 0; i != Set.size(); ++i) { + if (i) cerr << ","; + cerr << " " << Set[i]->getPassName(); + } + cerr << "\n"; + } + } protected: // Collection of pass whose last user asked this manager to claim @@ -925,8 +936,13 @@ BasicBlockPassManager::runOnFunction(Function &F) { for (std::vector::iterator itr = passVectorBegin(), e = passVectorEnd(); itr != e; ++itr) { Pass *P = *itr; + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); + std::string Msg2 = "' on BasicBlock '" + (*I).getName() + "'...\n"; dumpPassInfo(P, Msg1, Msg2); + dumpAnalysisSetInfo("Required", P, AnUsage.getRequiredSet()); + initializeAnalysisImpl(P); BasicBlockPass *BP = dynamic_cast(P); @@ -934,6 +950,7 @@ BasicBlockPassManager::runOnFunction(Function &F) { if (Changed) dumpPassInfo(P, Msg3, Msg2); + dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet()); removeNotPreservedAnalysis(P); recordAvailableAnalysis(P); @@ -1154,9 +1171,12 @@ bool FunctionPassManagerImpl_New::runOnFunction(Function &F) { for (std::vector::iterator itr = passVectorBegin(), e = passVectorEnd(); itr != e; ++itr) { Pass *P = *itr; + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); std::string Msg2 = "' on Function '" + F.getName() + "'...\n"; dumpPassInfo(P, Msg1, Msg2); + dumpAnalysisSetInfo("Required", P, AnUsage.getRequiredSet()); initializeAnalysisImpl(P); FunctionPass *FP = dynamic_cast(P); @@ -1164,6 +1184,7 @@ bool FunctionPassManagerImpl_New::runOnFunction(Function &F) { if (Changed) dumpPassInfo(P, Msg3, Msg2); + dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet()); removeNotPreservedAnalysis(P); recordAvailableAnalysis(P); @@ -1294,9 +1315,12 @@ ModulePassManager::runOnModule(Module &M) { for (std::vector::iterator itr = passVectorBegin(), e = passVectorEnd(); itr != e; ++itr) { Pass *P = *itr; + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); std::string Msg2 = "' on Module '" + M.getModuleIdentifier() + "'...\n"; dumpPassInfo(P, Msg1, Msg2); + dumpAnalysisSetInfo("Required", P, AnUsage.getRequiredSet()); initializeAnalysisImpl(P); ModulePass *MP = dynamic_cast(P); @@ -1304,7 +1328,8 @@ ModulePassManager::runOnModule(Module &M) { if (Changed) dumpPassInfo(P, Msg3, Msg2); - + dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet()); + removeNotPreservedAnalysis(P); recordAvailableAnalysis(P); removeDeadPasses(P, Msg2);