Commit ce0d16f5 authored by Luke Drummond's avatar Luke Drummond
Browse files

[NFC][AMDGPU] assert scoreboard index is in range

`getRegInterval` can theoretically return AGPRs or SGPRS which aren't
valid when updating the VgprMemTypes array. Make this clear with an
assert.
parent adaae6a7
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -678,7 +678,7 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
      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 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
        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/AGPR
          // defs. That's required for a sane index into `VgprMemTypes` below
          assert(TRI->isVectorRegister(*MRI, Op.getReg()));
          VmemType V = getVmemType(Inst);
          for (int RegNo = Interval.first; RegNo < Interval.second; ++RegNo)
            VgprVmemTypes[RegNo] |= 1 << V;