[llvm] [llc] Respect --print-pipeline-passes when using -passes (PR #80940)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 21:45:22 PST 2024
https://github.com/aeubanks created https://github.com/llvm/llvm-project/pull/80940
None
>From 6ea5f04757763f08d1a244b19370eeeab62209fe Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Wed, 7 Feb 2024 05:43:16 +0000
Subject: [PATCH] [llc] Respect --print-pipeline-passes when using -passes
---
llvm/test/tools/llc/new-pm/pipeline.mir | 11 ++++++
llvm/tools/llc/NewPMDriver.cpp | 46 +++++++++++--------------
2 files changed, 32 insertions(+), 25 deletions(-)
create mode 100644 llvm/test/tools/llc/new-pm/pipeline.mir
diff --git a/llvm/test/tools/llc/new-pm/pipeline.mir b/llvm/test/tools/llc/new-pm/pipeline.mir
new file mode 100644
index 00000000000000..c7dda4b6d13560
--- /dev/null
+++ b/llvm/test/tools/llc/new-pm/pipeline.mir
@@ -0,0 +1,11 @@
+# RUN: llc -mtriple=x86_64-pc-linux-gnu -x mir -passes=no-op-machine-function --print-pipeline-passes -filetype=null < %s | FileCheck %s --match-full-lines
+
+# CHECK: IR pipeline: PrintMIRPreparePass
+# CHECK: MIR pipeline: no-op-machine-function,print,FreeMachineFunctionPass
+
+---
+name: f
+body: |
+ bb.0:
+ RET 0
+...
diff --git a/llvm/tools/llc/NewPMDriver.cpp b/llvm/tools/llc/NewPMDriver.cpp
index 17ce77d6034de9..7666d09f30d030 100644
--- a/llvm/tools/llc/NewPMDriver.cpp
+++ b/llvm/tools/llc/NewPMDriver.cpp
@@ -188,9 +188,6 @@ int llvm::compileModuleWithNewPM(
auto &MMI = MFAM.getResult<MachineModuleAnalysis>(*M);
if (MIR->parseMachineFunctions(*M, MMI))
return 1;
-
- RunPasses(BOS.get(), Out.get(), M.get(), Context, Buffer, &MPM, &MAM, MFPM,
- MFAM);
} else {
ExitOnErr(LLVMTM.buildCodeGenPipeline(MPM, MFPM, MFAM, *OS,
DwoOut ? &DwoOut->os() : nullptr,
@@ -198,36 +195,35 @@ int llvm::compileModuleWithNewPM(
auto StartStopInfo = TargetPassConfig::getStartStopInfo(PIC);
assert(StartStopInfo && "Expect StartStopInfo!");
- // Add IR or MIR printing pass according the pass type.
if (auto StopPassName = StartStopInfo->StopPass; !StopPassName.empty()) {
MFPM.addPass(PrintMIRPass(*OS));
MFPM.addPass(FreeMachineFunctionPass());
}
+ }
- if (PrintPipelinePasses) {
- std::string IRPipeline;
- raw_string_ostream IRSOS(IRPipeline);
- MPM.printPipeline(IRSOS, [&PIC](StringRef ClassName) {
- auto PassName = PIC.getPassNameForClassName(ClassName);
- return PassName.empty() ? ClassName : PassName;
- });
- outs() << "IR pipeline: " << IRPipeline << '\n';
-
- std::string MIRPipeline;
- raw_string_ostream MIRSOS(MIRPipeline);
- MFPM.printPipeline(MIRSOS, [&PIC](StringRef ClassName) {
- auto PassName = PIC.getPassNameForClassName(ClassName);
- return PassName.empty() ? ClassName : PassName;
- });
- outs() << "MIR pipeline: " << MIRPipeline << '\n';
- return 0;
- }
-
- RunPasses(BOS.get(), Out.get(), M.get(), Context, Buffer, &MPM, &MAM, MFPM,
- MFAM);
+ if (PrintPipelinePasses) {
+ std::string IRPipeline;
+ raw_string_ostream IRSOS(IRPipeline);
+ MPM.printPipeline(IRSOS, [&PIC](StringRef ClassName) {
+ auto PassName = PIC.getPassNameForClassName(ClassName);
+ return PassName.empty() ? ClassName : PassName;
+ });
+ outs() << "IR pipeline: " << IRPipeline << '\n';
+
+ std::string MIRPipeline;
+ raw_string_ostream MIRSOS(MIRPipeline);
+ MFPM.printPipeline(MIRSOS, [&PIC](StringRef ClassName) {
+ auto PassName = PIC.getPassNameForClassName(ClassName);
+ return PassName.empty() ? ClassName : PassName;
+ });
+ outs() << "MIR pipeline: " << MIRPipeline << '\n';
+ return 0;
}
+ RunPasses(BOS.get(), Out.get(), M.get(), Context, Buffer, &MPM, &MAM, MFPM,
+ MFAM);
+
// Declare success.
Out->keep();
if (DwoOut)
More information about the llvm-commits
mailing list