[PATCH] D158834: [NFC][AMDGPU] assert scoreboard index is in range

Luke Drummond via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 25 03:38:26 PDT 2023


ldrumm created this revision.
ldrumm added a reviewer: arsenm.
Herald added subscribers: foad, kerbowa, arphaman, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
Herald added a project: All.
ldrumm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

`getRegInterval` can theoretically return AGPRs or SGPRS which aren't
valid when updating the VgprMemTypes array. Make this clear with an
assert.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158834

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


Index: llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -678,7 +678,7 @@
       setRegScore(RegNo + NUM_ALL_VGPRS, t, CurrScore);
     }
 #endif
-  } else {
+  } else /* LGKM_CNT || EXP_CNT || VS_CNT || NUM_INST_CNTS */{
     // Match the score to the destination registers.
     for (unsigned I = 0, E = Inst.getNumOperands(); I != E; ++I) {
       auto &Op = Inst.getOperand(I);
@@ -689,6 +689,10 @@
         if (Interval.first >= NUM_ALL_VGPRS)
           continue;
         if (updateVMCntOnly(Inst)) {
+          // updateVMCntOnly should only leave us with VGPRs
+          // MUBUF, MTBUF, MIMG, FlatGlobal, and FlatScratch only have VGPR
+          // defs. That's required for a sane index into `VgprMemTypes` below
+          assert(TRI->isVGPR(*MRI, Op.getReg()));
           VmemType V = getVmemType(Inst);
           for (int RegNo = Interval.first; RegNo < Interval.second; ++RegNo)
             VgprVmemTypes[RegNo] |= 1 << V;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158834.553431.patch
Type: text/x-patch
Size: 1104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230825/98d5b98a/attachment.bin>


More information about the llvm-commits mailing list