From 48c1bc7b3a7a0ee9b30da43b83f63f210c65ee91 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 30 Jul 2002 19:51:02 +0000 Subject: [PATCH] Implement new -debug-pass=Arguments option that causes PassManager to print out the command line options for the optimizations it is running. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3165 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Pass.cpp | 13 +++++++++++++ lib/VMCore/PassManagerT.h | 31 ++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index d60a50053cf..39766e35705 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -126,6 +126,19 @@ TimingInfo::~TimingInfo() { } +void PMDebug::PrintArgumentInformation(const Pass *P) { + // Print out passes in pass manager... + if (const AnalysisResolver *PM = dynamic_cast(P)) { + for (unsigned i = 0, e = PM->getNumContainedPasses(); i != e; ++i) + PrintArgumentInformation(PM->getContainedPass(i)); + + } else { // Normal pass. Print argument information... + // Print out arguments for registered passes that are _optimizations_ + if (const PassInfo *PI = P->getPassInfo()) + if (PI->getPassType() & PassInfo::Optimization) + std::cerr << " -" << PI->getPassArgument(); + } +} void PMDebug::PrintPassInformation(unsigned Depth, const char *Action, Pass *P, Annotable *V) { diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index 555bcaae106..b4155e42a49 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -29,7 +29,7 @@ class Annotable; // Different debug levels that can be enabled... enum PassDebugLevel { - None, Structure, Executions, Details + None, Arguments, Structure, Executions, Details }; static cl::opt @@ -37,7 +37,7 @@ PassDebugging("debug-pass", cl::Hidden, cl::desc("Print PassManager debugging information"), cl::values( clEnumVal(None , "disable debug output"), - // TODO: add option to print out pass names "PassOptions" + clEnumVal(Arguments , "print pass arguments to pass to 'opt'"), clEnumVal(Structure , "print pass structure before run()"), clEnumVal(Executions, "print pass name before it is executed"), clEnumVal(Details , "print pass details when it is executed"), @@ -48,13 +48,20 @@ PassDebugging("debug-pass", cl::Hidden, // instantiated by the template. // struct PMDebug { - // If compiled in debug mode, these functions can be enabled by setting - // -debug-pass on the command line of the tool being used. - // - static void PrintPassStructure(Pass *P) { - if (PassDebugging >= Structure) - P->dumpPassStructure(); + static void PerformPassStartupStuff(Pass *P) { + // If debugging is enabled, print out argument information... + if (PassDebugging >= Arguments) { + std::cerr << "Pass Arguments: "; + PrintArgumentInformation(P); + std::cerr << "\n"; + + // Print the pass execution structure + if (PassDebugging >= Structure) + P->dumpPassStructure(); + } } + + static void PrintArgumentInformation(const Pass *P); static void PrintPassInformation(unsigned,const char*,Pass *, Annotable *); static void PrintAnalysisSetInfo(unsigned,const char*,Pass *P, const std::vector &); @@ -151,7 +158,7 @@ public: // Output debug information... - if (Parent == 0) PMDebug::PrintPassStructure(this); + if (Parent == 0) PMDebug::PerformPassStartupStuff(this); // Run all of the passes for (unsigned i = 0, e = Passes.size(); i < e; ++i) { @@ -306,6 +313,12 @@ public: return 1 + Parent->getDepth(); } + virtual unsigned getNumContainedPasses() const { return Passes.size(); } + virtual const Pass *getContainedPass(unsigned N) const { + assert(N < Passes.size() && "Pass number out of range!"); + return Passes[N]; + } + // add - Add a pass to the queue of passes to run. This passes ownership of // the Pass to the PassManager. When the PassManager is destroyed, the pass // will be destroyed as well, so there is no need to delete the pass. This