[llvm] Emit newline after IR-dump banner in PrintCallGraphPass (PR #199410)

Prerona Chaudhuri via llvm-commits llvm-commits at lists.llvm.org
Wed May 27 21:55:21 PDT 2026


https://github.com/pchaudhuri-nv updated https://github.com/llvm/llvm-project/pull/199410

>From b517f8909e04c84be27515b6e462bbf59a30fdf3 Mon Sep 17 00:00:00 2001
From: pchaudhuri-nv <pchaudhuri at nvidia.com>
Date: Sun, 24 May 2026 09:14:19 +0000
Subject: [PATCH] Emit newline after IR-dump banner in PrintCallGraphPass

Required for Compiler Explorer's opt-pipeline viewer: the tool parses
pass output by splitting on the IR-dump banner line, so the banner must
end with a newline. Without it, targets that exercise this pass cannot
be inspected through the opt-pipeline feature.

Assisted by Claude.
---
 llvm/lib/Analysis/CallGraphSCCPass.cpp               |  2 +-
 llvm/test/Other/legacy-callgraph-scc-pass-printer.ll | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/Other/legacy-callgraph-scc-pass-printer.ll

diff --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp
index 9213ea8ea2383..3fd2fe02f6688 100644
--- a/llvm/lib/Analysis/CallGraphSCCPass.cpp
+++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp
@@ -678,7 +678,7 @@ namespace {
       auto PrintBannerOnce = [&]() {
         if (BannerPrinted)
           return;
-        OS << Banner;
+        OS << Banner << "\n";
         BannerPrinted = true;
       };
 
diff --git a/llvm/test/Other/legacy-callgraph-scc-pass-printer.ll b/llvm/test/Other/legacy-callgraph-scc-pass-printer.ll
new file mode 100644
index 0000000000000..fda04f6740575
--- /dev/null
+++ b/llvm/test/Other/legacy-callgraph-scc-pass-printer.ll
@@ -0,0 +1,11 @@
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-ipra \
+; RUN:     -print-after=DummyCGSCCPass -o - %s 2>&1 | FileCheck %s
+; REQUIRES: x86-registered-target
+
+; The legacy CallGraphSCCPass printer should emit the banner as its own line.
+; CHECK-LABEL: *** IR Dump After DummyCGSCCPass (DummyCGSCCPass) ***
+; CHECK-NEXT: define void @bar() {
+
+define void @bar() {
+  ret void
+}



More information about the llvm-commits mailing list