This is an archive of the discontinued LLVM Phabricator instance.

[LTO] Handle __imp_ (dllimport) symbols consistently with lld
ClosedPublic

Authored by tejohnson on Jul 10 2018, 8:56 AM.

Details

Summary

Similar to what lld already does for dllimport symbols which are
prefaced with imp_ (see lld patch r240620), strip off the imp_
prefix in LTO. Otherwise we can get 2 separate GlobalResolution for
a single symbol, the dllimport declaration, and the definition, which
leads to incorrect LTO handling.

Tests coming in separate tools/lld patch.

Fixes PR38105.

Diff Detail

Repository
rL LLVM

Event Timeline

tejohnson created this revision.Jul 10 2018, 8:56 AM
dmajor added a subscriber: dmajor.Jul 10 2018, 9:01 AM

Is it impossible to also test this locally (in the LLVM repo)? It will be hard to hack on this file if there aren't local tests.

Is it impossible to also test this locally (in the LLVM repo)? It will be hard to hack on this file if there aren't local tests.

Yeah I can just invoke llvm-lto2 with the resolutions lld gives LTO in this case and confirm that the symbol is kept...will add test shortly

tejohnson updated this revision to Diff 154832.Jul 10 2018, 9:32 AM

Add llvm-lto2 test (confirmed fails without fix)

Thanks! (I'm not comfortable signing off though, since I don't know much about dllimport.)

pcc added a comment.Jul 10 2018, 10:06 AM

This is a COFF-specific behaviour so it should be conditioned on the object file format being COFF.

Restrict to COFF.

pcc accepted this revision.Jul 23 2018, 11:57 AM

LGTM

Sorry, I reviewed this and left one comment but I forgot to send it. Aside from that, this looks good.

lib/LTO/LTO.cpp
528 ↗(On Diff #154843)

You don't need to pass a triple here, you can get it from RegularLTO.CombinedModule->getTargetTriple().

This revision is now accepted and ready to land.Jul 23 2018, 11:57 AM
tejohnson marked an inline comment as done.Jul 23 2018, 3:32 PM
tejohnson updated this revision to Diff 156900.Jul 23 2018, 3:33 PM

Address comment

This revision was automatically updated to reflect the committed changes.