[PATCH] D22356: [ThinLTO] Perform index-based weak/linkonce resolution in import pass

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 07:43:39 PDT 2016


tejohnson created this revision.
tejohnson added a reviewer: mehdi_amini.
tejohnson added a subscriber: llvm-commits.
tejohnson added a dependency: D22302: [ThinLTO/gold] Perform index-based weak/linkonce resolution.
Herald added a subscriber: mehdi_amini.

This enables weak/linkonce resolution in ThinLTO distributed
backends, which use the FunctionImportPass. It will also enable removal
of the support/flags for force-linking LinkOnceODR symbols, since all
paths now use index-based resolution (will be done in follow-on patch).

One tricky aspect of the weak/linkonce resolution in the distributed
backend case occurs if the link involves --start-lib/--end-lib with some
of the object files. Because there are two separate links (the ThinLink
and then the final native link), depending on the intervening importing
and inlining we can get into a situation where the linkonce selected
as prevailing in the ThinLink is no longer linked in by the second link.
The linker will only pull symbols from an archive library, in this
case formed via --start-lib/--end-lib, if there is a strong reference
to a symbol in that library from a library/object listed earlier in the
link, which may no longer be the case after importing etc. Note that
the gold-plugin does not know whether the objects are in a library
formed by --start-lib/--end-lib. To handle this, I added a new
PreserveNonPrevailing flag to thinLTOResolveWeakForLinkerInIndex.
When that flag is enabled, it will conservatively prevent conversion
of non-prevailing symbols to available_externally, and will promote
exported non-prevailing linkonce to weak to ensure they are not
eliminated after inlining. The new thinlto_preserve_nonprevailodr.ll
test case ensures this works (and fails without this new flag).

Note this required adding back the isExported callback to
thinLTOResolveWeakForLinkerInIndex (e.g. the changes in
ThinLTOCodeGenerator.cpp).

Depends on D22302.

https://reviews.llvm.org/D22356

Files:
  include/llvm/LTO/LTO.h
  lib/LTO/LTO.cpp
  lib/LTO/ThinLTOCodeGenerator.cpp
  lib/Transforms/IPO/FunctionImport.cpp
  test/tools/gold/X86/Inputs/thinlto_preserve_nonprevailodr-1.ll
  test/tools/gold/X86/Inputs/thinlto_preserve_nonprevailodr-2.ll
  test/tools/gold/X86/Inputs/thinlto_preserve_nonprevailodr-3.ll
  test/tools/gold/X86/thinlto_preserve_nonprevailodr.ll
  tools/gold/gold-plugin.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22356.63972.patch
Type: text/x-patch
Size: 16321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160714/3f738030/attachment.bin>


More information about the llvm-commits mailing list