Page MenuHomePhabricator

[lld/mac] Tweak estimateStubsInRangeVA a bit

Authored by thakis on Aug 30 2021, 9:57 AM.


Group Reviewers
Restricted Project
rG83df94067d36: [lld/mac] Tweak estimateStubsInRangeVA a bit
  • Move a few variables closer to their uses, remove some completely (no behavior change)
  • Add some comments
  • Make maxPotentialThunks include calls to stubs. It's possible that an earlier call to a stub late in the stub table will need a thunk, and that inserted thunk could push a stub earlier in the stub table out of range. This is unlikely to happen, but usually there are way fewer stub calls than non-stub calls, so if we're doing a conservative approximation here we might as well do it correctly. (For chromium's unit_tests target, 134421/242639 stub calls are direct calls without this change, compared to 134408/242639 with this change)

No real, meaningful behavior difference.

Diff Detail

Event Timeline

thakis created this revision.Aug 30 2021, 9:57 AM
Herald added a project: Restricted Project. · View Herald Transcript
oontvoo accepted this revision.Aug 30 2021, 10:08 AM
oontvoo added a subscriber: oontvoo.
oontvoo added inline comments.

I must be missing something here but why does this need to be a loop and not simply

if (callIdx < inputs.size()) {
  InputSection *isec = inputs.last();
   secEnd = alignTo(isecEnd, isec->align) + isec->getSize();

IOWs, isecEnd seems to get overridden in each iteration, yes?

This revision is now accepted and ready to land.Aug 30 2021, 10:08 AM
thakis added inline comments.Aug 30 2021, 10:28 AM

Yes, this computes the end address of all sections. After the loop, isecEndpoints right after where the last section would end up, assuming we don't insert thunk sections anywhere along the way.

int3 accepted this revision.Aug 30 2021, 10:53 AM
int3 added a subscriber: int3.



It's a loop since it's summing the aligned sizes

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2021, 10:57 AM
oontvoo added inline comments.Aug 30 2021, 10:57 AM

Thanks :)
i shouldn't have done reviews on monday before☕