[llvm-bugs] [Bug 32207] New: -print-after-all banner not printed following r292442

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 10 00:09:36 PST 2017


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: unassignedbugs at nondot.org
          Reporter: yaron.keren at gmail.com
                CC: llvm-bugs at lists.llvm.org, mehdi.amini at apple.com,
                    mehdi.amini at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170310/ea18f7a9/attachment.html>


More information about the llvm-bugs mailing list