Page MenuHomePhabricator

[GlobalDCE] In VFE support for relative pointers, allow GEP references to the base symbol
ClosedPublic

Authored by kubamracek on Sep 2 2021, 9:54 AM.

Details

Summary

This is for Swift VFE support. In some vtable forms that Swift emits, the "base" of a relative pointer is not the global symbol itself directly, but a GEP into it -- so the pointer is relative to a particular field in the global. So getPointerAtOffset() needs to be able to see through the GEP and allow it in a SUB expression, to correctly recognize the offset as a vtable slot.

Diff Detail

Event Timeline

kubamracek created this revision.Sep 2 2021, 9:54 AM
kubamracek requested review of this revision.Sep 2 2021, 9:54 AM
fhahn accepted this revision.Sep 13 2021, 8:40 AM

LGTM, thanks!

llvm/lib/Analysis/TypeMetadataUtils.cpp
129

given that this is only used at a single point, maybe define it as a lambda at the use, so all the swift specific code is kept close together?

llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-gep.ll
2

new tests probably should use the new pm syntax (-passes='globaldce')

This revision is now accepted and ready to land.Sep 13 2021, 8:40 AM
This revision was landed with ongoing or failed builds.Sep 13 2021, 3:22 PM
This revision was automatically updated to reflect the committed changes.