This is an archive of the discontinued LLVM Phabricator instance.

[lld] Make error handling functions opaque
ClosedPublic

Authored by MaskRay on Feb 16 2022, 8:30 PM.

Details

Reviewers
inglorion
int3
thakis
Group Reviewers
Restricted Project
Commits
rG941f06282a3d: [lld] Make error handling functions opaque
Summary

The inline lld::error expands to two function calls errorHandler and error
where the latter is opaque. Move the functions to .cpp files to decrease code
size.

My x86-64 lld executable is 9KiB smaller.

Diff Detail

Event Timeline

MaskRay requested review of this revision.Feb 16 2022, 8:30 PM
MaskRay created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 16 2022, 8:30 PM
MaskRay edited the summary of this revision. (Show Details)Feb 16 2022, 8:31 PM
thakis accepted this revision.Feb 17 2022, 6:21 AM
thakis added a subscriber: thakis.

…do we really care about 9kiB of code? On my system, lld is 49730704 bytes, so that's a 0.2% reduction. Having 7 more lines of code seems worse than the benefit from that win – and that win probably only happens if you build lld without LTO.

But /shrug, if you feel this is a good change, lg I suppose :)

This revision is now accepted and ready to land.Feb 17 2022, 6:21 AM

…do we really care about 9kiB of code? On my system, lld is 49730704 bytes, so that's a 0.2% reduction. Having 7 more lines of code seems worse than the benefit from that win – and that win probably only happens if you build lld without LTO.

But /shrug, if you feel this is a good change, lg I suppose :)

This saves instruction cache for some hot paths, though it's difficult to measure any improvement.

On my system, lld is 49730704 bytes, so that's a 0.2% reduction.

We should count liblld*.a, not every LLVM library pulled in by LTO. Then the ratio will be higher.
(If one compares a non-lld linker with lld, the size of something like LLVMgold.so needs to be counted.)

This revision was automatically updated to reflect the committed changes.