[PATCH] D87154: [WIP][Statepoints] Change statepoint machine instr format to better suit VReg lowering.

Denis Antrushin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 4 11:46:06 PDT 2020


dantrushin created this revision.
dantrushin added reviewers: reames, skatkov.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
dantrushin requested review of this revision.

Current Statepoint MI format is this:

  STATEPOINT
  <id>, <num patch bytes >, <num call arguments>, <call target>,
  [call arguments...],
  <StackMaps::ConstantOp>, <calling convention>,
  <StackMaps::ConstantOp>, <statepoint flags>,
  <StackMaps::ConstantOp>, <num deopt args>, [deopt args...],
  <gc base/derived pairs...> <gc allocas...>

Note that GC pointers are listed in pairs <base,derived>.
This causes base pointers to appear many times (at least twice) in
instruction, which is bad for us.
The problem is that machine operand tiedness is 1-1 relation, so
it might look like this:

  %vr2 = STATEPOINT ... %vr1, %vr1(tied-def0)

Since only one instance of %vr1 is tied, that may lead to incorrect
codegen (see PR46917 for more details), so we have to always spill
base pointers. This mostly defeats new VReg lowering scheme.

This patch changes statepoint instruction format so that every
gc pointer appears only once in operand list, so that they all can
be tied. Additional set of operands is added to preserve base-derived
relation required to build stackmap.
New statepoint looks like this:

  STATEPOINT
  <id>, <num patch bytes>, <num call arguments>, <call target>,
  [call arguments...],
  <StackMaps::ConstantOp>, <calling convention>,
  <StackMaps::ConstantOp>, <statepoint flags>,
  <StackMaps::ConstantOp>, <num deopt args>, [deopt args...],
  <StackMaps::ConstantOp>, <num gc pointers>, [gc pointers...],
  <StackMaps::ConstantOp>, <num gc allocas>,  [gc allocas...]
  <num entries in gc map>, <base/derived indices...>

Changes are:

- every gc pointer is listed only once  in a flat list, prefixed with its length;
- alloca list is prefixed with its length too;
- following alloca list is length-prefixed list of base-derived indices of pointers from gc pointer list. Note that indices are logical (number of pointer), not absolute (index of machine operand). Length of map is a bare constant, not encoded in stackmap format.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87154

Files:
  llvm/include/llvm/CodeGen/StackMaps.h
  llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
  llvm/lib/CodeGen/StackMaps.cpp
  llvm/test/CodeGen/X86/statepoint-stack-usage.ll
  llvm/test/CodeGen/X86/statepoint-vector.ll
  llvm/test/CodeGen/X86/statepoint-vreg-details.ll
  llvm/test/CodeGen/X86/statepoint-vreg.ll
  llvm/test/CodeGen/X86/statepoint-vreg.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87154.290002.patch
Type: text/x-patch
Size: 49746 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200904/e6dcffca/attachment-0001.bin>


More information about the llvm-commits mailing list