[llvm] [LegacyPM] Print banner with newline when filter-print-funcs is given. (PR #153699)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 15:09:43 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: Tyler Lanphear (tylanphear)

<details>
<summary>Changes</summary>

When using the legacy PM, if `-filter-print-funcs` is given with `-print-after-all`, the banner is printed without a newline for the first function printed, e.g:

```
*** IR Dump After Function Integration/Inlining (inline) ***; Function attrs:
define @<!-- -->foo() {
...
```

instead of the correct output:

```
*** IR Dump After Function Integration/Inlining (inline) ***
; Function attrs:
define @<!-- -->foo() {
...
```

This patch fixes the behavior by changing `PrintBannerOnce()` to emit a newline after the banner unconditionally.

---
Full diff: https://github.com/llvm/llvm-project/pull/153699.diff


1 Files Affected:

- (modified) llvm/lib/Analysis/CallGraphSCCPass.cpp (+2-4) 


``````````diff
diff --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp
index de64fdb9548e6..91370f6dad002 100644
--- a/llvm/lib/Analysis/CallGraphSCCPass.cpp
+++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp
@@ -678,14 +678,13 @@ namespace {
       auto PrintBannerOnce = [&]() {
         if (BannerPrinted)
           return;
-        OS << Banner;
+        OS << Banner << "\n";
         BannerPrinted = true;
       };
 
       bool NeedModule = llvm::forcePrintModuleIR();
       if (isFunctionInPrintList("*") && NeedModule) {
         PrintBannerOnce();
-        OS << "\n";
         SCC.getCallGraph().getModule().print(OS, nullptr);
         return false;
       }
@@ -701,12 +700,11 @@ namespace {
           }
         } else if (isFunctionInPrintList("*")) {
           PrintBannerOnce();
-          OS << "\nPrinting <null> Function\n";
+          OS << "Printing <null> Function\n";
         }
       }
       if (NeedModule && FoundFunction) {
         PrintBannerOnce();
-        OS << "\n";
         SCC.getCallGraph().getModule().print(OS, nullptr);
       }
       return false;

``````````

</details>


https://github.com/llvm/llvm-project/pull/153699


More information about the llvm-commits mailing list