This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Omit IMAGE_SYM_CLASS_LABEL symbols from the PE symbol table
ClosedPublic

Authored by mstorsjo on Nov 14 2021, 2:46 PM.

Details

Summary

Also omit section definition symbols. This matches the condition for
symbols to omit from map files.

If we start producing lots of IMAGE_SYM_CLASS_LABEL symbols due to
D113865, it inflates the size of mingw style default linked binaries
(with dwarf debug info and a regular PE symbol table) a fair bit
(by 14% in one test).

By omitting these symbols, the size remains the same as before, and
by omitting the section definition symbols we further shrink the
mingw style unstripped binaries by 14% in one test.

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Nov 14 2021, 2:46 PM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 14 2021, 2:46 PM
rnk added a comment.Nov 15 2021, 2:11 PM

Seems reasonable, just style nits

lld/COFF/Writer.cpp
1213–1214

If dc will only be used in the if, it's preferred to declare the variable inside the if condition.

1213–1219

Please keep this grouped with the check, so it's clear that it's one operation to ensure that each symbol is written at most once.

mstorsjo updated this revision to Diff 387407.Nov 15 2021, 2:29 PM

Adjusted the code as suggested.

mstorsjo marked 2 inline comments as done.Nov 15 2021, 2:31 PM
mstorsjo added inline comments.
lld/COFF/Writer.cpp
1213–1214

Sure, thanks.

1213–1219

Ok, will do. I was a bit divided over this while writing the initial version, as it also seems counterintuitive to set a flag "written" while we might still bail out and not write it. But setting the flag avoids needlessly checking the storage class multiple times (and keeps the flag check more together).

rnk accepted this revision.Nov 15 2021, 3:15 PM

lgtm

This revision is now accepted and ready to land.Nov 15 2021, 3:15 PM