summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/CFGPrinter.cpp
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2018-07-25 17:22:12 +0000
committerXinliang David Li <davidxl@google.com>2018-07-25 17:22:12 +0000
commit45a607e5630379dfa20ecda0297fe3c57f211b4d (patch)
treebcd6825939d43f04d9dbe8e5afcd0e12c86b9af0 /llvm/lib/Analysis/CFGPrinter.cpp
parent5f75371c5d0794cf2b92b18b5a97575b002b1ba7 (diff)
downloadbcm5719-llvm-45a607e5630379dfa20ecda0297fe3c57f211b4d.tar.gz
bcm5719-llvm-45a607e5630379dfa20ecda0297fe3c57f211b4d.zip
Add an option to specify the name of
an function whose CFG is to be viewed/printed. Differential Revision: https://reviews.llvm.org/D49447 llvm-svn: 337940
Diffstat (limited to 'llvm/lib/Analysis/CFGPrinter.cpp')
-rw-r--r--llvm/lib/Analysis/CFGPrinter.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/CFGPrinter.cpp b/llvm/lib/Analysis/CFGPrinter.cpp
index fb261755e5d..fc25cef8ddc 100644
--- a/llvm/lib/Analysis/CFGPrinter.cpp
+++ b/llvm/lib/Analysis/CFGPrinter.cpp
@@ -22,6 +22,11 @@
#include "llvm/Support/FileSystem.h"
using namespace llvm;
+static cl::opt<std::string> CFGFuncName(
+ "cfg-func-name", cl::Hidden,
+ cl::desc("The name of a function (or its substring)"
+ " whose CFG is viewed/printed."));
+
namespace {
struct CFGViewerLegacyPass : public FunctionPass {
static char ID; // Pass identifcation, replacement for typeid
@@ -83,6 +88,8 @@ PreservedAnalyses CFGOnlyViewerPass::run(Function &F,
}
static void writeCFGToDotFile(Function &F, bool CFGOnly = false) {
+ if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName))
+ return;
std::string Filename = ("cfg." + F.getName() + ".dot").str();
errs() << "Writing '" << Filename << "'...";
@@ -162,6 +169,8 @@ PreservedAnalyses CFGOnlyPrinterPass::run(Function &F,
/// being a 'dot' and 'gv' program in your path.
///
void Function::viewCFG() const {
+ if (!CFGFuncName.empty() && !getName().contains(CFGFuncName))
+ return;
ViewGraph(this, "cfg" + getName());
}
@@ -171,6 +180,8 @@ void Function::viewCFG() const {
/// this can make the graph smaller.
///
void Function::viewCFGOnly() const {
+ if (!CFGFuncName.empty() && !getName().contains(CFGFuncName))
+ return;
ViewGraph(this, "cfg" + getName(), true);
}
OpenPOWER on IntegriCloud