[llvm] d7a388c - [AMDGPU] Pass MF into the SIInsertWaitcnts constructor. NFC. (#186369)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 13 06:22:43 PDT 2026


Author: Jay Foad
Date: 2026-03-13T13:22:38Z
New Revision: d7a388c39b5a99c697fae083f8d83f3f960c3b46

URL: https://github.com/llvm/llvm-project/commit/d7a388c39b5a99c697fae083f8d83f3f960c3b46
DIFF: https://github.com/llvm/llvm-project/commit/d7a388c39b5a99c697fae083f8d83f3f960c3b46.diff

LOG: [AMDGPU] Pass MF into the SIInsertWaitcnts constructor. NFC. (#186369)

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.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index a4060744804fa..83bb2410864ff 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