Use a module analysis

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3133 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-07-29 23:02:25 +00:00
parent 0b0554596e
commit 1ad4436cc2

View File

@ -19,17 +19,22 @@
struct ModulePassPrinter : public Pass { struct ModulePassPrinter : public Pass {
Pass *PassToPrint; const PassInfo *PassToPrint;
ModulePassPrinter(Pass *PI) : PassToPrint(PI) {} ModulePassPrinter(const PassInfo *PI) : PassToPrint(PI) {}
virtual bool run(Module &M) { virtual bool run(Module &M) {
std::cout << "Printing Analysis info for Pass " std::cout << "Printing Analysis info for Pass "
<< PassToPrint->getPassName() << ":\n"; << PassToPrint->getPassName() << ":\n";
PassToPrint->print(std::cout, &M); getAnalysis<Pass>(PassToPrint).print(std::cout, &M);
// Get and print pass... // Get and print pass...
return false; return false;
} }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired(PassToPrint);
AU.setPreservesAll();
}
}; };
struct FunctionPassPrinter : public FunctionPass { struct FunctionPassPrinter : public FunctionPass {
@ -122,7 +127,7 @@ int main(int argc, char **argv) {
else if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P)) else if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P))
Passes.add(new FunctionPassPrinter(Analysis)); Passes.add(new FunctionPassPrinter(Analysis));
else else
Passes.add(new ModulePassPrinter(P)); Passes.add(new ModulePassPrinter(Analysis));
} else } else
cerr << "Cannot create pass: " << Analysis->getPassName() << "\n"; cerr << "Cannot create pass: " << Analysis->getPassName() << "\n";