aboutsummaryrefslogtreecommitdiffstats
path: root/tools/opt/opt.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-07-05 15:32:03 +0000
committerDevang Patel <dpatel@apple.com>2007-07-05 15:32:03 +0000
commit56fb16454066f9a901ffb7573f44c9008b0f3117 (patch)
tree56bec05046488071e6f21c3d4341a185e853728e /tools/opt/opt.cpp
parent14da32a486f31ba695de9080830e6fadf4942d5b (diff)
downloadexternal_llvm-56fb16454066f9a901ffb7573f44c9008b0f3117.zip
external_llvm-56fb16454066f9a901ffb7573f44c9008b0f3117.tar.gz
external_llvm-56fb16454066f9a901ffb7573f44c9008b0f3117.tar.bz2
Fix PR1539. Add LoopPassPrinter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37909 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/opt/opt.cpp')
-rw-r--r--tools/opt/opt.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index e6ff5ec..ace0d3c 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -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))