[clang] [llvm] [Passes] Add StandardInstrumentation to runCodeGenPipeline (PR #238671)
Aiden Grossman via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 3 21:22:14 PST 2026
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/238671
Otherwise tools like -print-after-all do not work. Add a regression test in clang given we do not directly call this function from anywhere in LLVM yet.
>From b66448a23e2c20bb5d36605cde70babf784fc544 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Wed, 4 Nov 2026 05:20:43 +0000
Subject: [PATCH] [Passes] Add StandardInstrumentation to runCodeGenPipeline
Otherwise tools like -print-after-all do not work. Add a regression test
in clang given we do not directly call this function from anywhere in
LLVM yet.
---
clang/test/Misc/codegen-printer.c | 7 +++++++
llvm/lib/Passes/RunCodeGen.cpp | 4 ++++
2 files changed, 11 insertions(+)
create mode 100644 clang/test/Misc/codegen-printer.c
diff --git a/clang/test/Misc/codegen-printer.c b/clang/test/Misc/codegen-printer.c
new file mode 100644
index 00000000000000..ed1ce73d5ee616
--- /dev/null
+++ b/clang/test/Misc/codegen-printer.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -O3 -S -mllvm -print-after-all \
+// RUN: -mllvm -force-new-pm-codegen -o %t 2>&1 | FileCheck %s
+
+// CHECK: *** IR Dump After CodeGenPreparePass
+// CHECK: *** IR Dump After X86AsmPrinterPas
+
+void foo() {}
diff --git a/llvm/lib/Passes/RunCodeGen.cpp b/llvm/lib/Passes/RunCodeGen.cpp
index 67aecdb6f5494c..d66b62ca3ac27c 100644
--- a/llvm/lib/Passes/RunCodeGen.cpp
+++ b/llvm/lib/Passes/RunCodeGen.cpp
@@ -18,6 +18,7 @@
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
@@ -75,6 +76,9 @@ static Error runCodeGenPipelineNewPM(TargetMachine &TM, Module &M,
PB.registerMachineFunctionAnalyses(MFAM);
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM, &MFAM);
+ StandardInstrumentations SI(M.getContext(), /*DebugLogging=*/false);
+ SI.registerCallbacks(PIC, &MAM);
+
MAM.registerPass([&] { return MachineModuleAnalysis(MMI); });
Error BuildPipelineError = TM.buildCodeGenPipeline(
More information about the cfe-commits
mailing list