This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Add LOH_ARM64_ADRP_ADD_LDR optimization hint support
ClosedPublic

Authored by BertalanD on Jul 25 2022, 11:26 AM.

Details

Summary

This hint instructs the linker to optimize an adrp+add+ldr sequence used
for loading from a local symbol's address by loading directly if it's
close enough, or to an adrp(p)+ldr sequence if it's not.

This transformation is the same as what's done int ADRP_LDR_GOT_LDR for
local symbols. The logic for acting on this hint is therefore moved to a
new function which will be called by the existing applyAdrpLdrGotLdr()
function.

Diff Detail

Event Timeline

BertalanD created this revision.Jul 25 2022, 11:26 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 25 2022, 11:26 AM
BertalanD requested review of this revision.Jul 25 2022, 11:26 AM
thakis accepted this revision.Jul 27 2022, 7:14 AM
thakis added a subscriber: thakis.

Nice!

lld/MachO/Arch/ARM64.cpp
548

Given that this is the most commonly used type: Any perf impact from making this function do slightly more work?

This revision is now accepted and ready to land.Jul 27 2022, 7:14 AM
BertalanD added inline comments.Jul 27 2022, 4:25 PM
lld/MachO/Arch/ARM64.cpp
548

These are the stats for a --threads=1 link of the usual Chromium Framework repro file:

x before
+ after

    N           Min           Max        Median           Avg        Stddev
x  10     4.7864389      5.115659     4.8095057      4.860885    0.10600977
+  10      4.783572      4.847595     4.8069289     4.8113722   0.023636726
No difference proven at 95.0% confidence
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2022, 1:47 AM