[llvm] [RegAlloc] Add register allocation anti-hints infrastructure (PR #218071)
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 21:48:02 PDT 2026
================
@@ -31,21 +32,53 @@ AllocationOrder AllocationOrder::create(Register VirtReg, const VirtRegMap &VRM,
const LiveRegMatrix *Matrix) {
const MachineFunction &MF = VRM.getMachineFunction();
const TargetRegisterInfo *TRI = &VRM.getTargetRegInfo();
+ const MachineRegisterInfo &MRI = MF.getRegInfo();
auto Order = RegClassInfo.getOrder(MF.getRegInfo().getRegClass(VirtReg));
- SmallVector<MCPhysReg, 16> Hints;
- bool HardHints =
- TRI->getRegAllocationHints(VirtReg, Order, Hints, MF, &VRM, Matrix);
+
+ // HintsAndCustomOrder holds Hints first followed by the shuffled order if the
+ // anti-hints shuffle it.
+ SmallVector<MCPhysReg, 16> HintsAndCustomOrder;
+
+ // Get hints
+ bool HardHints = TRI->getRegAllocationHints(
+ VirtReg, Order, HintsAndCustomOrder, MF, &VRM, Matrix);
+ const int NumHints = static_cast<int>(HintsAndCustomOrder.size());
LLVM_DEBUG({
- if (!Hints.empty()) {
+ if (NumHints) {
dbgs() << "hints:";
- for (MCPhysReg Hint : Hints)
+ for (MCPhysReg Hint : HintsAndCustomOrder)
dbgs() << ' ' << printReg(Hint, TRI);
dbgs() << '\n';
}
});
----------------
qcolombet wrote:
I believe this is fine (although a bit confusing because of the name) because HintsAndCustomOrder hasn't been populated with the custom order yet.
https://github.com/llvm/llvm-project/pull/218071
More information about the llvm-commits
mailing list