[PATCH] D81603: [WIP] MIR Statepoint refactoring: Pass GC pointergs in VRegs.

Denis Antrushin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 11:08:18 PDT 2020


dantrushin created this revision.
dantrushin added reviewers: reames, skatkov, anna.
Herald added subscribers: llvm-commits, hiraditya, qcolombet, MatzeB.
Herald added a project: LLVM.

In current implementation we spill Statepoint's GC arguments into
stack slots and then reload them at corresponding gc.relocate
location. That works reasonably well for small functions/GC sets,
but when register pressure gets high of GC pointer sets grows
large, this causes ugly code, because those spills are not understood
by the register allocator and we end up with reloads from spill
locations which immediately get spilled into statepoint slots.

This change insroduces new form of STATEPOINT instruction:
GC arguments are passed on VRegs and STATEPOINT itself becomes
variadic defs instruction, e.g.:

  rel1,rel2,... = STATEPOINT ..., derived1<tied-def0>, derived2<tied-def1>, ...

Then register allocator can spill/fold them as it sees appropriate.
If target runtime/GC does not support GC support GC objects in
registers, FixupStatepointCallerSaves pass is extended to spill
them (optionally allowing these pointers to stay in CSRs).

Due to SDNode memory menagement, we use simple scheme to decide
which GC pointers pass in VRegs: just take first N.
For that to work, we sort GC derived pointers to have those not
needing relocation (e.g., constants) at the end of GC arguments
list.
`N` is further limited by maximal amount of tied registers machine
instruction can have (15 at the moment).

For more context/details about statepoints see documentation at
https://llvm.org/docs/Statepoints.html
https://llvm.org/docs/GarbageCollection.html

This review includes all changes and aimed to provide full context of
what's being done. It will be committed in smaller parts with separate
smaller reviews for every change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81603

Files:
  llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
  llvm/include/llvm/CodeGen/StackMaps.h
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
  llvm/lib/CodeGen/InlineSpiller.cpp
  llvm/lib/CodeGen/MachineVerifier.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
  llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
  llvm/lib/CodeGen/TargetInstrInfo.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/test/CodeGen/X86/statepoint-call-lowering.ll
  llvm/test/CodeGen/X86/statepoint-duplicates-export.ll
  llvm/test/CodeGen/X86/statepoint-invoke.ll
  llvm/test/CodeGen/X86/statepoint-no-extra-const.ll
  llvm/test/CodeGen/X86/statepoint-regs.ll
  llvm/test/CodeGen/X86/statepoint-uniqueing.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81603.269912.patch
Type: text/x-patch
Size: 86034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200610/1c5e865e/attachment-0001.bin>


More information about the llvm-commits mailing list