https://bugs.llvm.org/show_bug.cgi?id=32207

            Bug ID: 32207
           Summary: -print-after-all banner not printed following r292442
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: yaron.ke...@gmail.com
                CC: llvm-bugs@lists.llvm.org, mehdi.am...@apple.com,
                    mehdi.am...@silkan.com

$ cat a.cpp
void foo() {}
$ clang -c -O a.cpp -mllvm -print-after-all |& grep unused
*** IR Dump After Remove unused exception handling info ***
$ clang -c -O a.cpp -mllvm -print-after-all |& grep inlining
$ clang -v
clang version 5.0.0 (trunk 294982)

the problem is static bool BannerPrinted is shared across *all*
PrintCallGraphPass passes so only the first pass (Remove unused exception
handling info) prints its banner.

To achieve one BannerPrinted per non-empty SCC, it should be non static local
to runOnSCC:

    bool runOnSCC(CallGraphSCC &SCC) override {
      bool BannerPrinted = false;
      auto PrintBannerOnce = [&] () {
        if (BannerPrinted)
          return;
        Out << Banner;
        BannerPrinted = true;
        };
      for (CallGraphNode *CGN : SCC) {
        if (CGN->getFunction()) {
          if (isFunctionInPrintList(CGN->getFunction()->getName())) {
            PrintBannerOnce();
            CGN->getFunction()->print(Out);
          }
        } else if (llvm::isFunctionInPrintList("*")) {
          PrintBannerOnce();
          Out << "\nPrinting <null> Function\n";
        }
      }
      return false;
    }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to