Page MenuHomePhabricator

[RS4GC] Introduce intrinsics to get base ptr and offset
Needs ReviewPublic

Authored by yrouban on Tue, Apr 13, 10:10 PM.

Details

Summary

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) could be implemented as a separate pass.

Diff Detail

Event Timeline

yrouban created this revision.Tue, Apr 13, 10:10 PM
yrouban requested review of this revision.Tue, Apr 13, 10:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptTue, Apr 13, 10:10 PM
Herald added a subscriber: jdoerfert. · View Herald Transcript