llvm.org GIT mirror llvm / 56fb164
Fix PR1539. Add LoopPassPrinter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37909 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 12 years ago
2 changed file(s) with 31 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-as < %s | opt -analyze -inline -disable-output
11 ; PR 1526
2 ; RUN: llvm-as < %s | opt -analyze -indvars -disable-output
3 ; PR 1539
24 define i32 @test1() {
35 ret i32 0;
46 }
175175 };
176176
177177 char FunctionPassPrinter::ID = 0;
178
179 struct LoopPassPrinter : public LoopPass {
180 static char ID;
181 const PassInfo *PassToPrint;
182 LoopPassPrinter(const PassInfo *PI) :
183 LoopPass((intptr_t)&ID), PassToPrint(PI) {}
184
185 virtual bool runOnLoop(Loop *L, LPPassManager &LPM) {
186 if (!Quiet) {
187 cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
188 getAnalysisID(PassToPrint).print(cout,
189 L->getHeader()->getParent()->getParent());
190 }
191 // Get and print pass...
192 return false;
193 }
194
195 virtual const char *getPassName() const { return "'Pass' Printer"; }
196
197 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
198 AU.addRequiredID(PassToPrint);
199 AU.setPreservesAll();
200 }
201 };
202
203 char LoopPassPrinter::ID = 0;
204
178205 struct BasicBlockPassPrinter : public BasicBlockPass {
179206 const PassInfo *PassToPrint;
180207 static char ID;
371398 if (AnalyzeOnly) {
372399 if (dynamic_cast(P))
373400 Passes.add(new BasicBlockPassPrinter(PassInf));
401 else if (dynamic_cast(P))
402 Passes.add(new LoopPassPrinter(PassInf));
374403 else if (dynamic_cast(P))
375404 Passes.add(new FunctionPassPrinter(PassInf));
376405 else if (dynamic_cast(P))