[PATCH] D88861: GC-parseable element atomic memcpy/memmove

Artur Pilipenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 16:39:33 PDT 2020


apilipenko created this revision.
apilipenko added reviewers: reames, skatkov, fedor.sergeev, yrouban.
Herald added subscribers: dantrushin, jfb, hiraditya.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.
apilipenko requested review of this revision.

This change introduces a GC parseable lowering for element atomic memcpy/memmove intrinsics. This way runtime can provide an implementation which can take a safepoint during copy operation. See "GC-parseable element atomic memcpy/memmove" thread on llvm-dev for the background and details:
https://groups.google.com/g/llvm-dev/c/NnENHzmX-b8/m/3PyN8Y2pCAAJ

This lowering involves three things:

1. The call is wrapped into a statepoint.
2. The call is lowered to a different symbol `__llvm_{memcpy|memmove}_element_unordered_atomic_safepoint_<element_size>`.
3. The arguments for the call are adjusted so as to make the base pointers available in the copy function.

In order to be consistent with other calls by default element atomic memcpy/memmove intrinsics are treated as non-leaf. So, by default GC parseable lowering is generated. Old GC leaf lowering will be generated if the call is explicitly marked "gc-leaf-function" attribute.

This default choice though introduces a minor transitioning issue. In some systems, e.g. ours, GC safepoints are coupled with deoptimization mechanism (this is controlled by a cl::opt `rs4gc-allow-statepoint-with-no-deopt-info`). In this case we can't have a statepoint without deopt information. Normally it's up to the frontend to make sure that non-leaf calls also have proper deopt state. But element atomic memcpy/memmove intrinsic calls might be generated by the optimizer, which is not aware of this coupling. If statepoints without deopt into are not allowed and we see a non-leaf memcpy/memmove without deopt state we treat it as a leaf copy and don't produce a statepoint.


https://reviews.llvm.org/D88861

Files:
  llvm/docs/LangRef.rst
  llvm/docs/Statepoints.rst
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/test/Transforms/RewriteStatepointsForGC/unordered-atomic-memcpy-no-deopt.ll
  llvm/test/Transforms/RewriteStatepointsForGC/unordered-atomic-memcpy.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88861.296328.patch
Type: text/x-patch
Size: 33129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201005/23751d71/attachment.bin>


More information about the llvm-commits mailing list