[ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols
authorSteven Wu <stevenwu@apple.com>
Wed, 17 Apr 2019 17:38:09 +0000 (17:38 +0000)
committerSteven Wu <stevenwu@apple.com>
Wed, 17 Apr 2019 17:38:09 +0000 (17:38 +0000)
commit05a358cdcd55d1ee0a0d92383aa49489479c6362
tree57f42ce4fb1e42147599b47628fea5274857ed02
parent88679717ce44dc31dcb87dc5f0206e9e3348001a
[ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols

Summary:
Reapply r357931 with fixes to ThinLTO testcases and llvm-lto tool.

ThinLTOCodeGenerator currently does not preserve llvm.used symbols and
it can internalize them. In order to pass the necessary information to the
legacy ThinLTOCodeGenerator, the input to the code generator is
rewritten to be based on lto::InputFile.

Now ThinLTO using the legacy LTO API will requires data layout in
Module.

"internalize" thinlto action in llvm-lto is updated to run both
"promote" and "internalize" with the same configuration as
ThinLTOCodeGenerator. The old "promote" + "internalize" option does not
produce the same output as ThinLTOCodeGenerator.

This fixes: PR41236
rdar://problem/49293439

Reviewers: tejohnson, pcc, kromanova, dexonsmith

Reviewed By: tejohnson

Subscribers: ormris, bd1976llvm, mehdi_amini, inglorion, eraman, hiraditya, jkorous, dexonsmith, arphaman, dang, llvm-commits

Tags: #llvm

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

llvm-svn: 358601
26 files changed:
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/test/Bitcode/Inputs/module_hash.ll
llvm/test/Bitcode/module_hash.ll
llvm/test/ThinLTO/X86/Inputs/alias_import.ll
llvm/test/ThinLTO/X86/Inputs/alias_resolution.ll
llvm/test/ThinLTO/X86/Inputs/distributed_indexes.ll
llvm/test/ThinLTO/X86/Inputs/merge-triple.ll
llvm/test/ThinLTO/X86/Inputs/section.ll
llvm/test/ThinLTO/X86/Inputs/thinlto-internalize-used2.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/alias_import.ll
llvm/test/ThinLTO/X86/alias_resolution.ll
llvm/test/ThinLTO/X86/deadstrip.ll
llvm/test/ThinLTO/X86/distributed_indexes.ll
llvm/test/ThinLTO/X86/internalize.ll
llvm/test/ThinLTO/X86/linkonce_odr_unnamed_addr.ll
llvm/test/ThinLTO/X86/merge-triple.ll
llvm/test/ThinLTO/X86/prefix_replace.ll
llvm/test/ThinLTO/X86/section.ll
llvm/test/ThinLTO/X86/thinlto-internalize-used.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/weak_resolution.ll
llvm/test/ThinLTO/X86/weak_resolution_single.ll
llvm/test/Transforms/ThinLTOBitcodeWriter/no-type-md.ll
llvm/tools/llvm-lto/llvm-lto.cpp