llvm-project/lld/test
Jez Ng 5d88f2dd94 [lld-macho] Deduplicate fixed-width literals
Conceptually, the implementation is pretty straightforward: we put each
literal value into a hashtable, and then write out the keys of that
hashtable at the end.

In contrast with ELF, the Mach-O format does not support variable-length
literals that aren't strings. Its literals are either 4, 8, or 16 bytes
in length. LLD-ELF dedups its literals via sorting + uniq'ing, but since
we don't need to worry about overly-long values, we should be able to do
a faster job by just hashing.

That said, the implementation right now is far from optimal, because we
add to those hashtables serially. To parallelize this, we'll need a
basic concurrent hashtable (only needs to support concurrent writes w/o
interleave reads), which shouldn't be to hard to implement, but I'd like
to punt on it for now.

Numbers for linking chromium_framework on my 3.2 GHz 16-Core Intel Xeon W:

      N           Min           Max        Median           Avg        Stddev
  x  20          4.27          4.39         4.315        4.3225   0.033225703
  +  20          4.36          4.82          4.44        4.4845    0.13152846
  Difference at 95.0% confidence
          0.162 +/- 0.0613971
          3.74783% +/- 1.42041%
          (Student's t, pooled s = 0.0959262)

This corresponds to binary size savings of 2MB out of 335MB, or 0.6%.
It's not a great tradeoff as-is, but as mentioned our implementation can
be signficantly optimized, and literal dedup will unlock more
opportunities for ICF to identify identical structures that reference
the same literals.

Reviewed By: #lld-macho, gkm

Differential Revision: https://reviews.llvm.org/D103113
2021-06-11 19:50:08 -04:00
..
COFF [LLD] [COFF] Fix autoexport from LTO objects with comdat symbols 2021-06-03 15:14:49 +03:00
ELF [ELF][RISCV] Resolve branch relocations referencing undefined weak to current location if not using PLT 2021-06-10 13:25:16 -07:00
MachO [lld-macho] Deduplicate fixed-width literals 2021-06-11 19:50:08 -04:00
MinGW [lld][MinGW] Introduce aliases for -Bdynamic and -Bstatic 2021-05-17 22:13:26 +02:00
Unit Support multi-configuration generators correctly in several config files 2021-02-11 09:32:20 -08:00
darwin [lld-macho] Switch default to new Darwin backend 2021-03-01 12:30:10 -05:00
mach-o [lld-macho] Switch default to new Darwin backend 2021-03-01 12:30:10 -05:00
wasm [lld][WebAssemlby] Fix for string merging of -dwarf-5 sections 2021-06-01 14:33:56 -07:00
CMakeLists.txt Fix lld macho standalone build by including llvm/Config/llvm-config.h instead of llvm/Config/config.h 2021-05-19 11:15:07 -04:00
lit.cfg.py [lld-macho] Initial groundwork for -bitcode_bundle 2021-04-16 16:47:14 -04:00
lit.site.cfg.py.in Fix lld macho standalone build by including llvm/Config/llvm-config.h instead of llvm/Config/config.h 2021-05-19 11:15:07 -04:00