[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:59:13 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);
----------------
mssefat wrote:

Added the assertion and dropped the reserve.

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


More information about the llvm-commits mailing list