Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions llvm/include/llvm/Passes/CodeGenPassBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,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())
MFPM.addPass(std::forward<InsertedPassT>(Pass));
if (Name == TargetPassT::name()) {
if (runBeforeAdding(InsertedPassT::name()))
MFPM.addPass(std::forward<InsertedPassT>(Pass));
}
});
}

Expand Down
15 changes: 15 additions & 0 deletions llvm/test/tools/llc/new-pm/start-stop-inserted.ll
Original file line number Diff line number Diff line change
@@ -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