This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] ICF: Fold some sections with differing addends
AbandonedPublic

Authored by int3 on Jul 16 2021, 11:42 PM.

Details

Reviewers
gkm
Group Reviewers
Restricted Project
Summary

We previously treated all sections with differing addends as
unequal. This is not always true, particularly when the sections are
referencing literals: different addends may point to the same literal in
the output binary. References to absolute symbols and alt_entry symbols
can manifest this issue too (see icf.s), but are less common in practice.

To achieve this, we 1) move the addend check later in equalsConstant()
and 2) adjust our hash function to ignore symbol values and reloc
addends.

Along the way, I removed stubsHelperIndex from the hash computation as
it is effectively a no-op: Since D105044: [lld-macho] Move ICF earlier to avoid emitting redundant binds, ICF runs before
stubsHelperIndex gets set. The present implementation doesn't attempt
to factor DylibSymbol references into the hash at all, mirroring
LLD-ELF's approach. We may want to revisit this in the future after
doing some benchmarking.

Diff Detail

Event Timeline

int3 created this revision.Jul 16 2021, 11:42 PM
Herald added a project: Restricted Project. · View Herald Transcript
int3 requested review of this revision.Jul 16 2021, 11:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 16 2021, 11:42 PM
int3 planned changes to this revision.Aug 26 2021, 12:16 PM
int3 abandoned this revision.Feb 18 2022, 8:25 AM

will put up a better approach