[PATCH] D20749: Introduce support for relative C++ ABI gated on LTO visibility.

Peter Collingbourne via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 13:55:40 PDT 2016


pcc created this revision.
pcc added reviewers: rsmith, rjmccall, rafael, mehdi_amini, aaron.ballman, majnemer, rnk.
pcc added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

I'd like to propose this patch as an alternative to D17893 and D18199
that approaches the user interface to the relative C++ ABI feature from
a different angle. Instead of adding custom attributes and a whitelist,
we instead introduce a flag, -flto-relative-c++-abi-vtables, which enables
the relative ABI only for classes with hidden LTO visibility [0], which is
a concept we introduced for whole-program devirtualization that is based
on object file visibility. That concept also effectively controls where
the compiler is allowed to change the ABI arbitrarily. By using that very
similar concept, we can start off with a much simpler overall user interface,
at least for programs that are already using LTO.

It may seem strange to tie this feature to LTO visibility (and LTO), since
the feature of course does not intrinsically rely on LTO. However, I think
it seems reasonable for hidden LTO visibility to act as one possible source
of information for where the new ABI can be applied. At a later point we
can consider introducing other ways to enable the ABI (such as specific
attributes or whitelisting as proposed in D17893).

By requiring classes to have hidden visibility (a prerequisite for hidden
LTO visibility), we also avoid being blocked on the issues around non-hidden
visibility in ELF that were raised on the initial discussion thread for this
feature [1].

LTO also makes it a little easier to detect ABI mismatches in a platform
independent way using module flags. This patch introduces a module flag that
is used for that purpose.

[0] http://clang.llvm.org/docs/LTOVisibility.html
[1] http://lists.llvm.org/pipermail/llvm-dev/2016-February/096146.html

http://reviews.llvm.org/D20749

Files:
  docs/UsersManual.rst
  include/clang/AST/DeclCXX.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Sema/Sema.h
  lib/AST/DeclCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CGVTables.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/bitsets.cpp
  test/CodeGenCXX/debug-info-virtual-fn-relative.cpp
  test/CodeGenCXX/vtable-relative-abi.cpp
  test/Driver/unstable-cxx-abi-vtables.cpp
  test/SemaCXX/unstable-cxx-abi.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20749.58834.patch
Type: text/x-patch
Size: 57024 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160527/996146ce/attachment-0001.bin>


More information about the cfe-commits mailing list