aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/Pass.cpp13
-rw-r--r--lib/VMCore/PassManagerT.h31
2 files changed, 35 insertions, 9 deletions
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp
index d60a50053c..39766e3570 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<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) {
diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h
index 555bcaae10..b4155e42a4 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<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