This is an archive of the discontinued LLVM Phabricator instance.

[LTO] Fix commons handling
ClosedPublic

Authored by mehdi_amini on Sep 13 2016, 10:21 PM.

Details

Summary

Previously the prevailing information was not honored, and commons
symbols could override a strong definition. This patch fixes it and
propose the following semantic for commons: the client should mark
as prevailing the commons that it expects the LTO implementation to
merge (i.e. take the maximum size and alignment).
It implies that commons are allowed to have multiple prevailing
definitions.

Diff Detail

Repository
rL LLVM

Event Timeline

mehdi_amini retitled this revision from to [LTO] Fix commons handling.
mehdi_amini updated this object.
mehdi_amini added a reviewer: pcc.
mehdi_amini added a subscriber: llvm-commits.
pcc edited edge metadata.Sep 14 2016, 12:21 PM

The problem with this solution is that it requires the client to report all instances of the common symbol as prevailing. gold reports a single instance of the symbol as prevailing, and it won't necessarily be the first one. So the gold plugin can't know whether to report any given non-prevailing common symbol as prevailing since it doesn't know whether the eventual prevailing instance will be common or not. That's what the CommonResolution::Prevailing bit was tracking in the original gold plugin code. I think we'll need something similar here.

mehdi_amini edited edge metadata.

Change the API contract: if a least one instance of a common symbol is marked as prevailing, make sure it has the max(size) and max(alignment) over all the common instance for this symbol.

pcc added inline comments.Sep 14 2016, 1:51 PM
lib/LTO/LTO.cpp
357 ↗(On Diff #71415)

Please update this comment.

test/tools/llvm-lto2/X86/common.ll
57 ↗(On Diff #71415)

Please also add a test with a single common marked as prevailing.

Update comment

test/tools/llvm-lto2/X86/common.ll
57 ↗(On Diff #71425)

Isn't is already what LARGE-PREVAILED and SMALL-PREVAILED are?

pcc accepted this revision.Sep 14 2016, 2:03 PM
pcc edited edge metadata.

LGTM

Isn't is already what LARGE-PREVAILED and SMALL-PREVAILED are?

Yes, sorry, I missed those.

One other thing: the test you are updating should live in test/LTO/Resolution/X86 because it is testing the API rather than the command line tool.

This revision is now accepted and ready to land.Sep 14 2016, 2:03 PM
This revision was automatically updated to reflect the committed changes.