[LowerTypeTests] Limit when icall jumptable entries are emitted
authorVlad Tsyrklevich <vlad@tsyrklevich.net>
Fri, 13 Jul 2018 19:57:39 +0000 (19:57 +0000)
committerVlad Tsyrklevich <vlad@tsyrklevich.net>
Fri, 13 Jul 2018 19:57:39 +0000 (19:57 +0000)
commitcd1559366d835d7e5263f1fde369dc78e51c5b23
tree5d064a0028854bbb6d481d53ec621465c77c23c9
parentbe9a9fd3dd8fdabb78566bea93baa33b22999d10
[LowerTypeTests] Limit when icall jumptable entries are emitted

Summary:
Currently LowerTypeTests emits jumptable entries for all live external
and address-taken functions; however, we could limit the number of
functions that we emit entries for significantly.

For Cross-DSO CFI, we continue to emit jumptable entries for all
exported definitions.  In the non-Cross-DSO CFI case, we only need to
emit jumptable entries for live functions that are address-taken in live
functions. This ignores exported functions and functions that are only
address taken in dead functions. This change uses ThinLTO summary data
(now emitted for all modules during ThinLTO builds) to determine
address-taken and liveness info.

The logic for emitting jumptable entries is more conservative in the
regular LTO case because we don't have summary data in the case of
monolithic LTO builds; however, once summaries are emitted for all LTO
builds we can unify the Thin/monolithic LTO logic to only use summaries
to determine the liveness of address taking functions.

This change is a partial fix for PR37474. It reduces the build size for
nacl_helper by ~2-3%, the reduction is due to nacl_helper compiling in
lots of unused code and unused functions that are address taken in dead
functions no longer being being considered live due to emitted jumptable
references. The reduction for chromium is ~0.1-0.2%.

Reviewers: pcc, eugenis, javed.absar

Reviewed By: pcc

Subscribers: aheejin, dexonsmith, dschuff, mehdi_amini, eraman, steven_wu, llvm-commits, kcc

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

llvm-svn: 337038
13 files changed:
llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/test/LTO/Resolution/X86/export-jumptable.ll
llvm/test/ThinLTO/X86/cfi-icall.ll
llvm/test/Transforms/LowerTypeTests/Inputs/export-icall.yaml [new file with mode: 0644]
llvm/test/Transforms/LowerTypeTests/Inputs/exported-funcs.yaml [new file with mode: 0644]
llvm/test/Transforms/LowerTypeTests/export-alias.ll
llvm/test/Transforms/LowerTypeTests/export-cross-dso-cfi.ll [new file with mode: 0644]
llvm/test/Transforms/LowerTypeTests/export-icall.ll
llvm/test/Transforms/LowerTypeTests/export-symver.ll
llvm/test/Transforms/LowerTypeTests/function-arm-thumb.ll
llvm/test/Transforms/LowerTypeTests/function-ext.ll
llvm/test/Transforms/LowerTypeTests/pr37625.ll