Skip to content

Commit 245b1cd

Browse files
committed
[CodeGen][NPM] Account inserted passes for -start/stop options
1 parent 6887d0a commit 245b1cd

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

llvm/include/llvm/Passes/CodeGenPassBuilder.h

Lines changed: 4 additions & 2 deletions
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())
583-
MFPM.addPass(std::forward<InsertedPassT>(Pass));
582+
if (Name == TargetPassT::name()) {
583+
if (runBeforeAdding(InsertedPassT::name()))
584+
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)