[llvm] b117ccf - [CodeGen][NPM] Account inserted passes for -start/stop options (#148111)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 16 04:01:02 PDT 2025
Author: Vikram Hegde
Date: 2025-07-16T16:30:58+05:30
New Revision: b117ccf40df16bcd0b24e2a91d8f749ddb7933f3
URL: https://github.com/llvm/llvm-project/commit/b117ccf40df16bcd0b24e2a91d8f749ddb7933f3
DIFF: https://github.com/llvm/llvm-project/commit/b117ccf40df16bcd0b24e2a91d8f749ddb7933f3.diff
LOG: [CodeGen][NPM] Account inserted passes for -start/stop options (#148111)
same as https://github.com/llvm/llvm-project/pull/138830
This partly solves the issue
https://github.com/llvm/llvm-project/issues/138831 for -enable-new-pm.
https://github.com/llvm/llvm-project/pull/137290 will not have this
problem, but this needs to be added this till we migrate to the new pass
builder structure.
Even with this, there is no way to -start-after an inserted pass right
now.
Co-authored-by : Oke, Akshat
<[Akshat.Oke at amd.com](mailto:Akshat.Oke at amd.com)>
Added:
llvm/test/tools/llc/new-pm/start-stop-inserted.ll
Modified:
llvm/include/llvm/Passes/CodeGenPassBuilder.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index dc5f3f80f547e..a8176ebb776cf 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -579,8 +579,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())
+ if (Name == TargetPassT::name() &&
+ 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-commits
mailing list