[all-commits] [llvm/llvm-project] 458676: [WPD/VFE] Always emit vcall_visibility metadata fo...

Teresa Johnson via All-commits all-commits at lists.llvm.org
Thu Jan 23 11:36:14 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 458676db6e41e3942a3b9498f6ba90e956897c2a
      https://github.com/llvm/llvm-project/commit/458676db6e41e3942a3b9498f6ba90e956897c2a
  Author: Teresa Johnson <tejohnson at google.com>
  Date:   2020-01-23 (Thu, 23 Jan 2020)

  Changed paths:
    M clang/lib/CodeGen/CGVTables.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
    M llvm/include/llvm/IR/GlobalObject.h
    M llvm/lib/IR/Metadata.cpp
    M llvm/lib/Transforms/IPO/GlobalDCE.cpp
    M llvm/lib/Transforms/IPO/GlobalSplit.cpp
    M llvm/test/Transforms/GlobalDCE/virtual-functions-base-call.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-base-pointer-call.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-derived-call.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-derived-pointer-call.ll
    A llvm/test/Transforms/GlobalDCE/virtual-functions-novfe.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions.ll
    M llvm/test/Transforms/GlobalDCE/vtable-rtti.ll
    M llvm/test/Transforms/GlobalSplit/basic.ll

  Log Message:
  -----------
  [WPD/VFE] Always emit vcall_visibility metadata for -fwhole-program-vtables

Summary:
First patch to support Safe Whole Program Devirtualization Enablement,
see RFC here: http://lists.llvm.org/pipermail/llvm-dev/2019-December/137543.html

Always emit !vcall_visibility metadata under -fwhole-program-vtables,
and not just for -fvirtual-function-elimination. The vcall visibility
metadata will (in a subsequent patch) be used to communicate to WPD
which vtables are safe to devirtualize, and we will optionally convert
the metadata to hidden visibility at link time. Subsequent follow on
patches will help enable this by adding vcall_visibility metadata to the
ThinLTO summaries, and always emit type test intrinsics under
-fwhole-program-vtables (and not just for vtables with hidden
visibility).

In order to do this safely with VFE, since for VFE all vtable loads must
be type checked loads which will no longer be the case, this patch adds
a new "Virtual Function Elim" module flag to communicate to GlobalDCE
whether to perform VFE using the vcall_visibility metadata.

One additional advantage of using the vcall_visibility metadata to drive
more WPD at LTO link time is that we can use the same mechanism to
enable more aggressive VFE at LTO link time as well. The link time
option proposed in the RFC will convert vcall_visibility metadata to
hidden (aka linkage unit visibility), which combined with
-fvirtual-function-elimination will allow it to be done more
aggressively at LTO link time under the same conditions.

Reviewers: pcc, ostannard, evgeny777, steven_wu

Subscribers: mehdi_amini, Prazek, hiraditya, dexonsmith, davidxl, cfe-commits, llvm-commits

Tags: #clang, #llvm

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




More information about the All-commits mailing list