aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshat Oke <Akshat.Oke@amd.com>2025-05-07 08:57:31 +0000
committerAkshat Oke <Akshat.Oke@amd.com>2025-07-09 08:49:21 +0000
commitb0f06a702546b3ed7d89bfa3256cbeea784f2b82 (patch)
treeaacd00ff2079b26973fea77dacd0c08c2c79f2ab
parent4f58c4453826e606f9b748cdc82692407d387edf (diff)
downloadllvm-users/optimisan/pb/inserted-start-stop.zip
llvm-users/optimisan/pb/inserted-start-stop.tar.gz
llvm-users/optimisan/pb/inserted-start-stop.tar.bz2
[CodeGen][NPM] Account inserted passes for -start/stop optionsusers/optimisan/pb/inserted-start-stop
-rw-r--r--llvm/include/llvm/Passes/CodeGenPassBuilder.h6
-rw-r--r--llvm/test/tools/llc/new-pm/start-stop-inserted.ll15
2 files changed, 19 insertions, 2 deletions
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 6d0aaee..752ed6a 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -583,8 +583,10 @@ protected:
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 0000000..ce5ad2d
--- /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