[PATCH] D106214: [lld-macho] ICF: Fold some sections with differing addends
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 16 23:42:02 PDT 2021
int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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 <https://reviews.llvm.org/D105044>, 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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106214
Files:
lld/MachO/ICF.cpp
lld/test/MachO/icf-literals.s
lld/test/MachO/icf.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106214.359538.patch
Type: text/x-patch
Size: 11175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210717/9a6b894d/attachment.bin>
More information about the llvm-commits
mailing list