This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Factor out common InputSection members
ClosedPublic

Authored by int3 on Jul 1 2021, 12:06 PM.

Details

Reviewers
gkm
thakis
Group Reviewers
Restricted Project
Commits
rGf6b6e7214366: [lld-macho] Factor out common InputSection members
Summary

We have been creating many ConcatInputSections with identical values due
to .subsections_via_symbols. This diff factors out the identical values
into a Shared struct, to reduce memory consumption and make copying
cheaper.

I also changed callSiteCount from a uint32_t to a 31-bit field to save an
extra word.

All in all, this takes InputSection from 120 to 72 bytes (and
ConcatInputSection from 160 to 112 bytes), i.e. 30% size reduction in
ConcatInputSection.

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

    N           Min           Max        Median           Avg        Stddev
x  20          4.14          4.24          4.18         4.183   0.027548999
+  20          4.04          4.11         4.075        4.0775   0.018027756
Difference at 95.0% confidence
        -0.1055 +/- 0.0149005
        -2.52211% +/- 0.356215%
        (Student's t, pooled s = 0.0232803)

Diff Detail

Event Timeline

int3 created this revision.Jul 1 2021, 12:06 PM
Herald added a project: Restricted Project. · View Herald Transcript
int3 requested review of this revision.Jul 1 2021, 12:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2021, 12:06 PM
thakis accepted this revision.Jul 1 2021, 12:09 PM
thakis added a subscriber: thakis.

Nice!

lld/MachO/InputSection.h
147

This might fail in 32-bit builds -- probably want to do <= for that.

This revision is now accepted and ready to land.Jul 1 2021, 12:09 PM
int3 updated this revision to Diff 356026.Jul 1 2021, 3:14 PM
int3 marked an inline comment as done.
int3 edited the summary of this revision. (Show Details)

address comment

This revision was landed with ongoing or failed builds.Jul 1 2021, 6:23 PM
This revision was automatically updated to reflect the committed changes.