[ThinLTO] Remove dead and dropped symbol declarations when possible
authorTeresa Johnson <tejohnson@google.com>
Tue, 6 Feb 2018 00:43:39 +0000 (00:43 +0000)
committerTeresa Johnson <tejohnson@google.com>
Tue, 6 Feb 2018 00:43:39 +0000 (00:43 +0000)
commit791c98e4c82bcaa245c9b57e5d0de1cf1a16e182
tree840c676d316c8a68a2c04c2a6866fc7113be8dd0
parent7b98be2c192ceeccd18daafb5129400866ff5188
[ThinLTO] Remove dead and dropped symbol declarations when possible

Summary:
Removing the dropped symbols will prevent indirect call promotion in the
ThinLTO Backend from adding a new reference to a symbol, which can
result in linker unsats. This can happen when we compile with a sample
profile collected from one binary by used for another, which may have
profiled targets that aren't used in the new binary.

Note that until dropDeadSymbols handles variables and aliases (in
progress), we may not be able to remove the declaration and can still
have an issue.

Reviewers: grimar, davidxl

Subscribers: mehdi_amini, inglorion, llvm-commits, eraman

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

llvm-svn: 324299
llvm/lib/LTO/LTOBackend.cpp
llvm/test/ThinLTO/X86/deadstrip.ll
llvm/test/Transforms/PGOProfile/thinlto_samplepgo_icp_droppeddead.ll [new file with mode: 0644]
llvm/test/tools/gold/X86/global_with_section.ll