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
This commit is contained in:
Chris Lattner 2002-07-30 19:51:02 +00:00
parent 55b45bfae3
commit 48c1bc7b3a
2 changed files with 35 additions and 9 deletions

View File

@ -126,6 +126,19 @@ TimingInfo::~TimingInfo() {
}
void PMDebug::PrintArgumentInformation(const Pass *P) {
// Print out passes in pass manager...
if (const AnalysisResolver *PM = dynamic_cast<const AnalysisResolver*>(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) {

View File

@ -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<enum PassDebugLevel>
@ -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<AnalysisID> &);
@ -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