This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Have ICF dedup explicitly-defined selrefs
ClosedPublic

Authored by int3 on Sep 13 2022, 8:30 AM.

Details

Summary

This is what ld64 does (though it doesn't use ICF to do this; instead it
always dedups selrefs by default).

We'll want to dedup implicitly-defined selrefs as well, but I will leave
that for future work.

Additionally, I'm not *super* happy with the current LLD implementation
because I think it is rather janky and inefficient. But at least it
moves us toward the goal of closing the size gap with ld64. I've
described ideas for cleaning up our implementation here:
https://github.com/llvm/llvm-project/issues/57714

Diff Detail

Event Timeline

int3 created this revision.Sep 13 2022, 8:30 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
int3 requested review of this revision.Sep 13 2022, 8:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 13 2022, 8:30 AM
int3 added inline comments.Sep 13 2022, 2:25 PM
lld/MachO/ICF.cpp
414

hm I should rename this to foldable too

Roger added a subscriber: Roger.Sep 14 2022, 10:59 AM
Roger added inline comments.
lld/MachO/ICF.cpp
414

Agreed :)

417–423

I really appreciate pulling out these boolean expressions into their own variables to give a name to what they represent. If it can be done any further, I'd really encourage it :)

thakis accepted this revision.Sep 14 2022, 12:11 PM
thakis added a subscriber: thakis.

Out of curiosity, do you have any numbers on what that does to the size gap for your apps?

lld/MachO/ICF.cpp
417–423

+1, but maybe some of that could land in a separate (unreviewed, behavior-preserving) commit so it's easier to see the behavior change in this diff :)

This revision is now accepted and ready to land.Sep 14 2022, 12:11 PM
This revision was automatically updated to reflect the committed changes.
int3 marked 3 inline comments as done.
int3 added a comment.Sep 14 2022, 3:00 PM

Out of curiosity, do you have any numbers on what that does to the size gap for your apps?

I'll re-gather some numbers in a bit. But this is basically the last of the non-__text sections for us that showed a significant size regression wrt ld64's output.