]> granicus.if.org Git - llvm/commit
LTO: Apply global DCE to ThinLTO modules at LTO opt level 0.
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 1 Nov 2017 17:58:39 +0000 (17:58 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 1 Nov 2017 17:58:39 +0000 (17:58 +0000)
commitf284f00fe090463d4d64151585be85ba72cc38ec
treec04c5331556049934220092c0d98d6a889d011d1
parentfa81b6ba937a76f7d05c224ec5ae20099734c052
LTO: Apply global DCE to ThinLTO modules at LTO opt level 0.

This is necessary because DCE is applied to full LTO modules. Without
this change, a reference from a dead ThinLTO global to a dead full
LTO global will result in an undefined reference at link time.

This problem is only observable when --gc-sections is disabled, or
when targeting COFF, as the COFF port of lld requires all symbols to
have a definition even if all references are dead (this is consistent
with link.exe).

This change also adds an EliminateAvailableExternally pass at -O0. This
is necessary to handle the situation on Windows where a non-prevailing
copy of a linkonce_odr function has an SEH filter function; any
such filters must be DCE'd because they will contain a call to the
llvm.localrecover intrinsic, passing as an argument the address of the
function that the filter belongs to, and llvm.localrecover requires
this function to be defined locally.

Fixes PR35142.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317108 91177308-0d34-0410-b5e6-96231b3b80d8
lib/LTO/LTO.cpp
lib/Transforms/IPO/PassManagerBuilder.cpp
test/LTO/Resolution/X86/Inputs/dead-strip-fulllto.ll
test/LTO/Resolution/X86/dead-strip-fulllto.ll