diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2018-10-09 04:30:23 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2018-10-09 04:30:23 +0000 |
commit | d46f580986360d5202c7d3b435021ae4951b6fbb (patch) | |
tree | 2ae26e7afd896cbba62371457bb6d523d25fc892 /llvm/lib/Analysis | |
parent | f96e618017c3ca74934a7e8ef941e346c31e5092 (diff) | |
download | bcm5719-llvm-d46f580986360d5202c7d3b435021ae4951b6fbb.tar.gz bcm5719-llvm-d46f580986360d5202c7d3b435021ae4951b6fbb.zip |
[CFG Printer] Add support for writing the dot files with a custom
prefix.
Use this to direct these files to a specific location in the test suite
so that we don't write files out to random directories (or fail if the
working directory isn't writable).
llvm-svn: 344014
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/CFGPrinter.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/CFGPrinter.cpp b/llvm/lib/Analysis/CFGPrinter.cpp index 5b170dfa790..6d01e9d5d44 100644 --- a/llvm/lib/Analysis/CFGPrinter.cpp +++ b/llvm/lib/Analysis/CFGPrinter.cpp @@ -7,9 +7,10 @@ // //===----------------------------------------------------------------------===// // -// This file defines a '-dot-cfg' analysis pass, which emits the -// cfg.<fnname>.dot file for each function in the program, with a graph of the -// CFG for that function. +// This file defines a `-dot-cfg` analysis pass, which emits the +// `<prefix>.<fnname>.dot` file for each function in the program, with a graph +// of the CFG for that function. The default value for `<prefix>` is `cfg` but +// can be customized as needed. // // The other main feature of this file is that it implements the // Function::viewCFG method, which is useful for debugging passes which operate @@ -27,6 +28,10 @@ static cl::opt<std::string> CFGFuncName( cl::desc("The name of a function (or its substring)" " whose CFG is viewed/printed.")); +static cl::opt<std::string> CFGDotFilenamePrefix( + "cfg-dot-filename-prefix", cl::Hidden, + cl::desc("The prefix used for the CFG dot file names.")); + namespace { struct CFGViewerLegacyPass : public FunctionPass { static char ID; // Pass identifcation, replacement for typeid @@ -90,7 +95,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(); + std::string Filename = + (CFGDotFilenamePrefix + "." + F.getName() + ".dot").str(); errs() << "Writing '" << Filename << "'..."; std::error_code EC; |