[llvm] r337940 - Add an option to specify the name of
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 25 10:22:12 PDT 2018
Author: davidxl
Date: Wed Jul 25 10:22:12 2018
New Revision: 337940
URL: http://llvm.org/viewvc/llvm-project?rev=337940&view=rev
Log:
Add an option to specify the name of
an function whose CFG is to be viewed/printed.
Differential Revision: https://reviews.llvm.org/D49447
Modified:
llvm/trunk/lib/Analysis/CFGPrinter.cpp
Modified: llvm/trunk/lib/Analysis/CFGPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CFGPrinter.cpp?rev=337940&r1=337939&r2=337940&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CFGPrinter.cpp (original)
+++ llvm/trunk/lib/Analysis/CFGPrinter.cpp Wed Jul 25 10:22:12 2018
@@ -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
}
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::ru
/// 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);
}
More information about the llvm-commits
mailing list