Page MenuHomePhabricator

[LTO][ThinLTO] Use the linker resolutions to mark global values as dso_local.

Authored by sfertile on Jul 20 2017, 2:20 PM.

Diff Detail


Event Timeline

sfertile created this revision.Jul 20 2017, 2:20 PM
mehdi_amini edited edge metadata.Jul 20 2017, 10:05 PM

Thanks, I'm glad to see this coming!

691 ↗(On Diff #107501)

This does not seem safe in face of hash collision.

223 ↗(On Diff #107501)

You have a null check here, while the same iteration in LTO.cpp does not bother. I think we should be able to skip the null check by construction.

225 ↗(On Diff #107501)

This loop is:

bool gv_is_dso_local = llvm::any_of(VI.getSummaryList(), [} (const std::unique_ptr<GlobalValueSummary> &Summary) { return Summary->isDSOLocal(); });
if (gv_is_dso_local) 
228 ↗(On Diff #107501)

I was trying to figure out if your code handles declarations as well, and it seems so.
But interestingly it means that we do the following for declarations as well, I'm not sure it is totally relevant: @tejohnson WDYT? (this is tangential to this review)

grandinj added inline comments.
152 ↗(On Diff #107501)

whithin -> within

inouehrs added inline comments.Jul 21 2017, 6:13 AM
876 ↗(On Diff #107501)

Do we need some version check (and some comments) for compatibility with old bc files?

mehdi_amini added inline comments.Jul 21 2017, 9:08 PM
876 ↗(On Diff #107501)

The default will be 0 for old .bc files, which translate to "not local", which should be conservatively OK I believe?

Ideally we would checking a bitcode file from the 5.0 branching point in the repo and test this behavior.

sfertile updated this revision to Diff 108159.Jul 25 2017, 5:49 PM

Fixed spelling in comment.
Updated the look-up when marking summary as local to be limited to the bitcode module being added.
Changed for loop to llvm::any_of.

sfertile marked 3 inline comments as done.Jul 25 2017, 6:36 PM
sfertile added inline comments.
876 ↗(On Diff #107501)

That was my reasoning for not needing a version check.
I'll add the bitcode test from the 5.0 branch next update.

691 ↗(On Diff #107501)

I've limited the summary look-up to the bitcode module we are currently adding, is this what you had in mind?

685 ↗(On Diff #108159)

I realize that this is the same GUID as calculated above since the call to getGlobalIdentifier is being passed ExternalLinkage. I'll update this to reflect that.

sfertile updated this revision to Diff 110472.Aug 9 2017, 1:54 PM

re-based, removed accidentally added white space in one of the tests and used the existing GUID in addThinLTO summary look-up.

sfertile updated this revision to Diff 110870.Aug 13 2017, 6:26 AM

rebased to top of trunk

sfertile updated this revision to Diff 112654.Aug 24 2017, 8:29 PM

Added a bitcode compatibility test.

sfertile updated this revision to Diff 120907.Oct 30 2017, 3:48 PM
sfertile marked 6 inline comments as done.

Rebased to top of trunk. The patch this one is dependent on is now committed as well,

sfertile updated this revision to Diff 120934.Oct 30 2017, 9:17 PM

Previous diff was missing updates to one of the tests.

pcc added inline comments.Nov 2 2017, 11:21 AM
215 ↗(On Diff #120934)

I think you need to check that all summaries are dso-local to protect against hash collisions here.

sfertile updated this revision to Diff 121430.Nov 2 2017, 7:58 PM

Changed the importing to check that every summary is local before marking a GlobalValue as local.

sfertile marked an inline comment as done.Nov 2 2017, 7:59 PM
sfertile added inline comments.
215 ↗(On Diff #120934)

Good point. Updated.

pcc accepted this revision.Nov 3 2017, 12:53 PM


This revision is now accepted and ready to land.Nov 3 2017, 12:53 PM
This revision was automatically updated to reflect the committed changes.
sfertile marked an inline comment as done.