[PATCH] D109630: [CFGPrinter] Fix CFGPrinter that specifying function names does not work

Congzhe Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 10 13:58:10 PDT 2021


congzhe created this revision.
Herald added a subscriber: hiraditya.
congzhe requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The option that -view-cfg -cfg-func-name=<string> is supposed to print the cfg only for function with names contained in <string>, but currently it does not work and all functions in the IR will be printed out which causes inconvenience.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109630

Files:
  llvm/lib/Analysis/CFGPrinter.cpp


Index: llvm/lib/Analysis/CFGPrinter.cpp
===================================================================
--- llvm/lib/Analysis/CFGPrinter.cpp
+++ llvm/lib/Analysis/CFGPrinter.cpp
@@ -84,6 +84,8 @@
 static void viewCFG(Function &F, const BlockFrequencyInfo *BFI,
                     const BranchProbabilityInfo *BPI, uint64_t MaxFreq,
                     bool CFGOnly = false) {
+  if (!CFGFuncName.emtpy() && !F.getName().contains(CFGFuncName))
+	return;
   DOTFuncInfo CFGInfo(&F, BFI, BPI, MaxFreq);
   CFGInfo.setHeatColors(ShowHeatColors);
   CFGInfo.setEdgeWeights(ShowEdgeWeight);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109630.372009.patch
Type: text/x-patch
Size: 592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210910/869406ce/attachment.bin>


More information about the llvm-commits mailing list