[llvm] [AMDGPU] Make SGPR occupancy the exact inverse of getMaxNumSGPRs (PR #201342)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 05:46:53 PDT 2026


================
@@ -167,7 +167,12 @@ bool AMDGPUMCExpr::evaluateAlignTo(MCValue &Res, const MCAssembler *Asm) const {
 bool AMDGPUMCExpr::evaluateOccupancy(MCValue &Res,
                                      const MCAssembler *Asm) const {
   uint64_t InitOccupancy, MaxWaves, Granule, TargetTotalNumVGPRs, Generation,
-      NumSGPRs, NumVGPRs;
+      NumSGPRs, NumVGPRs, SGPRTotal, SGPRGranule, SGPRTrapReserve;
+
+  // createOccupancy() always emits exactly these ten operands; bail out rather
+  // than read out of bounds if a hand-written expression has a different arity.
+  if (Args.size() != 10)
+    return false;
----------------
arsenm wrote:

Whatever this is, this is the wrong way to handle it. Should validate this is well formed at parsing, or handle arbitrary expressions 

https://github.com/llvm/llvm-project/pull/201342


More information about the llvm-commits mailing list