[all-commits] [llvm/llvm-project] 0923a6: [clang] Emit type metadata on available_externally...

Teresa Johnson via All-commits all-commits at lists.llvm.org
Fri Feb 19 12:43:11 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0923a60ea70f884d2f170f65d0faa494a25af231
      https://github.com/llvm/llvm-project/commit/0923a60ea70f884d2f170f65d0faa494a25af231
  Author: Teresa Johnson <tejohnson at google.com>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M clang/lib/CodeGen/ItaniumCXXABI.cpp
    M clang/test/CodeGenCXX/type-metadata.cpp

  Log Message:
  -----------
  [clang] Emit type metadata on available_externally vtables for WPD

When WPD is enabled, via WholeProgramVTables, emit type metadata for
available_externally vtables. Additionally, add the vtables to the
llvm.compiler.used global so that they are not prematurely eliminated
(before *LTO analysis).

This is needed to avoid devirtualizing calls to a function overriding a
class defined in a header file but with a strong definition in a shared
library. Without type metadata on the available_externally vtables from
the header, the WPD analysis never sees what a derived class is
overriding. Even if the available_externally base class functions are
pure virtual, because shared library definitions are already treated
conservatively (committed patches D91583, D96721, and D96722) we will
not devirtualize, which would be unsafe since the library might contain
overrides that aren't visible to the LTO unit.

An example is std::error_category, which is overridden in LLVM
and causing failures after a self build with WPD enabled, because
libstdc++ contains hidden overrides of the virtual base class methods.

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




More information about the All-commits mailing list