[all-commits] [llvm/llvm-project] d5a70d: [lld/mac] Write every weak symbol only once in the...
Nico Weber via All-commits
all-commits at lists.llvm.org
Fri May 7 14:12:10 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d5a70db1938c06380bdab033b7d47a7437914f4c
https://github.com/llvm/llvm-project/commit/d5a70db1938c06380bdab033b7d47a7437914f4c
Author: Nico Weber <thakis at chromium.org>
Date: 2021-05-07 (Fri, 07 May 2021)
Changed paths:
M lld/MachO/InputFiles.cpp
M lld/MachO/InputSection.cpp
M lld/MachO/InputSection.h
M lld/MachO/MapFile.cpp
M lld/MachO/SymbolTable.cpp
M lld/MachO/Symbols.h
M lld/MachO/UnwindInfoSection.cpp
M lld/MachO/Writer.cpp
A lld/test/MachO/weak-definition-gc.s
Log Message:
-----------
[lld/mac] Write every weak symbol only once in the output
Before this, if an inline function was defined in several input files,
lld would write each copy of the inline function the output. With this
patch, it only writes one copy.
Reduces the size of Chromium Framework from 378MB to 345MB (compared
to 290MB linked with ld64, which also does dead-stripping, which we
don't do yet), and makes linking it faster:
N Min Max Median Avg Stddev
x 10 3.9957051 4.3496981 4.1411121 4.156837 0.10092097
+ 10 3.908154 4.169318 3.9712729 3.9846753 0.075773012
Difference at 95.0% confidence
-0.172162 +/- 0.083847
-4.14165% +/- 2.01709%
(Student's t, pooled s = 0.0892373)
Implementation-wise, when merging two weak symbols, this sets a
"canOmitFromOutput" on the InputSection belonging to the weak symbol not put in
the symbol table. We then don't write InputSections that have this set, as long
as they are not referenced from other symbols. (This happens e.g. for object
files that don't set .subsections_via_symbols or that use .alt_entry.)
Some restrictions:
- not yet done for bitcode inputs
- no "comdat" handling (`kindNoneGroupSubordinate*` in ld64) --
Frame Descriptor Entries (FDEs), Language Specific Data Areas (LSDAs)
(that is, catch block unwind information) and Personality Routines
associated with weak functions still not stripped. This is wasteful,
but harmless.
- However, this does strip weaks from __unwind_info (which is needed for
correctness and not just for size)
- This nopes out on InputSections that are referenced form more than
one symbol (eg from .alt_entry) for now
Things that work based on symbols Just Work:
- map files (change in MapFile.cpp is no-op and not needed; I just
found it a bit more explicit)
- exports
Things that work with inputSections need to explicitly check if
an inputSection is written (e.g. unwind info).
This patch is useful in itself, but it's also likely also a useful foundation
for dead_strip.
I used to have a "canoncialRepresentative" pointer on InputSection instead of
just the bool, which would be handy for ICF too. But I ended up not needing it
for this patch, so I removed that again for now.
Differential Revision: https://reviews.llvm.org/D102076
More information about the All-commits
mailing list