mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-25 04:39:51 +00:00
Fix PR1539. Add LoopPassPrinter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37909 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
14da32a486
commit
56fb164540
@ -1,5 +1,7 @@
|
||||
; RUN: llvm-as < %s | opt -analyze -inline -disable-output
|
||||
; PR 1526
|
||||
; RUN: llvm-as < %s | opt -analyze -indvars -disable-output
|
||||
; PR 1539
|
||||
define i32 @test1() {
|
||||
ret i32 0;
|
||||
}
|
||||
|
@ -176,6 +176,33 @@ struct FunctionPassPrinter : public FunctionPass {
|
||||
};
|
||||
|
||||
char FunctionPassPrinter::ID = 0;
|
||||
|
||||
struct LoopPassPrinter : public LoopPass {
|
||||
static char ID;
|
||||
const PassInfo *PassToPrint;
|
||||
LoopPassPrinter(const PassInfo *PI) :
|
||||
LoopPass((intptr_t)&ID), PassToPrint(PI) {}
|
||||
|
||||
virtual bool runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||
if (!Quiet) {
|
||||
cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
|
||||
getAnalysisID<Pass>(PassToPrint).print(cout,
|
||||
L->getHeader()->getParent()->getParent());
|
||||
}
|
||||
// Get and print pass...
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual const char *getPassName() const { return "'Pass' Printer"; }
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequiredID(PassToPrint);
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
};
|
||||
|
||||
char LoopPassPrinter::ID = 0;
|
||||
|
||||
struct BasicBlockPassPrinter : public BasicBlockPass {
|
||||
const PassInfo *PassToPrint;
|
||||
static char ID;
|
||||
@ -372,6 +399,8 @@ int main(int argc, char **argv) {
|
||||
if (AnalyzeOnly) {
|
||||
if (dynamic_cast<BasicBlockPass*>(P))
|
||||
Passes.add(new BasicBlockPassPrinter(PassInf));
|
||||
else if (dynamic_cast<LoopPass*>(P))
|
||||
Passes.add(new LoopPassPrinter(PassInf));
|
||||
else if (dynamic_cast<FunctionPass*>(P))
|
||||
Passes.add(new FunctionPassPrinter(PassInf));
|
||||
else if (dynamic_cast<CallGraphSCCPass*>(P))
|
||||
|
Loading…
Reference in New Issue
Block a user