This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO/gold] Change preempted def to avail extern linkage when possible
AbandonedPublic

Authored by tejohnson on Mar 31 2016, 1:40 PM.

Details

Summary

Similar to the approach being discussed for libLTO in D18346,
optimize the ThinLTO backend compilations and object files by converting
preempted weak and linkonce symbols to available_externally when
possible. This ensures that they are dropped and don't unnecessarily
show up in the object file.

Diff Detail

Event Timeline

tejohnson updated this revision to Diff 52279.Mar 31 2016, 1:40 PM
tejohnson retitled this revision from to [ThinLTO/gold] Change preempted def to avail extern linkage when possible.
tejohnson updated this object.
tejohnson added reviewers: rafael, mehdi_amini.
tejohnson added a subscriber: llvm-commits.
tejohnson updated this revision to Diff 52699.Apr 5 2016, 9:02 AM
As discussed in D18346, alias/aliasee cannot be available_externally.

Augmented test with alias case.
rafael added inline comments.Apr 5 2016, 1:25 PM
tools/gold/gold-plugin.cpp
779

It is OK to have available_externally to a comdat member, no?

I mean, it is equivalent to a declaration, and we can have a declaration to a comdat member.

rafael edited edge metadata.Apr 5 2016, 1:35 PM

trying to get phab to send an email.

tejohnson added inline comments.Apr 5 2016, 1:45 PM
tools/gold/gold-plugin.cpp
779

You can't have a declaration or available_externally in a comdat. From Verifier.cpp:

if (GV.isDeclarationForLinker())
  Assert(!GV.hasComdat(), "Declaration may not be in a Comdat!", &GV);
tejohnson updated this revision to Diff 52785.Apr 6 2016, 6:23 AM
tejohnson edited edge metadata.
  • Handle comdat members
rafael added inline comments.May 16 2016, 8:52 AM
test/tools/gold/X86/thinlto_linkonceresolution.ll
28

It just be just extern, not extern_weak, no?

tools/gold/gold-plugin.cpp
785

If the alias is preempted, you can turn it to a global variable declaration.

843

You can always set the comdat to null, so I would drop this if.

tejohnson abandoned this revision.May 27 2016, 2:21 PM

Thanks for the review. I'm going to abandon these however and instead use the support I just refactored out of ThinLTOCodeGenerator in r270698, which will do the same using a callback to get info about prevailing symbols.

test/tools/gold/X86/thinlto_linkonceresolution.ll
28

Yes, this line was changed in r266752 after Mehdi changed this in the ModuleLinker, but I hadn't rebased for awhile.

tools/gold/gold-plugin.cpp
785

True, but that would prevent inlining. Probably better to keep the inlining opportunity intact.