[llvm-branch-commits] [llvm] [CodeGen][NPM] Account inserted passes for -start/stop options (PR #138830)
Akshat Oke via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon May 12 02:11:52 PDT 2025
https://github.com/optimisan updated https://github.com/llvm/llvm-project/pull/138830
>From 67f7f32e9ca0a8befc28b7504e9e7f141d771eae Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Wed, 7 May 2025 08:57:31 +0000
Subject: [PATCH] [CodeGen][NPM] Account inserted passes for -start/stop
options
---
llvm/include/llvm/Passes/CodeGenPassBuilder.h | 6 ++++--
llvm/test/tools/llc/new-pm/start-stop-inserted.ll | 15 +++++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
create mode 100644 llvm/test/tools/llc/new-pm/start-stop-inserted.ll
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 6d0aaee32b33e..752ed6ae08a96 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -583,8 +583,10 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
void insertPass(InsertedPassT &&Pass) const {
AfterCallbacks.emplace_back(
[&](StringRef Name, MachineFunctionPassManager &MFPM) mutable {
- if (Name == TargetPassT::name())
- MFPM.addPass(std::forward<InsertedPassT>(Pass));
+ if (Name == TargetPassT::name()) {
+ if (runBeforeAdding(InsertedPassT::name()))
+ MFPM.addPass(std::forward<InsertedPassT>(Pass));
+ }
});
}
diff --git a/llvm/test/tools/llc/new-pm/start-stop-inserted.ll b/llvm/test/tools/llc/new-pm/start-stop-inserted.ll
new file mode 100644
index 0000000000000..ce5ad2d9e5065
--- /dev/null
+++ b/llvm/test/tools/llc/new-pm/start-stop-inserted.ll
@@ -0,0 +1,15 @@
+; REQUIRES: amdgpu-registered-target
+
+; AMDGPU inserts the fourth instance of dead-mi-elimination pass after detect-dead-lanes
+; This checks that the pipeline stops before that.
+
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -O3 -enable-new-pm -stop-before=dead-mi-elimination,4 --print-pipeline-passes -filetype=null %s | FileCheck %s
+
+; There is no way to -start-after an inserted pass right now.
+; RUN: not llc -mtriple=amdgcn-amd-amdhsa -O3 -enable-new-pm -start-after=dead-mi-elimination,4 --print-pipeline-passes -filetype=null %s
+
+
+; CHECK: dead-mi-elimination
+; CHECK: dead-mi-elimination
+; CHECK: dead-mi-elimination
+; CHECK-NOT: dead-mi-elimination
More information about the llvm-branch-commits
mailing list