<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - -print-after-all banner not printed following r292442"
   href="https://bugs.llvm.org/show_bug.cgi?id=32207">32207</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-print-after-all banner not printed following r292442
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>yaron.keren@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mehdi.amini@apple.com, mehdi.amini@silkan.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ 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;
    }</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>