[llvm] [CodeGen][NPM] Allow nested MF pass managers for -passes (PR #128852)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 02:01:20 PST 2025
https://github.com/optimisan created https://github.com/llvm/llvm-project/pull/128852
None
>From 41ac5de0ae7a24de5de31d8321cd0ead6a9a89a6 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Wed, 26 Feb 2025 09:58:41 +0000
Subject: [PATCH] [CodeGen][NPM] Allow nested MF pass managers for -passes
---
llvm/lib/Passes/PassBuilder.cpp | 11 ++++++++++-
llvm/test/tools/llc/new-pm/pipeline.mir | 8 ++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index c9825dfc89d3d..96028802a4349 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -2117,9 +2117,18 @@ Error PassBuilder::parseLoopPass(LoopPassManager &LPM,
Error PassBuilder::parseMachinePass(MachineFunctionPassManager &MFPM,
const PipelineElement &E) {
StringRef Name = E.Name;
- if (!E.InnerPipeline.empty())
+ // Handle any nested pass managers.
+ if (!E.InnerPipeline.empty()) {
+ if (E.Name == "machine-function") {
+ MachineFunctionPassManager NestedPM;
+ if (auto Err = parseMachinePassPipeline(NestedPM, E.InnerPipeline))
+ return Err;
+ MFPM.addPass(std::move(NestedPM));
+ return Error::success();
+ }
return make_error<StringError>("invalid pipeline",
inconvertibleErrorCode());
+ }
#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
if (Name == NAME) { \
diff --git a/llvm/test/tools/llc/new-pm/pipeline.mir b/llvm/test/tools/llc/new-pm/pipeline.mir
index 761a3a424ee67..1113f2a26c449 100644
--- a/llvm/test/tools/llc/new-pm/pipeline.mir
+++ b/llvm/test/tools/llc/new-pm/pipeline.mir
@@ -1,10 +1,18 @@
# 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
# RUN: llc -mtriple=x86_64-pc-linux-gnu -x mir -passes='require<machine-dom-tree>,print<machine-dom-tree>' -print-pipeline-passes < %s | FileCheck --check-prefix=ANALYSIS %s
+# Check same nested pass managers
+# RUN: llc -mtriple=x86_64-pc-linux-gnu -x mir \
+# RUN: -passes='function(machine-function(machine-function(machine-cp)))' \
+# RUN: -print-pipeline-passes < %s | FileCheck %s --check-prefix=NESTED
+
+# RUN: not llc -mtriple=x86_64-pc-linux-gnu -x mir -passes='machine-function(whoops(verify))' -print-pipeline-passes < %s 2>&1
+
# CHECK: function(machine-function(no-op-machine-function)),PrintMIRPreparePass,function(machine-function(verify,print))
# ANALYSIS: require<machine-dom-tree>,print<machine-dom-tree>
+# NESTED: function(machine-function(machine-cp))
---
name: f
body: |
More information about the llvm-commits
mailing list