This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO/gold] Write empty imports even for modules with symbols
ClosedPublic

Authored by vitalybuka on Jan 24 2018, 4:32 PM.

Event Timeline

vitalybuka created this revision.Jan 24 2018, 4:32 PM

I guess this is needed for the case when we need to split the module due to the existence of type metadata, but there is no module id so we can only write as regular LTO?

llvm/tools/gold/gold-plugin.cpp
896

It would be good to avoid writing all these files unnecessarily (the common case). You could presumably get back from LTO::add (via addModule below) whether any module in the file had a summary (from the BitcodeLTOInfo structure in LTO::addModule).

vitalybuka planned changes to this revision.Jan 29 2018, 2:28 PM

avoid double writes

vitalybuka marked an inline comment as done.Jan 29 2018, 6:16 PM
vitalybuka added inline comments.
llvm/tools/gold/gold-plugin.cpp
896

Done, but in a little bit different way. We can just inform the caller about what was actually written. This way we can avoid having in the gold plugin the logic which checks LTO properties and decides what should be written or skipped.

tejohnson added inline comments.Jan 30 2018, 6:38 AM
llvm/include/llvm/LTO/LTO.h
221

Document new param

llvm/tools/gold/gold-plugin.cpp
896

Should this have been removed now?

llvm/tools/llvm-lto2/llvm-lto2.cpp
247

I think the only change here is the addition of the braces - I assume that was from some debugging code that was since removed, so the braces and the change to this file can be removed.

vitalybuka marked 4 inline comments as done.

addressed comments

llvm/tools/gold/gold-plugin.cpp
896

Ugh, removing this was the point of the patch. Probably result of invalid local merges.

addressed comments

corrected doc string

tejohnson added inline comments.Jan 30 2018, 11:05 AM
llvm/tools/gold/gold-plugin.cpp
873

Thinking through this some more, this seems a little dicey, because it assumes that createLTO will never try to access these filename strings that are owned by this set after the callback. In fact, that doesn't even seem to be the case currently (ModulePath which is a StringRef of the module identifier is passed to EmitImportsFiles after this callback is invoked). Rather than try to fix that, since it would still be fragile, I suggest making this a StringMap and noting in the map whether the file was written.

llvm/tools/llvm-lto2/llvm-lto2.cpp
247

Oh I see, there was a change here. In any case, please remove the added braces which aren't necessary.

vitalybuka marked an inline comment as done.

fixed use of container for strings

vitalybuka marked an inline comment as done.Jan 30 2018, 11:31 AM
vitalybuka added inline comments.
llvm/tools/gold/gold-plugin.cpp
873

Oh, I've totally missed "owning" part in the first place.

tejohnson accepted this revision.Jan 30 2018, 11:54 AM

LGTM

llvm/tools/gold/gold-plugin.cpp
936

nit: remove unnecessary braces

This revision is now accepted and ready to land.Jan 30 2018, 11:54 AM
vitalybuka marked an inline comment as done.

no braces

vitalybuka marked an inline comment as done.Jan 30 2018, 11:59 AM
This revision was automatically updated to reflect the committed changes.