[llvm] Teach whole program devirtualization about relative vtables
authorLeonard Chan <leonardchan@google.com>
Mon, 26 Sep 2022 20:27:09 +0000 (20:27 +0000)
committerLeonard Chan <leonardchan@google.com>
Thu, 23 Feb 2023 22:18:43 +0000 (22:18 +0000)
commitdb288184765c0b4010060ebea1f6de3ac1f66445
treec1281fa2a906820a663728039f503f5bfa428249
parentbbddaad6e8598f3af80cb185a96162da474792da
[llvm] Teach whole program devirtualization about relative vtables

Prior to this patch, WPD was not acting on relative-vtables in C++. This
involves teaching WPD about these things:

- llvm.load.relative which is how relative-vtables are indexed (instead of GEP)
- dso_local_equivalent which is used in the vtable itself when taking the
  offset between a virtual function and vtable
- Update llvm/test/ThinLTO/X86/devirt.ll to use opaque pointers and add
  equivalent tests for RV

Differential Revision: https://reviews.llvm.org/D134320
12 files changed:
llvm/include/llvm/Analysis/TypeMetadataUtils.h
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/lib/Analysis/TypeMetadataUtils.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/test/ThinLTO/X86/devirt.ll
llvm/test/Transforms/WholeProgramDevirt/Inputs/export.yaml
llvm/test/Transforms/WholeProgramDevirt/branch-funnel.ll
llvm/test/Transforms/WholeProgramDevirt/constant-arg.ll
llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl-check.ll
llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl-multiple-assumes.ll
llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl.ll
llvm/test/Transforms/WholeProgramDevirt/pointer-vtable.ll