This is an archive of the discontinued LLVM Phabricator instance.

[LTO] Always mark regular LTO units with EnableSplitLTOUnit=1
ClosedPublic

Authored by tejohnson on Jul 19 2019, 1:02 PM.

Details

Summary

Regular LTO modules do not need LTO Unit splitting, only ThinLTO does
(they must be consistently split into regular and Thin units for
optimizations such as whole program devirtualization and lower type
tests). In order to avoid spurious errors from LTO when combining with
split ThinLTO modules, always set this flag for regular LTO modules.

Diff Detail

Event Timeline

tejohnson created this revision.Jul 19 2019, 1:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2019, 1:02 PM
pcc added a comment.Jul 19 2019, 1:25 PM

Sorry, just realized this. If I do

clang++ -c -flto a.cpp # "split"
clang++ -c -flto=thin b.cpp -fwhole-program-vtables # non-split
clang++ a.o b.o

this should fail, right? If I'm not mistaken, this patch series will cause this to succeed. I think we need to change this patch so that it always sets EnableSplitLTOUnit to 1 for regular LTO, then you can drop the other patch.

In D65009#1594009, @pcc wrote:

Sorry, just realized this. If I do

clang++ -c -flto a.cpp # "split"
clang++ -c -flto=thin b.cpp -fwhole-program-vtables # non-split
clang++ a.o b.o

this should fail, right? If I'm not mistaken, this patch series will cause this to succeed. I think we need to change this patch so that it always sets EnableSplitLTOUnit to 1 for regular LTO, then you can drop the other patch.

This is a good point. We could detect and handle this during the LTO merging here, but I don't think it is worth it (it would essentially be treating regular LTO as split in any case). The change you suggested fixes the original bug, re running the llvm/clang tests now and will update the patches afterwards.

tejohnson updated this revision to Diff 210918.Jul 19 2019, 3:35 PM

Address comments

tejohnson retitled this revision from [LTO] Don't mark regular LTO units with EnableSplitLTOUnit to [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1.Jul 19 2019, 3:37 PM
tejohnson edited the summary of this revision. (Show Details)
pcc accepted this revision.Jul 19 2019, 3:56 PM

LGTM

This revision is now accepted and ready to land.Jul 19 2019, 3:56 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2019, 4:02 PM