llvm.org GIT mirror llvm / 28552da
Fix PR 1526. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37780 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 12 years ago
2 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-as < %s | opt -analyze -inline -disable-output
1 ; PR 1526
2 define i32 @test1() {
3 ret i32 0;
4 }
1313
1414 #include "llvm/Module.h"
1515 #include "llvm/PassManager.h"
16 #include "llvm/CallGraphSCCPass.h"
1617 #include "llvm/Bitcode/ReaderWriter.h"
1718 #include "llvm/Assembly/PrintModulePass.h"
1819 #include "llvm/Analysis/Verifier.h"
1920 #include "llvm/Analysis/LoopPass.h"
21 #include "llvm/Analysis/CallGraph.h"
2022 #include "llvm/Target/TargetData.h"
2123 #include "llvm/Target/TargetMachine.h"
2224 #include "llvm/Support/PassNameParser.h"
9294
9395 // ---------- Define Printers for module and function passes ------------
9496 namespace {
97
98 struct CallGraphSCCPassPrinter : public CallGraphSCCPass {
99 static char ID;
100 const PassInfo *PassToPrint;
101 CallGraphSCCPassPrinter(const PassInfo *PI) :
102 CallGraphSCCPass((intptr_t)&ID), PassToPrint(PI) {}
103
104 virtual bool runOnSCC(const std::vector&SCC) {
105 if (!Quiet) {
106 cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
107
108 for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
109 Function *F = SCC[i]->getFunction();
110 if (F)
111 getAnalysisID(PassToPrint).print(cout, F->getParent());
112 }
113 }
114 // Get and print pass...
115 return false;
116 }
117
118 virtual const char *getPassName() const { return "'Pass' Printer"; }
119
120 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
121 AU.addRequiredID(PassToPrint);
122 AU.setPreservesAll();
123 }
124 };
125
126 char CallGraphSCCPassPrinter::ID = 0;
95127
96128 struct ModulePassPrinter : public ModulePass {
97129 static char ID;
341373 Passes.add(new BasicBlockPassPrinter(PassInf));
342374 else if (dynamic_cast(P))
343375 Passes.add(new FunctionPassPrinter(PassInf));
376 else if (dynamic_cast(P))
377 Passes.add(new CallGraphSCCPassPrinter(PassInf));
344378 else
345379 Passes.add(new ModulePassPrinter(PassInf));
346380 }