[llvm] [AMDGPU] Pass MF into the SIInsertWaitcnts constructor. NFC. (PR #186369)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 13 05:01:05 PDT 2026
https://github.com/jayfoad updated https://github.com/llvm/llvm-project/pull/186369
>From 0c46d28d10e45a84d0da4376d9562225d1de6284 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Fri, 13 Mar 2026 11:16:41 +0000
Subject: [PATCH] [AMDGPU] Pass MF into the SIInsertWaitcnts constructor. NFC.
Pass MF into the SIInsertWaitcnts constructor instead of the run method.
This is more natural now that SIInsertWaitcnts is constructed once per
MachineFunction and enables future cleanup by initializing more fields
in the constructor that depend on MF.
---
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 5af658f3761de..869c5d87ea405 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -510,6 +510,7 @@ class SIInsertWaitcnts {
MachineLoopInfo *MLI;
MachinePostDominatorTree *PDT;
AliasAnalysis *AA = nullptr;
+ MachineFunction &MF;
struct BlockInfo {
std::unique_ptr<WaitcntBrackets> Incoming;
@@ -535,8 +536,8 @@ class SIInsertWaitcnts {
public:
SIInsertWaitcnts(MachineLoopInfo *MLI, MachinePostDominatorTree *PDT,
- AliasAnalysis *AA)
- : MLI(MLI), PDT(PDT), AA(AA) {
+ AliasAnalysis *AA, MachineFunction &MF)
+ : MLI(MLI), PDT(PDT), AA(AA), MF(MF) {
(void)ForceExpCounter;
(void)ForceLgkmCounter;
(void)ForceVMCounter;
@@ -551,7 +552,7 @@ class SIInsertWaitcnts {
bool isVMEMOrFlatVMEM(const MachineInstr &MI) const;
bool isDSRead(const MachineInstr &MI) const;
bool mayStoreIncrementingDSCNT(const MachineInstr &MI) const;
- bool run(MachineFunction &MF);
+ bool run();
void setForceEmitWaitcnt() {
// For non-debug builds, ForceEmitWaitcnt has been initialized to false;
@@ -3602,7 +3603,7 @@ bool SIInsertWaitcntsLegacy::runOnMachineFunction(MachineFunction &MF) {
if (auto *AAR = getAnalysisIfAvailable<AAResultsWrapperPass>())
AA = &AAR->getAAResults();
- return SIInsertWaitcnts(MLI, PDT, AA).run(MF);
+ return SIInsertWaitcnts(MLI, PDT, AA, MF).run();
}
PreservedAnalyses
@@ -3614,7 +3615,7 @@ SIInsertWaitcntsPass::run(MachineFunction &MF,
.getManager()
.getCachedResult<AAManager>(MF.getFunction());
- if (!SIInsertWaitcnts(MLI, PDT, AA).run(MF))
+ if (!SIInsertWaitcnts(MLI, PDT, AA, MF).run())
return PreservedAnalyses::all();
return getMachineFunctionPassPreservedAnalyses()
@@ -3622,7 +3623,7 @@ SIInsertWaitcntsPass::run(MachineFunction &MF,
.preserve<AAManager>();
}
-bool SIInsertWaitcnts::run(MachineFunction &MF) {
+bool SIInsertWaitcnts::run() {
ST = &MF.getSubtarget<GCNSubtarget>();
TII = ST->getInstrInfo();
TRI = &TII->getRegisterInfo();
More information about the llvm-commits
mailing list