[ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlags
authorFangrui Song <i@maskray.me>
Wed, 27 Jan 2021 18:43:51 +0000 (10:43 -0800)
committerFangrui Song <i@maskray.me>
Wed, 27 Jan 2021 18:43:51 +0000 (10:43 -0800)
commit54fb3ca96e261f7107cb1b5778c34cb0e0808be6
tree8d6091e77327a0695d974602db03808433461666
parent0b50fa99452f7f3077e62348b6cf6850a65930af
[ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlags

Imported functions and variable get the visibility from the module supplying the
definition.  However, non-imported definitions do not get the visibility from
(ELF) the most constraining visibility among all modules (Mach-O) the visibility
of the prevailing definition.

This patch

* adds visibility bits to GlobalValueSummary::GVFlags
* computes the result visibility and propagates it to all definitions

Protected/hidden can imply dso_local which can enable some optimizations (this
is stronger than GVFlags::DSOLocal because the implied dso_local can be
leveraged for ELF -shared while default visibility dso_local has to be cleared
for ELF -shared).

Note: we don't have summaries for declarations, so for ELF if a declaration has
the most constraining visibility, the result visibility may not be that one.

Differential Revision: https://reviews.llvm.org/D92900
34 files changed:
llvm/include/llvm/IR/ModuleSummaryIndex.h
llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
llvm/include/llvm/LTO/Config.h
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/Transforms/IPO/FunctionImport.h
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLToken.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/ModuleSummaryIndex.cpp
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Transforms/IPO/FunctionImport.cpp
llvm/test/Assembler/multi-summary-disassemble.ll
llvm/test/Assembler/thinlto-multiple-summaries-for-guid.ll
llvm/test/Assembler/thinlto-summary-visibility.ll [new file with mode: 0644]
llvm/test/Assembler/thinlto-summary.ll
llvm/test/Assembler/thinlto-vtable-summary.ll
llvm/test/Bitcode/thinlto-alias.ll
llvm/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll
llvm/test/Bitcode/thinlto-function-summary-callgraph-relbf.ll
llvm/test/Bitcode/thinlto-function-summary-refgraph.ll
llvm/test/Bitcode/thinlto-type-tests.ll
llvm/test/Bitcode/thinlto-type-vcalls.ll
llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
llvm/test/ThinLTO/X86/load-store-caching.ll
llvm/test/ThinLTO/X86/visibility-elf.ll
llvm/test/ThinLTO/X86/visibility-macho.ll
llvm/test/Transforms/LowerTypeTests/import-unsat.ll
llvm/test/Transforms/WholeProgramDevirt/import-indir.ll
llvm/test/tools/gold/X86/thinlto.ll