This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Fix & refactor symbol size calculations
ClosedPublic

Authored by int3 on Apr 6 2021, 10:22 AM.

Details

Summary

I noticed two problems with the previous implementation:

  • N_ALT_ENTRY symbols weren't being handled correctly -- they should determine the size of the previous symbol, even though they don't cause a new section to be created
  • The last symbol in a section had its size calculated wrongly; the first subsection's size was used instead of the last one

I decided to take the opportunity to refactor things as well, mainly to
realize my observation
here that we could
avoid doing a binary search to match symbols with subsections. I think
the resulting code is a bit simpler too.

    N           Min           Max        Median           Avg        Stddev
x  20          4.31          4.43          4.37        4.3775   0.034162922
+  20          4.32          4.43          4.38        4.3755    0.02799906
No difference proven at 95.0% confidence

Diff Detail

Event Timeline

int3 created this revision.Apr 6 2021, 10:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2021, 10:22 AM
Herald added a subscriber: mgrang. · View Herald Transcript
int3 requested review of this revision.Apr 6 2021, 10:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2021, 10:22 AM

Unless you think it only makes sense when paired with the rest of this diff, could you split out the renaming of SubsectionMapping to SubsectionMap into its own NFC diff (and probably just commit that directly)? It'd make the rest of this diff easier to read.

This revision is now accepted and ready to land.Apr 6 2021, 10:55 AM
This revision was landed with ongoing or failed builds.Apr 6 2021, 12:11 PM
This revision was automatically updated to reflect the committed changes.