[llvm] r305179 - Address http://bugs.llvm.org/pr32207 by making BannerPrinted local to runOnSCC and skipping banner for function declarations.

Yaron Keren via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 11 19:18:50 PDT 2017


Author: yrnkrn
Date: Sun Jun 11 21:18:50 2017
New Revision: 305179

URL: http://llvm.org/viewvc/llvm-project?rev=305179&view=rev
Log:
Address http://bugs.llvm.org/pr32207 by making BannerPrinted local to runOnSCC and skipping banner for function declarations.

Reviewed By: Mehdi AMINI

Differential Revision: https://reviews.llvm.org/D34086


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=305179&r1=305178&r2=305179&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp (original)
+++ llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp Sun Jun 11 21:18:50 2017
@@ -608,18 +608,18 @@ namespace {
     }
 
     bool runOnSCC(CallGraphSCC &SCC) override {
+      bool BannerPrinted = false;
       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 (Function *F = CGN->getFunction()) {
+          if (!F->isDeclaration() && isFunctionInPrintList(F->getName())) {
             PrintBannerOnce();
-            CGN->getFunction()->print(Out);
+            F->print(Out);
           }
         } else if (llvm::isFunctionInPrintList("*")) {
           PrintBannerOnce();




More information about the llvm-commits mailing list