[PATCH] D49447: Add an option to specify function name when view/print CFG

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 25 10:22:32 PDT 2018


This revision was automatically updated to reflect the committed changes.
davidxl marked an inline comment as done.
Closed by commit rL337940: Add an option to specify the name of (authored by davidxl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49447?vs=155953&id=157303#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49447

Files:
  llvm/trunk/lib/Analysis/CFGPrinter.cpp


Index: llvm/trunk/lib/Analysis/CFGPrinter.cpp
===================================================================
--- llvm/trunk/lib/Analysis/CFGPrinter.cpp
+++ llvm/trunk/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 @@
 }
 
 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 @@
 /// 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 @@
 /// this can make the graph smaller.
 ///
 void Function::viewCFGOnly() const {
+  if (!CFGFuncName.empty() && !getName().contains(CFGFuncName))
+     return;
   ViewGraph(this, "cfg" + getName(), true);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49447.157303.patch
Type: text/x-patch
Size: 1350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180725/1c7ec0f9/attachment.bin>


More information about the llvm-commits mailing list