[GlobalDCE] In VFE support for relative pointers, allow GEP references to the base...
authorKuba Mracek <mracek@apple.com>
Mon, 13 Sep 2021 21:44:49 +0000 (14:44 -0700)
committerKuba Mracek <mracek@apple.com>
Mon, 13 Sep 2021 22:22:11 +0000 (15:22 -0700)
commite80ee4cbd9a79efa99cabdbb42faba7c7b01e70e
tree44bf62747bb88f2317502bd4d78a439736e51b4b
parentb2032f18c9dec45a9cb4163136fa9dcbe256e772
[GlobalDCE] In VFE support for relative pointers, allow GEP references to the base symbol

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.

Differential Revision: https://reviews.llvm.org/D109169
llvm/lib/Analysis/TypeMetadataUtils.cpp
llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-gep.ll [new file with mode: 0644]