[PATCH] D100445: [RS4GC] Introduce intrinsics to get base ptr and offset

Yevgeny Rouban via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 13 22:10:12 PDT 2021


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

There can be a need for some optimizations to get (base, offset) for any GC pointer. The base can be calculated by generating needed instructions as it is done by the //RewriteStatepointsForGC::findBasePointer()// function. The offset can be calculated in the same way. Though to not expose the base calculation and to make the offset calculation as simple as //ptrtoint(derived_ptr) - ptrtoint(base_ptr)//, which is illegal outside RS4GC, this patch introduces 2 intrinsics:

- declare i8 addrspace(1)* @llvm.experimental.gc.get.pointer.base(i8 addrspace(1)* readnone nocapture %base_ptr) nounwind readnone willreturn "gc-leaf-function"
- declare i64 @llvm.experimental.gc.get.pointer.offset(i8 addrspace(1)* readnone nocapture %base_ptr) nounwind readnone willreturn "gc-leaf-function"

These intrinsics are inlined by RS4GC along with generation of statepoint sequences.

With these new intrinsics the GC parseable lowering for atomic memcpy intrinsics (D88861 <https://reviews.llvm.org/D88861>) could be implemented as a separate pass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100445

Files:
  llvm/docs/Statepoints.rst
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/test/Transforms/RewriteStatepointsForGC/intrinsics.ll
  llvm/utils/TableGen/CodeGenIntrinsics.h
  llvm/utils/TableGen/CodeGenTarget.cpp
  llvm/utils/TableGen/IntrinsicEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100445.337327.patch
Type: text/x-patch
Size: 26129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210414/df62dacd/attachment.bin>


More information about the llvm-commits mailing list