[llvm] [RegAlloc] Add register allocation anti-hints infrastructure (PR #218071)
Syadus Sefat via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 17:58:45 PDT 2026
================
@@ -443,6 +443,53 @@ bool TargetRegisterInfo::getRegAllocationHints(
return false;
}
+bool TargetRegisterInfo::isAntiHintedReg(
+ MCPhysReg Reg, const BitVector &AntiHintedRegUnits) const {
+ return llvm::any_of(regunits(Reg), [&](MCRegUnit Unit) {
+ return AntiHintedRegUnits.test(static_cast<unsigned>(Unit));
+ });
+}
+
+void TargetRegisterInfo::applyRegAllocationAntiHints(
+ Register VirtReg, ArrayRef<MCPhysReg> Order,
+ SmallVectorImpl<MCPhysReg> &HintsAndCustomOrder, unsigned NumHints,
+ const BitVector &AntiHintedRegUnits, const MachineFunction &MF,
+ const LiveRegMatrix *Matrix, const RegisterClassInfo *RegClassInfo) const {
+
+ if (AntiHintedRegUnits.none())
+ return;
+
+ HintsAndCustomOrder.truncate(NumHints);
+ HintsAndCustomOrder.append(Order.begin(), Order.end());
+
+ // Custom reordering of the allocation order.
+ filterAndSortForAntiHintedRegs(
+ VirtReg,
+ MutableArrayRef<MCPhysReg>(HintsAndCustomOrder).drop_front(NumHints),
+ AntiHintedRegUnits, MF, Matrix, RegClassInfo);
+}
+
+void TargetRegisterInfo::filterAndSortForAntiHintedRegs(
+ Register VirtReg, MutableArrayRef<MCPhysReg> CustomOrder,
+ const BitVector &AntiHintedRegUnits, const MachineFunction &MF,
+ const LiveRegMatrix *Matrix, const RegisterClassInfo *RegClassInfo) const {
+
+ // Partition non-anti-hinted register go first.
+ auto *PartitionPoint = std::stable_partition(
----------------
mssefat wrote:
Fixed.
https://github.com/llvm/llvm-project/pull/218071
More information about the llvm-commits
mailing list