Use a module analysis

llvm-svn: 3133
This commit is contained in:
Chris Lattner 2002-07-29 23:02:25 +00:00
parent fdf6bc216f
commit 2511b6e296
1 changed files with 9 additions and 4 deletions

View File

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