[llvm] [CodeGen][NPM] Support CodeGenSCCOrder in pipeline (PR #136818)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 21:52:30 PDT 2025
https://github.com/optimisan updated https://github.com/llvm/llvm-project/pull/136818
>From a8ffa6611b1775235f8dbff1fd8b538f3dac1a75 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Wed, 23 Apr 2025 06:38:10 +0000
Subject: [PATCH 1/3] [CodeGen][NPM] Support CodeGenSCCOrder in pipeline
pb/codegenscc-order
---
llvm/include/llvm/Passes/CodeGenPassBuilder.h | 89 +++++++++--
.../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 2 +
llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll | 144 ++++++++++++++++++
3 files changed, 219 insertions(+), 16 deletions(-)
create mode 100644 llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 61e377de0c424..ce67cdb6eb8ff 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
+#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/ScopedNoAliasAA.h"
#include "llvm/Analysis/TargetTransformInfo.h"
@@ -207,10 +208,7 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
class AddIRPass {
public:
AddIRPass(ModulePassManager &MPM, const DerivedT &PB) : MPM(MPM), PB(PB) {}
- ~AddIRPass() {
- if (!FPM.isEmpty())
- MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
- }
+ ~AddIRPass() { flushFPMToMPM(); }
template <typename PassT>
void operator()(PassT &&Pass, StringRef Name = PassT::name()) {
@@ -228,16 +226,40 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
FPM.addPass(std::forward<PassT>(Pass));
} else {
// Add Module Pass
- if (!FPM.isEmpty()) {
- MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
- FPM = FunctionPassManager();
- }
-
+ flushFPMToMPM();
MPM.addPass(std::forward<PassT>(Pass));
}
}
+ /// Setting this will add passes to the CGSCC pass manager.
+ void requireCGSCCOrder() {
+ if (PB.AddInCGSCCOrder)
+ return;
+ flushFPMToMPM();
+ PB.AddInCGSCCOrder = true;
+ }
+
+ /// Stop adding passes to the CGSCC pass manager.
+ /// Existing passes won't be removed.
+ void stopAddingInCGSCCOrder() {
+ if (!PB.AddInCGSCCOrder)
+ return;
+ flushFPMToMPM();
+ PB.AddInCGSCCOrder = false;
+ }
+
private:
+ void flushFPMToMPM() {
+ if (!FPM.isEmpty()) {
+ if (PB.AddInCGSCCOrder) {
+ MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(
+ createCGSCCToFunctionPassAdaptor(std::move(FPM))));
+ } else {
+ MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+ }
+ FPM = FunctionPassManager();
+ }
+ }
ModulePassManager &MPM;
FunctionPassManager FPM;
const DerivedT &PB;
@@ -254,7 +276,11 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
FPM.addPass(
createFunctionToMachineFunctionPassAdaptor(std::move(MFPM)));
FPM.addPass(InvalidateAnalysisPass<MachineFunctionAnalysis>());
- MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+ if (this->PB.AddInCGSCCOrder) {
+ MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(
+ createCGSCCToFunctionPassAdaptor(std::move(FPM))));
+ } else
+ MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
}
}
@@ -273,12 +299,7 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
MFPM.addPass(std::forward<PassT>(Pass));
} else {
// Add Module Pass
- if (!MFPM.isEmpty()) {
- MPM.addPass(createModuleToFunctionPassAdaptor(
- createFunctionToMachineFunctionPassAdaptor(std::move(MFPM))));
- MFPM = MachineFunctionPassManager();
- }
-
+ flushMFPMToMPM();
MPM.addPass(std::forward<PassT>(Pass));
}
@@ -286,7 +307,39 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
C(Name, MFPM);
}
+ /// Setting this will add passes to the CGSCC pass manager.
+ void requireCGSCCOrder() {
+ if (PB.AddInCGSCCOrder)
+ return;
+ flushMFPMToMPM();
+ PB.AddInCGSCCOrder = true;
+ }
+
+ /// Stop adding passes to the CGSCC pass manager.
+ /// Existing passes won't be removed.
+ void stopAddingInCGSCCOrder() {
+ if (!PB.AddInCGSCCOrder)
+ return;
+ flushMFPMToMPM();
+ PB.AddInCGSCCOrder = false;
+ }
+
private:
+ void flushMFPMToMPM() {
+ if (!MFPM.isEmpty()) {
+ if (PB.AddInCGSCCOrder) {
+ MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(
+ createCGSCCToFunctionPassAdaptor(
+ createFunctionToMachineFunctionPassAdaptor(
+ std::move(MFPM)))));
+ } else {
+ MPM.addPass(createModuleToFunctionPassAdaptor(
+ createFunctionToMachineFunctionPassAdaptor(std::move(MFPM))));
+ }
+ MFPM = MachineFunctionPassManager();
+ }
+ }
+
ModulePassManager &MPM;
MachineFunctionPassManager MFPM;
const DerivedT &PB;
@@ -552,6 +605,7 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
/// Helper variable for `-start-before/-start-after/-stop-before/-stop-after`
mutable bool Started = true;
mutable bool Stopped = true;
+ mutable bool AddInCGSCCOrder = false;
};
template <typename Derived, typename TargetMachineT>
@@ -810,6 +864,9 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPrepare(
AddIRPass &addPass) const {
derived().addPreISel(addPass);
+ if (Opt.RequiresCodeGenSCCOrder)
+ addPass.requireCGSCCOrder();
+
addPass(CallBrPreparePass());
// Add both the safe stack and the stack protection passes: each of them will
// only protect functions that have corresponding attributes.
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index b6cc5137d711a..c2b89fd8188f8 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -2067,6 +2067,8 @@ void AMDGPUCodeGenPassBuilder::addCodeGenPrepare(AddIRPass &addPass) const {
// being run on them, which causes crashes in the resource usage analysis).
addPass(AMDGPULowerBufferFatPointersPass(TM));
+ addPass.requireCGSCCOrder();
+
Base::addCodeGenPrepare(addPass);
if (isPassEnabled(EnableLoadStoreVectorizer))
diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll b/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
new file mode 100644
index 0000000000000..96a533a19c88a
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
@@ -0,0 +1,144 @@
+; UNSUPPORTED: expensive_checks
+; RUN: llc -O3 -enable-new-pm -mtriple=amdgcn--amdhsa -disable-verify -print-pipeline-passes < %s 2>&1 \
+; RUN: | tr ',' '\n' | FileCheck -check-prefix=GCN-O3 %s
+
+; REQUIRES: asserts
+
+; GCN-O3: require<MachineModuleAnalysis>
+; GCN-O3-NEXT: require<profile-summary>
+; GCN-O3-NEXT: require<collector-metadata>
+; GCN-O3-NEXT: pre-isel-intrinsic-lowering
+; GCN-O3-NEXT: function(expand-large-div-rem
+; GCN-O3-NEXT: expand-fp)
+; GCN-O3-NEXT: amdgpu-remove-incompatible-functions
+; GCN-O3-NEXT: amdgpu-printf-runtime-binding
+; GCN-O3-NEXT: amdgpu-lower-ctor-dtor
+; GCN-O3-NEXT: function(amdgpu-image-intrinsic-opt)
+; GCN-O3-NEXT: expand-variadics
+; GCN-O3-NEXT: amdgpu-always-inline
+; GCN-O3-NEXT: always-inline
+; GCN-O3-NEXT: amdgpu-export-kernel-runtime-handles
+; GCN-O3-NEXT: amdgpu-sw-lower-lds
+; GCN-O3-NEXT: amdgpu-lower-module-lds
+; GCN-O3-NEXT: function(infer-address-spaces
+; GCN-O3-NEXT: amdgpu-atomic-optimizer
+; GCN-O3-NEXT: atomic-expand
+; GCN-O3-NEXT: amdgpu-promote-alloca
+; GCN-O3-NEXT: separate-const-offset-from-gep<>
+; GCN-O3-NEXT: slsr
+; GCN-O3-NEXT: gvn<>
+; GCN-O3-NEXT: nary-reassociate
+; GCN-O3-NEXT: early-cse<>
+; GCN-O3-NEXT: amdgpu-codegenprepare
+; GCN-O3-NEXT: loop-mssa(loop-reduce)
+; GCN-O3-NEXT: mergeicmps
+; GCN-O3-NEXT: expand-memcmp
+; GCN-O3-NEXT: gc-lowering
+; GCN-O3-NEXT: lower-constant-intrinsics
+; GCN-O3-NEXT: UnreachableBlockElimPass
+; GCN-O3-NEXT: consthoist
+; GCN-O3-NEXT: ReplaceWithVeclib
+; GCN-O3-NEXT: partially-inline-libcalls
+; GCN-O3-NEXT: ee-instrument<post-inline>
+; GCN-O3-NEXT: scalarize-masked-mem-intrin
+; GCN-O3-NEXT: ExpandReductionsPass
+; GCN-O3-NEXT: gvn<>
+; GCN-O3-NEXT: amdgpu-lower-kernel-arguments)
+; GCN-O3-NEXT: amdgpu-lower-buffer-fat-pointers
+; GCN-O3-NEXT: cgscc(function(codegenprepare
+; GCN-O3-NEXT: load-store-vectorizer
+; GCN-O3-NEXT: lower-switch
+; GCN-O3-NEXT: lower-invoke
+; GCN-O3-NEXT: UnreachableBlockElimPass
+; GCN-O3-NEXT: flatten-cfg
+; GCN-O3-NEXT: sink
+; GCN-O3-NEXT: amdgpu-late-codegenprepare
+; GCN-O3-NEXT: amdgpu-unify-divergent-exit-nodes
+; GCN-O3-NEXT: fix-irreducible
+; GCN-O3-NEXT: unify-loop-exits
+; GCN-O3-NEXT: StructurizeCFGPass
+; GCN-O3-NEXT: amdgpu-annotate-uniform
+; GCN-O3-NEXT: si-annotate-control-flow
+; GCN-O3-NEXT: amdgpu-rewrite-undef-for-phi
+; GCN-O3-NEXT: lcssa))
+; GCN-O3-NEXT: amdgpu-perf-hint
+; GCN-O3-NEXT: cgscc(function(require<uniformity>
+; GCN-O3-NEXT: callbr-prepare
+; GCN-O3-NEXT: safe-stack
+; GCN-O3-NEXT: stack-protector))
+; GCN-O3-NEXT: cgscc(function(machine-function(amdgpu-isel
+; GCN-O3-NEXT: si-fix-sgpr-copies
+; GCN-O3-NEXT: si-i1-copies
+; GCN-O3-NEXT: finalize-isel
+; GCN-O3-NEXT: early-tailduplication
+; GCN-O3-NEXT: opt-phis
+; GCN-O3-NEXT: stack-coloring
+; GCN-O3-NEXT: localstackalloc
+; GCN-O3-NEXT: dead-mi-elimination
+; GCN-O3-NEXT: early-machinelicm
+; GCN-O3-NEXT: machine-cse
+; GCN-O3-NEXT: machine-sink
+; GCN-O3-NEXT: peephole-opt
+; GCN-O3-NEXT: dead-mi-elimination
+; GCN-O3-NEXT: si-fold-operands
+; GCN-O3-NEXT: gcn-dpp-combine
+; GCN-O3-NEXT: si-load-store-opt
+; GCN-O3-NEXT: si-peephole-sdwa
+; GCN-O3-NEXT: early-machinelicm
+; GCN-O3-NEXT: machine-cse
+; GCN-O3-NEXT: si-fold-operands
+; GCN-O3-NEXT: dead-mi-elimination
+; GCN-O3-NEXT: si-shrink-instructions
+; GCN-O3-NEXT: detect-dead-lanes
+; GCN-O3-NEXT: InitUndefPass
+; GCN-O3-NEXT: ProcessImplicitDefsPass
+; GCN-O3-NEXT: unreachable-mbb-elimination
+; GCN-O3-NEXT: require<live-vars>
+; GCN-O3-NEXT: require<machine-loops>
+; GCN-O3-NEXT: phi-node-elimination
+; GCN-O3-NEXT: two-address-instruction
+; GCN-O3-NEXT: register-coalescer
+; GCN-O3-NEXT: rename-independent-subregs
+; GCN-O3-NEXT: machine-scheduler
+; GCN-O3-NEXT: greedy<all>
+; GCN-O3-NEXT: amdgpu-nsa-reassign
+; GCN-O3-NEXT: VirtRegRewriterPass
+; GCN-O3-NEXT: stack-slot-coloring
+; GCN-O3-NEXT: machine-cp
+; GCN-O3-NEXT: machinelicm
+; GCN-O3-NEXT: si-fix-vgpr-copies
+; GCN-O3-NEXT: si-optimize-exec-masking
+; GCN-O3-NEXT: remove-redundant-debug-values
+; GCN-O3-NEXT: fixup-statepoint-caller-saved
+; GCN-O3-NEXT: PostRAMachineSinkingPass
+; GCN-O3-NEXT: ShrinkWrapPass
+; GCN-O3-NEXT: PrologEpilogInserterPass
+; GCN-O3-NEXT: branch-folder
+; GCN-O3-NEXT: tailduplication
+; GCN-O3-NEXT: machine-latecleanup
+; GCN-O3-NEXT: machine-cp
+; GCN-O3-NEXT: post-ra-pseudos
+; GCN-O3-NEXT: postmisched
+; GCN-O3-NEXT: block-placement
+; GCN-O3-NEXT: fentry-insert
+; GCN-O3-NEXT: xray-instrumentation
+; GCN-O3-NEXT: patchable-function
+; GCN-O3-NEXT: gcn-create-vopd
+; GCN-O3-NEXT: si-memory-legalizer
+; GCN-O3-NEXT: si-insert-waitcnts
+; GCN-O3-NEXT: si-late-branch-lowering
+; GCN-O3-NEXT: si-pre-emit-peephole
+; GCN-O3-NEXT: post-RA-hazard-rec
+; GCN-O3-NEXT: AMDGPUWaitSGPRHazardsPass
+; GCN-O3-NEXT: amdgpu-insert-delay-alu
+; GCN-O3-NEXT: branch-relaxation
+; GCN-O3-NEXT: remove-loads-into-fake-uses
+; GCN-O3-NEXT: live-debug-values
+; GCN-O3-NEXT: machine-sanmd
+; GCN-O3-NEXT: stack-frame-layout)
+; GCN-O3-NEXT: invalidate<machine-function-info>))
+
+
+define void @empty() {
+ ret void
+}
>From d14347e626546695ddb4ce8e0e25019414b7d46d Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Wed, 23 Apr 2025 08:55:23 +0000
Subject: [PATCH 2/3] Remove tr and support expensive check
---
llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll | 267 +++++++++----------
1 file changed, 133 insertions(+), 134 deletions(-)
diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll b/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
index 96a533a19c88a..7ba1771eba08d 100644
--- a/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
+++ b/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
@@ -1,142 +1,141 @@
-; UNSUPPORTED: expensive_checks
; RUN: llc -O3 -enable-new-pm -mtriple=amdgcn--amdhsa -disable-verify -print-pipeline-passes < %s 2>&1 \
-; RUN: | tr ',' '\n' | FileCheck -check-prefix=GCN-O3 %s
+; RUN: | FileCheck -check-prefix=GCN-O3 %s
; REQUIRES: asserts
; GCN-O3: require<MachineModuleAnalysis>
-; GCN-O3-NEXT: require<profile-summary>
-; GCN-O3-NEXT: require<collector-metadata>
-; GCN-O3-NEXT: pre-isel-intrinsic-lowering
-; GCN-O3-NEXT: function(expand-large-div-rem
-; GCN-O3-NEXT: expand-fp)
-; GCN-O3-NEXT: amdgpu-remove-incompatible-functions
-; GCN-O3-NEXT: amdgpu-printf-runtime-binding
-; GCN-O3-NEXT: amdgpu-lower-ctor-dtor
-; GCN-O3-NEXT: function(amdgpu-image-intrinsic-opt)
-; GCN-O3-NEXT: expand-variadics
-; GCN-O3-NEXT: amdgpu-always-inline
-; GCN-O3-NEXT: always-inline
-; GCN-O3-NEXT: amdgpu-export-kernel-runtime-handles
-; GCN-O3-NEXT: amdgpu-sw-lower-lds
-; GCN-O3-NEXT: amdgpu-lower-module-lds
-; GCN-O3-NEXT: function(infer-address-spaces
-; GCN-O3-NEXT: amdgpu-atomic-optimizer
-; GCN-O3-NEXT: atomic-expand
-; GCN-O3-NEXT: amdgpu-promote-alloca
-; GCN-O3-NEXT: separate-const-offset-from-gep<>
-; GCN-O3-NEXT: slsr
-; GCN-O3-NEXT: gvn<>
-; GCN-O3-NEXT: nary-reassociate
-; GCN-O3-NEXT: early-cse<>
-; GCN-O3-NEXT: amdgpu-codegenprepare
-; GCN-O3-NEXT: loop-mssa(loop-reduce)
-; GCN-O3-NEXT: mergeicmps
-; GCN-O3-NEXT: expand-memcmp
-; GCN-O3-NEXT: gc-lowering
-; GCN-O3-NEXT: lower-constant-intrinsics
-; GCN-O3-NEXT: UnreachableBlockElimPass
-; GCN-O3-NEXT: consthoist
-; GCN-O3-NEXT: ReplaceWithVeclib
-; GCN-O3-NEXT: partially-inline-libcalls
-; GCN-O3-NEXT: ee-instrument<post-inline>
-; GCN-O3-NEXT: scalarize-masked-mem-intrin
-; GCN-O3-NEXT: ExpandReductionsPass
-; GCN-O3-NEXT: gvn<>
-; GCN-O3-NEXT: amdgpu-lower-kernel-arguments)
-; GCN-O3-NEXT: amdgpu-lower-buffer-fat-pointers
-; GCN-O3-NEXT: cgscc(function(codegenprepare
-; GCN-O3-NEXT: load-store-vectorizer
-; GCN-O3-NEXT: lower-switch
-; GCN-O3-NEXT: lower-invoke
-; GCN-O3-NEXT: UnreachableBlockElimPass
-; GCN-O3-NEXT: flatten-cfg
-; GCN-O3-NEXT: sink
-; GCN-O3-NEXT: amdgpu-late-codegenprepare
-; GCN-O3-NEXT: amdgpu-unify-divergent-exit-nodes
-; GCN-O3-NEXT: fix-irreducible
-; GCN-O3-NEXT: unify-loop-exits
-; GCN-O3-NEXT: StructurizeCFGPass
-; GCN-O3-NEXT: amdgpu-annotate-uniform
-; GCN-O3-NEXT: si-annotate-control-flow
-; GCN-O3-NEXT: amdgpu-rewrite-undef-for-phi
-; GCN-O3-NEXT: lcssa))
-; GCN-O3-NEXT: amdgpu-perf-hint
-; GCN-O3-NEXT: cgscc(function(require<uniformity>
-; GCN-O3-NEXT: callbr-prepare
-; GCN-O3-NEXT: safe-stack
-; GCN-O3-NEXT: stack-protector))
-; GCN-O3-NEXT: cgscc(function(machine-function(amdgpu-isel
-; GCN-O3-NEXT: si-fix-sgpr-copies
-; GCN-O3-NEXT: si-i1-copies
-; GCN-O3-NEXT: finalize-isel
-; GCN-O3-NEXT: early-tailduplication
-; GCN-O3-NEXT: opt-phis
-; GCN-O3-NEXT: stack-coloring
-; GCN-O3-NEXT: localstackalloc
-; GCN-O3-NEXT: dead-mi-elimination
-; GCN-O3-NEXT: early-machinelicm
-; GCN-O3-NEXT: machine-cse
-; GCN-O3-NEXT: machine-sink
-; GCN-O3-NEXT: peephole-opt
-; GCN-O3-NEXT: dead-mi-elimination
-; GCN-O3-NEXT: si-fold-operands
-; GCN-O3-NEXT: gcn-dpp-combine
-; GCN-O3-NEXT: si-load-store-opt
-; GCN-O3-NEXT: si-peephole-sdwa
-; GCN-O3-NEXT: early-machinelicm
-; GCN-O3-NEXT: machine-cse
-; GCN-O3-NEXT: si-fold-operands
-; GCN-O3-NEXT: dead-mi-elimination
-; GCN-O3-NEXT: si-shrink-instructions
-; GCN-O3-NEXT: detect-dead-lanes
-; GCN-O3-NEXT: InitUndefPass
-; GCN-O3-NEXT: ProcessImplicitDefsPass
-; GCN-O3-NEXT: unreachable-mbb-elimination
-; GCN-O3-NEXT: require<live-vars>
-; GCN-O3-NEXT: require<machine-loops>
-; GCN-O3-NEXT: phi-node-elimination
-; GCN-O3-NEXT: two-address-instruction
-; GCN-O3-NEXT: register-coalescer
-; GCN-O3-NEXT: rename-independent-subregs
-; GCN-O3-NEXT: machine-scheduler
-; GCN-O3-NEXT: greedy<all>
-; GCN-O3-NEXT: amdgpu-nsa-reassign
-; GCN-O3-NEXT: VirtRegRewriterPass
-; GCN-O3-NEXT: stack-slot-coloring
-; GCN-O3-NEXT: machine-cp
-; GCN-O3-NEXT: machinelicm
-; GCN-O3-NEXT: si-fix-vgpr-copies
-; GCN-O3-NEXT: si-optimize-exec-masking
-; GCN-O3-NEXT: remove-redundant-debug-values
-; GCN-O3-NEXT: fixup-statepoint-caller-saved
-; GCN-O3-NEXT: PostRAMachineSinkingPass
-; GCN-O3-NEXT: ShrinkWrapPass
-; GCN-O3-NEXT: PrologEpilogInserterPass
-; GCN-O3-NEXT: branch-folder
-; GCN-O3-NEXT: tailduplication
-; GCN-O3-NEXT: machine-latecleanup
-; GCN-O3-NEXT: machine-cp
-; GCN-O3-NEXT: post-ra-pseudos
-; GCN-O3-NEXT: postmisched
-; GCN-O3-NEXT: block-placement
-; GCN-O3-NEXT: fentry-insert
-; GCN-O3-NEXT: xray-instrumentation
-; GCN-O3-NEXT: patchable-function
-; GCN-O3-NEXT: gcn-create-vopd
-; GCN-O3-NEXT: si-memory-legalizer
-; GCN-O3-NEXT: si-insert-waitcnts
-; GCN-O3-NEXT: si-late-branch-lowering
-; GCN-O3-NEXT: si-pre-emit-peephole
-; GCN-O3-NEXT: post-RA-hazard-rec
-; GCN-O3-NEXT: AMDGPUWaitSGPRHazardsPass
-; GCN-O3-NEXT: amdgpu-insert-delay-alu
-; GCN-O3-NEXT: branch-relaxation
-; GCN-O3-NEXT: remove-loads-into-fake-uses
-; GCN-O3-NEXT: live-debug-values
-; GCN-O3-NEXT: machine-sanmd
-; GCN-O3-NEXT: stack-frame-layout)
-; GCN-O3-NEXT: invalidate<machine-function-info>))
+; GCN-O3: require<profile-summary>
+; GCN-O3: require<collector-metadata>
+; GCN-O3: pre-isel-intrinsic-lowering
+; GCN-O3: function(expand-large-div-rem
+; GCN-O3: expand-fp)
+; GCN-O3: amdgpu-remove-incompatible-functions
+; GCN-O3: amdgpu-printf-runtime-binding
+; GCN-O3: amdgpu-lower-ctor-dtor
+; GCN-O3: function(amdgpu-image-intrinsic-opt)
+; GCN-O3: expand-variadics
+; GCN-O3: amdgpu-always-inline
+; GCN-O3: always-inline
+; GCN-O3: amdgpu-export-kernel-runtime-handles
+; GCN-O3: amdgpu-sw-lower-lds
+; GCN-O3: amdgpu-lower-module-lds
+; GCN-O3: function(infer-address-spaces
+; GCN-O3: amdgpu-atomic-optimizer
+; GCN-O3: atomic-expand
+; GCN-O3: amdgpu-promote-alloca
+; GCN-O3: separate-const-offset-from-gep<>
+; GCN-O3: slsr
+; GCN-O3: gvn<>
+; GCN-O3: nary-reassociate
+; GCN-O3: early-cse<>
+; GCN-O3: amdgpu-codegenprepare
+; GCN-O3: loop-mssa(loop-reduce)
+; GCN-O3: mergeicmps
+; GCN-O3: expand-memcmp
+; GCN-O3: gc-lowering
+; GCN-O3: lower-constant-intrinsics
+; GCN-O3: UnreachableBlockElimPass
+; GCN-O3: consthoist
+; GCN-O3: ReplaceWithVeclib
+; GCN-O3: partially-inline-libcalls
+; GCN-O3: ee-instrument<post-inline>
+; GCN-O3: scalarize-masked-mem-intrin
+; GCN-O3: ExpandReductionsPass
+; GCN-O3: gvn<>
+; GCN-O3: amdgpu-lower-kernel-arguments)
+; GCN-O3: amdgpu-lower-buffer-fat-pointers
+; GCN-O3: cgscc(function(codegenprepare
+; GCN-O3: load-store-vectorizer
+; GCN-O3: lower-switch
+; GCN-O3: lower-invoke
+; GCN-O3: UnreachableBlockElimPass
+; GCN-O3: flatten-cfg
+; GCN-O3: sink
+; GCN-O3: amdgpu-late-codegenprepare
+; GCN-O3: amdgpu-unify-divergent-exit-nodes
+; GCN-O3: fix-irreducible
+; GCN-O3: unify-loop-exits
+; GCN-O3: StructurizeCFGPass
+; GCN-O3: amdgpu-annotate-uniform
+; GCN-O3: si-annotate-control-flow
+; GCN-O3: amdgpu-rewrite-undef-for-phi
+; GCN-O3: lcssa))
+; GCN-O3: amdgpu-perf-hint
+; GCN-O3: cgscc(function(require<uniformity>
+; GCN-O3: callbr-prepare
+; GCN-O3: safe-stack
+; GCN-O3: stack-protector))
+; GCN-O3: cgscc(function(machine-function(amdgpu-isel
+; GCN-O3: si-fix-sgpr-copies
+; GCN-O3: si-i1-copies
+; GCN-O3: finalize-isel
+; GCN-O3: early-tailduplication
+; GCN-O3: opt-phis
+; GCN-O3: stack-coloring
+; GCN-O3: localstackalloc
+; GCN-O3: dead-mi-elimination
+; GCN-O3: early-machinelicm
+; GCN-O3: machine-cse
+; GCN-O3: machine-sink
+; GCN-O3: peephole-opt
+; GCN-O3: dead-mi-elimination
+; GCN-O3: si-fold-operands
+; GCN-O3: gcn-dpp-combine
+; GCN-O3: si-load-store-opt
+; GCN-O3: si-peephole-sdwa
+; GCN-O3: early-machinelicm
+; GCN-O3: machine-cse
+; GCN-O3: si-fold-operands
+; GCN-O3: dead-mi-elimination
+; GCN-O3: si-shrink-instructions
+; GCN-O3: detect-dead-lanes
+; GCN-O3: InitUndefPass
+; GCN-O3: ProcessImplicitDefsPass
+; GCN-O3: unreachable-mbb-elimination
+; GCN-O3: require<live-vars>
+; GCN-O3: require<machine-loops>
+; GCN-O3: phi-node-elimination
+; GCN-O3: two-address-instruction
+; GCN-O3: register-coalescer
+; GCN-O3: rename-independent-subregs
+; GCN-O3: machine-scheduler
+; GCN-O3: greedy<all>
+; GCN-O3: amdgpu-nsa-reassign
+; GCN-O3: VirtRegRewriterPass
+; GCN-O3: stack-slot-coloring
+; GCN-O3: machine-cp
+; GCN-O3: machinelicm
+; GCN-O3: si-fix-vgpr-copies
+; GCN-O3: si-optimize-exec-masking
+; GCN-O3: remove-redundant-debug-values
+; GCN-O3: fixup-statepoint-caller-saved
+; GCN-O3: PostRAMachineSinkingPass
+; GCN-O3: ShrinkWrapPass
+; GCN-O3: PrologEpilogInserterPass
+; GCN-O3: branch-folder
+; GCN-O3: tailduplication
+; GCN-O3: machine-latecleanup
+; GCN-O3: machine-cp
+; GCN-O3: post-ra-pseudos
+; GCN-O3: postmisched
+; GCN-O3: block-placement
+; GCN-O3: fentry-insert
+; GCN-O3: xray-instrumentation
+; GCN-O3: patchable-function
+; GCN-O3: gcn-create-vopd
+; GCN-O3: si-memory-legalizer
+; GCN-O3: si-insert-waitcnts
+; GCN-O3: si-late-branch-lowering
+; GCN-O3: si-pre-emit-peephole
+; GCN-O3: post-RA-hazard-rec
+; GCN-O3: AMDGPUWaitSGPRHazardsPass
+; GCN-O3: amdgpu-insert-delay-alu
+; GCN-O3: branch-relaxation
+; GCN-O3: remove-loads-into-fake-uses
+; GCN-O3: live-debug-values
+; GCN-O3: machine-sanmd
+; GCN-O3: stack-frame-layout)
+; GCN-O3: invalidate<machine-function-info>))
define void @empty() {
>From dcf2c2daacb93b15b21fc2c0cb3dbc14c02536d0 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Thu, 24 Apr 2025 04:51:11 +0000
Subject: [PATCH 3/3] separate tests for O2 and O3
---
llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll | 139 ++++++++++++++++++-
1 file changed, 137 insertions(+), 2 deletions(-)
diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll b/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
index 7ba1771eba08d..fbfb850cd7776 100644
--- a/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
+++ b/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
@@ -1,7 +1,142 @@
-; RUN: llc -O3 -enable-new-pm -mtriple=amdgcn--amdhsa -disable-verify -print-pipeline-passes < %s 2>&1 \
+; RUN: llc -enable-new-pm -disable-verify -mtriple=amdgcn--amdhsa -print-pipeline-passes < %s 2>&1 \
+; RUN: | FileCheck -check-prefix=GCN-O2 %s
+
+; RUN: llc -O3 -enable-new-pm -disable-verify -mtriple=amdgcn--amdhsa -print-pipeline-passes < %s 2>&1 \
; RUN: | FileCheck -check-prefix=GCN-O3 %s
-; REQUIRES: asserts
+; GCN-O2: require<MachineModuleAnalysis>
+; GCN-O2: require<profile-summary>
+; GCN-O2: require<collector-metadata>
+; GCN-O2: pre-isel-intrinsic-lowering
+; GCN-O2: function(expand-large-div-rem
+; GCN-O2: expand-fp)
+; GCN-O2: amdgpu-remove-incompatible-functions
+; GCN-O2: amdgpu-printf-runtime-binding
+; GCN-O2: amdgpu-lower-ctor-dtor
+; GCN-O2: function(amdgpu-image-intrinsic-opt)
+; GCN-O2: expand-variadics
+; GCN-O2: amdgpu-always-inline
+; GCN-O2: always-inline
+; GCN-O2: amdgpu-export-kernel-runtime-handles
+; GCN-O2: amdgpu-sw-lower-lds
+; GCN-O2: amdgpu-lower-module-lds
+; GCN-O2: function(infer-address-spaces
+; GCN-O2: amdgpu-atomic-optimizer
+; GCN-O2: atomic-expand
+; GCN-O2: amdgpu-promote-alloca
+; GCN-O2: separate-const-offset-from-gep<>
+; GCN-O2: slsr
+; GCN-O2: early-cse<>
+; GCN-O2: nary-reassociate
+; GCN-O2: early-cse<>
+; GCN-O2: amdgpu-codegenprepare
+; GCN-O2: loop-mssa(loop-reduce)
+; GCN-O2: mergeicmps
+; GCN-O2: expand-memcmp
+; GCN-O2: gc-lowering
+; GCN-O2: lower-constant-intrinsics
+; GCN-O2: UnreachableBlockElimPass
+; GCN-O2: consthoist
+; GCN-O2: ReplaceWithVeclib
+; GCN-O2: partially-inline-libcalls
+; GCN-O2: ee-instrument<post-inline>
+; GCN-O2: scalarize-masked-mem-intrin
+; GCN-O2: ExpandReductionsPass
+; GCN-O2: early-cse<>
+; GCN-O2: amdgpu-lower-kernel-arguments)
+; GCN-O2: amdgpu-lower-buffer-fat-pointers
+; GCN-O2: cgscc(function(codegenprepare
+; GCN-O2: load-store-vectorizer
+; GCN-O2: lower-switch
+; GCN-O2: lower-invoke
+; GCN-O2: UnreachableBlockElimPass
+; GCN-O2: flatten-cfg
+; GCN-O2: sink
+; GCN-O2: amdgpu-late-codegenprepare
+; GCN-O2: amdgpu-unify-divergent-exit-nodes
+; GCN-O2: fix-irreducible
+; GCN-O2: unify-loop-exits
+; GCN-O2: StructurizeCFGPass
+; GCN-O2: amdgpu-annotate-uniform
+; GCN-O2: si-annotate-control-flow
+; GCN-O2: amdgpu-rewrite-undef-for-phi
+; GCN-O2: lcssa))
+; GCN-O2: amdgpu-perf-hint
+; GCN-O2: cgscc(function(require<uniformity>
+; GCN-O2: callbr-prepare
+; GCN-O2: safe-stack
+; GCN-O2: stack-protector))
+; GCN-O2: cgscc(function(machine-function(amdgpu-isel
+; GCN-O2: si-fix-sgpr-copies
+; GCN-O2: si-i1-copies
+; GCN-O2: finalize-isel
+; GCN-O2: early-tailduplication
+; GCN-O2: opt-phis
+; GCN-O2: stack-coloring
+; GCN-O2: localstackalloc
+; GCN-O2: dead-mi-elimination
+; GCN-O2: early-machinelicm
+; GCN-O2: machine-cse
+; GCN-O2: machine-sink
+; GCN-O2: peephole-opt
+; GCN-O2: dead-mi-elimination
+; GCN-O2: si-fold-operands
+; GCN-O2: gcn-dpp-combine
+; GCN-O2: si-load-store-opt
+; GCN-O2: si-peephole-sdwa
+; GCN-O2: early-machinelicm
+; GCN-O2: machine-cse
+; GCN-O2: si-fold-operands
+; GCN-O2: dead-mi-elimination
+; GCN-O2: si-shrink-instructions
+; GCN-O2: detect-dead-lanes
+; GCN-O2: InitUndefPass
+; GCN-O2: ProcessImplicitDefsPass
+; GCN-O2: unreachable-mbb-elimination
+; GCN-O2: require<live-vars>
+; GCN-O2: require<machine-loops>
+; GCN-O2: phi-node-elimination
+; GCN-O2: two-address-instruction
+; GCN-O2: register-coalescer
+; GCN-O2: rename-independent-subregs
+; GCN-O2: machine-scheduler
+; GCN-O2: greedy<all>
+; GCN-O2: amdgpu-nsa-reassign
+; GCN-O2: VirtRegRewriterPass
+; GCN-O2: stack-slot-coloring
+; GCN-O2: machine-cp
+; GCN-O2: machinelicm
+; GCN-O2: si-fix-vgpr-copies
+; GCN-O2: si-optimize-exec-masking
+; GCN-O2: remove-redundant-debug-values
+; GCN-O2: fixup-statepoint-caller-saved
+; GCN-O2: PostRAMachineSinkingPass
+; GCN-O2: ShrinkWrapPass
+; GCN-O2: PrologEpilogInserterPass
+; GCN-O2: branch-folder
+; GCN-O2: tailduplication
+; GCN-O2: machine-latecleanup
+; GCN-O2: machine-cp
+; GCN-O2: post-ra-pseudos
+; GCN-O2: postmisched
+; GCN-O2: block-placement
+; GCN-O2: fentry-insert
+; GCN-O2: xray-instrumentation
+; GCN-O2: patchable-function
+; GCN-O2: gcn-create-vopd
+; GCN-O2: si-memory-legalizer
+; GCN-O2: si-insert-waitcnts
+; GCN-O2: si-late-branch-lowering
+; GCN-O2: si-pre-emit-peephole
+; GCN-O2: post-RA-hazard-rec
+; GCN-O2: AMDGPUWaitSGPRHazardsPass
+; GCN-O2: amdgpu-insert-delay-alu
+; GCN-O2: branch-relaxation
+; GCN-O2: remove-loads-into-fake-uses
+; GCN-O2: live-debug-values
+; GCN-O2: machine-sanmd
+; GCN-O2: stack-frame-layout)
+; GCN-O2: invalidate<machine-function-info>))
; GCN-O3: require<MachineModuleAnalysis>
; GCN-O3: require<profile-summary>
More information about the llvm-commits
mailing list