Skip to content

Commit b117ccf

Browse files
authored
[CodeGen][NPM] Account inserted passes for -start/stop options (#148111)
same as #138830 This partly solves the issue #138831 for -enable-new-pm. #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 <[[email protected]](mailto:[email protected])>
1 parent e333d60 commit b117ccf

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

llvm/include/llvm/Passes/CodeGenPassBuilder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,10 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
579579
void insertPass(InsertedPassT &&Pass) const {
580580
AfterCallbacks.emplace_back(
581581
[&](StringRef Name, MachineFunctionPassManager &MFPM) mutable {
582-
if (Name == TargetPassT::name())
582+
if (Name == TargetPassT::name() &&
583+
runBeforeAdding(InsertedPassT::name())) {
583584
MFPM.addPass(std::forward<InsertedPassT>(Pass));
585+
}
584586
});
585587
}
586588

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; REQUIRES: amdgpu-registered-target
2+
3+
; AMDGPU inserts the fourth instance of dead-mi-elimination pass after detect-dead-lanes
4+
; This checks that the pipeline stops before that.
5+
6+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -O3 -enable-new-pm -stop-before=dead-mi-elimination,4 --print-pipeline-passes -filetype=null %s | FileCheck %s
7+
8+
; There is no way to -start-after an inserted pass right now.
9+
; RUN: not llc -mtriple=amdgcn-amd-amdhsa -O3 -enable-new-pm -start-after=dead-mi-elimination,4 --print-pipeline-passes -filetype=null %s
10+
11+
12+
; CHECK: dead-mi-elimination
13+
; CHECK: dead-mi-elimination
14+
; CHECK: dead-mi-elimination
15+
; CHECK-NOT: dead-mi-elimination

0 commit comments

Comments
 (0)