[llvm] [RISCV] Correct the limit of RegPresureSet `GPRAll` (PR #118473)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 06:00:24 PST 2024


================
@@ -934,3 +934,17 @@ bool RISCVRegisterInfo::getRegAllocationHints(
 
   return BaseImplRetVal;
 }
+
+unsigned RISCVRegisterInfo::getRegPressureSetLimit(const MachineFunction &MF,
+                                                   unsigned Idx) const {
+  if (Idx == RISCV::RegisterPressureSets::GPRAll) {
+    unsigned Reserved = 0;
+    BitVector ReservedRegs = getReservedRegs(MF);
+    for (MCPhysReg Reg = RISCV::X0_H; Reg <= RISCV::X31_H; Reg++)
+      if (ReservedRegs.test(Reg))
+        Reserved++;
+
+    return 32 - Reserved;
+  }
+  return RISCVGenRegisterInfo::getRegPressureSetLimit(MF, Idx);
----------------
arsenm wrote:

I'd expect the default to handle reserved registers correctly

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


More information about the llvm-commits mailing list