[llvm] [TRI] Remove reserved registers in getRegPressureSetLimit (PR #118787)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 6 07:17:54 PST 2024
================
@@ -674,6 +674,49 @@ TargetRegisterInfo::prependOffsetExpression(const DIExpression *Expr,
PrependFlags & DIExpression::EntryValue);
}
+unsigned TargetRegisterInfo::getRegPressureSetLimit(const MachineFunction &MF,
+ unsigned Idx) const {
+ const TargetRegisterClass *RC = nullptr;
+ unsigned NumRCUnits = 0;
+ for (const TargetRegisterClass *C : regclasses()) {
+ const int *PSetID = getRegClassPressureSets(C);
+ for (; *PSetID != -1; ++PSetID) {
+ if ((unsigned)*PSetID == Idx)
+ break;
+ }
+ if (*PSetID == -1)
+ continue;
+
+ // Found a register class that counts against this pressure set.
+ // For efficiency, only compute the set order for the largest set.
+ unsigned NUnits = getRegClassWeight(C).WeightLimit;
+ if (!RC || NUnits > NumRCUnits) {
+ RC = C;
+ NumRCUnits = NUnits;
+ }
+ }
+ assert(RC && "Failed to find register class");
+
+ unsigned NReserved = 0;
+ const BitVector Reserved = MF.getRegInfo().getReservedRegs();
+ for (MCPhysReg PhysReg : RC->getRawAllocationOrder(MF))
----------------
arsenm wrote:
There's still the pre-existing bug where the pressure number is wrong for overlapping registers in the allocation order, and should probably be reporting number of distinct allocatable registers
https://github.com/llvm/llvm-project/pull/118787
More information about the llvm-commits
mailing list