This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Handle LOH_ARM64_ADRP_LDR linker optimization hints
ClosedPublic

Authored by BertalanD on Jun 30 2022, 1:43 PM.

Details

Summary

This linker optimization hint transforms a pair of adrp+ldr (immediate)
instructions into an ldr (literal) load from a PC-relative address if it
is within the +/- 1 MiB range allowed by the ldr's 21 bit signed offset.

In the wild, only a small number of these hints are applicable because
not many loads end up close enough to the data segment. However, the
added helper functions will be useful in implementing the rest of the
LOH types.

Diff Detail

Event Timeline

BertalanD created this revision.Jun 30 2022, 1:43 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 30 2022, 1:43 PM
BertalanD requested review of this revision.Jun 30 2022, 1:43 PM
tschuett added inline comments.
lld/MachO/Arch/ARM64.cpp
166

I prefer enum class. It is slightly more verbose but safer.

thakis accepted this revision.Jun 30 2022, 1:56 PM
thakis added a subscriber: thakis.

Lgtm!

This revision is now accepted and ready to land.Jun 30 2022, 1:56 PM
int3 accepted this revision.Jun 30 2022, 2:07 PM
int3 added a subscriber: int3.

lgtm

Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2022, 12:48 AM

Sorry, looks like this broke an UBSan bot: https://lab.llvm.org/buildbot#builders/5/builds/25537.

I'll push the fix after testing it.