Skip to content

Commit da7bc1e

Browse files
committed
[CodeGen][NPM] Account inserted passes for -start/stop options
1 parent 4c6166a commit da7bc1e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

llvm/include/llvm/Passes/CodeGenPassBuilder.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,10 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
583583
void insertPass(InsertedPassT &&Pass) const {
584584
AfterCallbacks.emplace_back(
585585
[&](StringRef Name, MachineFunctionPassManager &MFPM) mutable {
586-
if (Name == TargetPassT::name())
587-
MFPM.addPass(std::forward<InsertedPassT>(Pass));
586+
if (Name == TargetPassT::name()) {
587+
if (runBeforeAdding(InsertedPassT::name()))
588+
MFPM.addPass(std::forward<InsertedPassT>(Pass));
589+
}
588590
});
589591
}
590592

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)