[llvm] r292442 - Improve the `-filter-print-funcs` option to skip the banner for CGSCC pass when nothing is to be printed

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 13:37:12 PST 2017


Author: mehdi_amini
Date: Wed Jan 18 15:37:11 2017
New Revision: 292442

URL: http://llvm.org/viewvc/llvm-project?rev=292442&view=rev
Log:
Improve the `-filter-print-funcs` option to skip the banner for CGSCC pass when nothing is to be printed

Before, it would print a sequence of:

  *** IR Dump After Function Integration/Inlining ******
  *** IR Dump After Function Integration/Inlining ******
  *** IR Dump After Function Integration/Inlining ******
  ...

for every single function in the module.

Modified:
    llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp

Modified: llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp?rev=292442&r1=292441&r2=292442&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp (original)
+++ llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp Wed Jan 18 15:37:11 2017
@@ -609,13 +609,23 @@ namespace {
     }
 
     bool runOnSCC(CallGraphSCC &SCC) override {
-      Out << Banner;
+      auto PrintBannerOnce = [&] () {
+        static bool BannerPrinted = false;
+        if (BannerPrinted)
+          return;
+        Out << Banner;
+        BannerPrinted = true;
+        };
       for (CallGraphNode *CGN : SCC) {
         if (CGN->getFunction()) {
-          if (isFunctionInPrintList(CGN->getFunction()->getName()))
+          if (isFunctionInPrintList(CGN->getFunction()->getName())) {
+            PrintBannerOnce();
             CGN->getFunction()->print(Out);
-        } else
+          }
+        } else if (llvm::isFunctionInPrintList("*")) {
+          PrintBannerOnce();
           Out << "\nPrinting <null> Function\n";
+        }
       }
       return false;
     }




More information about the llvm-commits mailing list