This is an archive of the discontinued LLVM Phabricator instance.

ThinLTO: Don't import aliases of any kind (even linkonce_odr)
ClosedPublic

Authored by dblaikie on Jul 25 2017, 8:36 PM.

Details

Summary

Until a more advanced version of importing can be implemented for
aliases (one that imports an alias as an available_externally definition
of the aliasee), skip the narrow subset of cases that was possible but
came at a cost: aliases of linkonce_odr functions could be imported
because the linkonce_odr function could be safely duplicated from the
source module. This came/comes at the cost of not being able to 'home'
imported linkonce functions (they had to be emitted linkonce_odr in all
the destination modules (even if they weren't used by an alias) rather
than as available_externally - causing extra object size).

Tangentially, this also was the only reason ThinLTO would emit multiple
CUs in to the resulting DWARF - which happens to be a problem for
Fission (there's a fix for this in GDB but not released yet, etc).
(actually it's not the only reason - but I'm sending a patch to fix the
other reason shortly)

There's no reason to believe this particularly narrow alias importing
was especially/meaningfully important, only that it was /possible/ to
implement in this way. When a more general solution is done, it should
still satisfy the DWARF concerns above, since the import will still be
available_externally, and thus not create extra CUs.

Since now all aliases are treated the same, I removed/simplified some
test cases since they were testing corner cases where there are no
longer any corners.

Diff Detail

Repository
rL LLVM

Event Timeline

dblaikie created this revision.Jul 25 2017, 8:36 PM
mehdi_amini edited edge metadata.Jul 25 2017, 9:00 PM

they had to be emitted linkonce_odr in all the destination modules (even if they weren't used by an alias) rather than as available_externally - causing extra object size.

Can you clarify this? It isn't clear to me.

There's no reason to believe this particularly narrow alias importing was especially/meaningfully important, only that it was /possible/ to implement in this way.

Do you have benchmark results (SPEC and your internal ones)? Also statistics on the number of imports before/after?

test/Linker/funcimport.ll
63 ↗(On Diff #108205)

Is this comment still up to date?

test/ThinLTO/X86/alias_import.ll
5 ↗(On Diff #108205)

It isn't clear to me that what is tested here is obsolete by your patch.

test/Transforms/FunctionImport/funcimport.ll
43 ↗(On Diff #108205)

Comment seems out-of-date?

dblaikie updated this revision to Diff 108211.Jul 25 2017, 9:17 PM

Update with comment fixes based on Mehdi's code review

tejohnson edited edge metadata.Jul 27 2017, 7:12 AM

Sorry for the delay. A few comments below. Regarding Mehdi's performance question - I don't expect this to have a major impact as we were only importing aliases in limited cases anyway. We'll see any performance effect in our nightly testing once this goes in, which should surface any surprise effects.

lib/Transforms/IPO/FunctionImport.cpp
135 ↗(On Diff #108211)

Braces can be removed

138 ↗(On Diff #108211)

While you're in here, can you correct the comment: s/does needs to know/does not need to know/

228 ↗(On Diff #108211)

This handling needs to be updated - can simply assert that CalleeSummary not an AliasSummary.

lib/Transforms/Utils/FunctionImportUtils.cpp
27 ↗(On Diff #108211)

GA is unused, and comment is stale. But I also think that this should be moved to after the below check of SGV being in GlobalsToImport, and converted to an assert (if in GlobalsToImport, better not be an alias).

133 ↗(On Diff #108211)

"External and linkonce definitions" (can you fix typo in "defnitions" while here)?

test/ThinLTO/X86/alias_import.ll
48 ↗(On Diff #108211)

Comment needs update.

dblaikie updated this revision to Diff 108470.Jul 27 2017, 7:58 AM

Address code review feedback from Teresa

tejohnson accepted this revision.Jul 27 2017, 8:04 AM

LGTM, with one more comment update noted below. Thanks!

lib/Transforms/IPO/FunctionImport.cpp
225 ↗(On Diff #108470)

Update comment.

This revision is now accepted and ready to land.Jul 27 2017, 8:04 AM
This revision was automatically updated to reflect the committed changes.
llvm/trunk/test/ThinLTO/X86/alias_import.ll