[PATCH] D138515: [CodeGen][RegAllocFast] Map PhysReg to its current VirtReg

Christudasan Devadasan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 23 11:55:50 PST 2022


cdevadas added a comment.

The idea of mapping a physical register into the current virtual register in RegAllocFast would be likely a risky choice with a global variable. The same was true for the initial patch I posted D134951 <https://reviews.llvm.org/D134951> which does the same thing specifically around the spill and reload functions via. the delegate.
The effort was to identify the physical register allocated for some special machine operands (whole-wave vector registers for AMDGPU), especially inside storeRegToStackSlot & loadRegFromStackSlot spill interfaces called from fast regalloc that directly spills the physRegs.
The better approach would be by passing an additional parameter (the virtual register) to the spiller interface. The interface is common to Greedy, PEI, and to some other places that have no use for this additional parameter. Still, I think it is the right way to handle the problem.



================
Comment at: llvm/include/llvm/CodeGen/MachineRegisterInfo.h:781
+  void setPhysToCurrentVirtReg(Register Reg) { PhysToCurrentVirtReg = Reg; }
+  Register getPhysToCurrentVirtReg() const { return PhysToCurrentVirtReg; }
+
----------------
arsenm wrote:
> Why pollute MRI with this, this is state local to RegAllocFast
It should be accessible for targets and hence I thought MRI would be a feasible place.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138515/new/

https://reviews.llvm.org/D138515



More information about the llvm-commits mailing list