diff options
author | Dan Gohman <gohman@apple.com> | 2007-05-14 14:25:08 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2007-05-14 14:25:08 +0000 |
commit | 90d97ac1e64e2e8eba995a090e9237d2f3857e3c (patch) | |
tree | 5fd4deaa58fbb1bf30e222f9f3c8b7eca479437e /llvm/lib/Analysis | |
parent | 86110bdf06bcccc72e3fdc4c44e23d2cae0292ff (diff) | |
download | bcm5719-llvm-90d97ac1e64e2e8eba995a090e9237d2f3857e3c.tar.gz bcm5719-llvm-90d97ac1e64e2e8eba995a090e9237d2f3857e3c.zip |
Add passes -view-cfg and -view-cfg-only that are like -print-cfg and
-print-cfg-only except they use the ViewCFG function, which displays the
CFG rendered with graphviz with gv.
llvm-svn: 37033
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/CFGPrinter.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/CFGPrinter.cpp b/llvm/lib/Analysis/CFGPrinter.cpp index c98cfe4daee..cc0f6b43182 100644 --- a/llvm/lib/Analysis/CFGPrinter.cpp +++ b/llvm/lib/Analysis/CFGPrinter.cpp @@ -90,6 +90,48 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits { } namespace { + struct VISIBILITY_HIDDEN CFGViewer : public FunctionPass { + static char ID; // Pass identifcation, replacement for typeid + CFGViewer() : FunctionPass((intptr_t)&ID) {} + + virtual bool runOnFunction(Function &F) { + F.viewCFG(); + return false; + } + + void print(std::ostream &OS, const Module* = 0) const {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + }; + + char CFGViewer::ID = 0; + RegisterPass<CFGViewer> V0("view-cfg", + "View CFG of function"); + + struct VISIBILITY_HIDDEN CFGOnlyViewer : public FunctionPass { + static char ID; // Pass identifcation, replacement for typeid + CFGOnlyViewer() : FunctionPass((intptr_t)&ID) {} + + virtual bool runOnFunction(Function &F) { + CFGOnly = true; + F.viewCFG(); + CFGOnly = false; + return false; + } + + void print(std::ostream &OS, const Module* = 0) const {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + }; + + char CFGOnlyViewer::ID = 0; + RegisterPass<CFGOnlyViewer> V1("view-cfg-only", + "View CFG of function (with no function bodies)"); + struct VISIBILITY_HIDDEN CFGPrinter : public FunctionPass { static char ID; // Pass identification, replacement for typeid CFGPrinter() : FunctionPass((intptr_t)&ID) {} |