Page MenuHomePhabricator

ELF: Try to create last thunk section at ThunkSectionSpacing bytes before the end.
ClosedPublic

Authored by pcc on Mar 27 2018, 6:38 PM.

Details

Summary

Now that we have the ability to create short thunks, it is beneficial
for thunk sections to be surrounded by ThunkSectionSpacing bytes
of code on both sides in order to increase the likelihood that the
distance from the thunk to the target will be sufficiently small to
allow for the creation of a short thunk. This is currently the case
for most thunks that we create, except for the last one, which could,
depending on the size of the output section, potentially appear near
the end and therefore have a relatively small amount of code after it.

This patch moves the last thunk section to ThunkSectionSpacing bytes
before the end of the output section, as long as the section is larger
than 2*ThunkSectionSpacing bytes. It reduces the size of Chromium
for Android's .text section by 32KB.

Depends on D44963

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.Mar 27 2018, 6:38 PM
grimar added a subscriber: grimar.Mar 28 2018, 1:43 AM

This sounds reasonable to me. For large programs there will be sufficient thunks that the small benefit to readability (all your thunks can be found at the end of the section) won't apply.

ruiu accepted this revision.Mar 30 2018, 11:07 AM

LGTM

This revision is now accepted and ready to land.Mar 30 2018, 11:07 AM
This revision was automatically updated to reflect the committed changes.