[PATCH] D39484: LTO: Apply global DCE to ThinLTO modules at LTO opt level 0.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 17:11:06 PDT 2017


pcc created this revision.
Herald added subscribers: hiraditya, mehdi_amini.

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.


https://reviews.llvm.org/D39484

Files:
  llvm/lib/LTO/LTO.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/test/LTO/Resolution/X86/Inputs/dead-strip-fulllto.ll
  llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39484.121090.patch
Type: text/x-patch
Size: 5870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171101/eb600cf2/attachment.bin>


More information about the llvm-commits mailing list