[all-commits] [llvm/llvm-project] 6385c1: [clang] Add experimental option to omit the RTTI c...

PiJoules via All-commits all-commits at lists.llvm.org
Wed Sep 13 16:18:26 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6385c1df919f237d4149fabf542a158f61010bf8
      https://github.com/llvm/llvm-project/commit/6385c1df919f237d4149fabf542a158f61010bf8
  Author: Leonard Chan <leonardchan at google.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/include/clang/Basic/LangOptions.def
    M clang/include/clang/Driver/Options.td
    M clang/lib/AST/VTableBuilder.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp
    A clang/test/CodeGenCXX/OmitRTTIComponentABI/simple-vtable-definition.cpp
    A clang/test/CodeGenCXX/OmitRTTIComponentABI/vbase-offset.cpp
    A clang/test/CodeGenCXX/OmitRTTIComponentABI/vtable-layout.cpp
    A clang/test/Driver/omit-rtti-component-flag.cpp
    A clang/test/Driver/omit-rtti-component-without-no-rtti.cpp

  Log Message:
  -----------
  [clang] Add experimental option to omit the RTTI component from the vtable when -fno-rtti is used

For programs that don't use RTTI, the rtti component is just replaced with a
zero. This way, vtables that don't use RTTI can still cooperate with vtables
that use RTTI since offset calculations on the ABI level would still work.
However, if throughout your whole program you don't use RTTI at all (such as
the embedded case), then this is just an unused pointer-sized component that's
wasting space. This adds an experimental option for removing the RTTI component
from the vtable.

Some notes:
- This is only allowed when RTTI is disabled, so we don't have to worry about
  things like `typeid` or `dynamic_cast`.
- This is a "use at your own risk" since, similar to relative vtables, everything
  must be compiled with this since it's an ABI breakage. That is, a program compiled
  with this is not guaranteed to work with a program compiled without this, even
  if RTTI is disabled for both programs.

Note that this is a completely different ABI flavor orthogonal to the
relative-vtables ABI. That is, they can be enabled/disabled independently.

Differential Revision: https://reviews.llvm.org/D152405




More information about the All-commits mailing list