[clang] Frontend components for the relative vtables ABI
authorLeonard Chan <leonardchan@google.com>
Wed, 10 Jun 2020 19:48:10 +0000 (12:48 -0700)
committerLeonard Chan <leonardchan@google.com>
Wed, 10 Jun 2020 19:48:10 +0000 (12:48 -0700)
commit2e009dbcb3e373a59e6e84dce6d51ae8a29f60a5
tree4d9760aba6e24dd99308be026eab837d4aa461da
parentc5bbdea9e120dda9632a71708a852cb32317ed92
[clang] Frontend components for the relative vtables ABI

This patch contains all of the clang changes from D72959.

- Generalize the relative vtables ABI such that it can be used by other targets.
- Add an enum VTableComponentLayout which controls whether components in the
  vtable should be pointers to other structs or relative offsets to those structs.
  Other ABIs can change this enum to restructure how components in the vtable
  are laid out/accessed.
- Add methods to ConstantInitBuilder for inserting relative offsets to a
  specified position in the aggregate being constructed.

See D72959 for background info.

Differential Revision: https://reviews.llvm.org/D77592
41 files changed:
clang/include/clang/AST/VTableBuilder.h
clang/include/clang/Basic/LangOptions.def
clang/include/clang/CodeGen/ConstantInitBuilder.h
clang/include/clang/Driver/Options.td
clang/lib/AST/ASTContext.cpp
clang/lib/AST/VTableBuilder.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CGVTables.h
clang/lib/CodeGen/ConstantInitBuilder.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/cross-tu-header.h [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/inline-virtual-function.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/member-function-pointer.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/no-alias-when-dso-local.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/no-stub-when-dso-local.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/override-pure-virtual-method.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/overriden-virtual-function.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-flag.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/thunk-mangling.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/vbase-offset.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/virtual-function-call.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/RelativeVTablesABI/vtable-hidden-when-in-comdat.cpp [new file with mode: 0644]