[all-commits] [llvm/llvm-project] 2eade1: [WPD] Use new llvm.public.type.test intrinsic for ...

aeubanks via All-commits all-commits at lists.llvm.org
Tue Jul 26 08:02:03 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2eade1dba4a8d6e1c6867e9127bcd88cf4e55976
  Author: Arthur Eubanks <aeubanks at google.com>
  Date:   2022-07-26 (Tue, 26 Jul 2022)

  Changed paths:
    M clang/lib/CodeGen/CGClass.cpp
    M clang/lib/CodeGen/ItaniumCXXABI.cpp
    M clang/test/CodeGenCXX/cfi-mfcall.cpp
    M clang/test/CodeGenCXX/thinlto-distributed-type-metadata.cpp
    A clang/test/CodeGenCXX/thinlto_public_type_test_distributed.ll
    M clang/test/CodeGenCXX/type-metadata.cpp
    A lld/test/ELF/lto/update_public_type_test.ll
    M llvm/include/llvm/IR/Intrinsics.td
    M llvm/include/llvm/IR/ModuleSummaryIndex.h
    M llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
    M llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
    M llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
    M llvm/lib/Analysis/TypeMetadataUtils.cpp
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/IR/ModuleSummaryIndex.cpp
    M llvm/lib/LTO/LTO.cpp
    M llvm/lib/LTO/LTOBackend.cpp
    M llvm/lib/LTO/LTOCodeGenerator.cpp
    M llvm/lib/LTO/ThinLTOCodeGenerator.cpp
    M llvm/lib/Transforms/IPO/LowerTypeTests.cpp
    M llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
    M llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
    A llvm/test/LTO/X86/public-type-test.ll
    M llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
    A llvm/test/ThinLTO/X86/public-type-test.ll
    M llvm/tools/llvm-lto/llvm-lto.cpp

  Log Message:
  [WPD] Use new llvm.public.type.test intrinsic for potentially publicly visible classes

Turning on opaque pointers has uncovered an issue with WPD where we currently pattern match away `assume(type.test)` in WPD so that a later LTT doesn't resolve the type test to undef and introduce an `assume(false)`. The pattern matching can fail in cases where we transform two `assume(type.test)`s into `assume(phi(type.test.1, type.test.2))`.

Currently we create `assume(type.test)` for all virtual calls that might be devirtualized. This is to support `-Wl,--lto-whole-program-visibility`.

To prevent this, all virtual calls that may not be in the same LTO module instead use a new `llvm.public.type.test` intrinsic in place of the `llvm.type.test`. Then when we know if `-Wl,--lto-whole-program-visibility` is passed or not, we can either replace all `llvm.public.type.test` with `llvm.type.test`, or replace all `llvm.public.type.test` with `true`. This prevents WPD from trying to pattern match away `assume(type.test)` for public virtual calls when failing the pattern matching will result in miscompiles.

Reviewed By: tejohnson

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

More information about the All-commits mailing list