Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lld/mac: Implement support for linker optimization hints (.loh) #50399

Open
nico opened this issue Jul 11, 2021 · 6 comments
Open

lld/mac: Implement support for linker optimization hints (.loh) #50399

nico opened this issue Jul 11, 2021 · 6 comments
Labels
bugzilla Issues migrated from bugzilla lld:MachO

Comments

@nico
Copy link
Contributor

nico commented Jul 11, 2021

Bugzilla Link 51055
Version unspecified
OS All
CC @gkmhub,@int3,@smeenai

Extended Description

LLVM supports .loh directives (llvm/trunk/test/MC/AArch64/arm64-directive_loh.s). Per https://reviews.llvm.org/D49929:

"""
The hints are there so that the linker can turn (non-adjacent) ADRP/ADD sequences, and similar, into ADR/NOP if the referenced symbol ends up close enough; this saves a cycle or so on Apple CPUs. To do that the compiler marks instruction-pairs used to generate a single address and saves that data off in a special MachO load command. I suppose it is sort of a souped-up relocation which specifies two addresses to be relocated instead of just one.
"""

I think we don't support that yet in lld.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@oontvoo oontvoo added the lld label Dec 18, 2021
@BertalanD
Copy link
Member

I'm working on this.

@EugeneZelenko EugeneZelenko removed the lld label Jun 17, 2022
@nico
Copy link
Contributor Author

nico commented Jul 25, 2022

current ld64.lld loh status:

  • LOH_ARM64_ADRP_ADRP
  • LOH_ARM64_ADRP_LDR
  • LOH_ARM64_ADRP_ADD_LDR
  • LOH_ARM64_ADRP_LDR_GOT_LDR
  • LOH_ARM64_ADRP_ADD_STR
  • LOH_ARM64_ADRP_LDR_GOT_STR
  • LOH_ARM64_ADRP_ADD
  • LOH_ARM64_ADRP_LDR_GOT

If I remember correctly, @BertalanD said that the implemented ones hit the majority of instances in Chromium Framework (@BertalanD, do you have a histogram at hand?).

@BertalanD
Copy link
Member

❯ ld @response.txt -verbose_optimization_hints 2>&1 | grep 'transformed to' | cut -d ' ' -f1 | sort | uniq -c | sort -n
  24 adrp-add-str
 319 adrp-add-ldr
 341 adrp-ldr-got-str
4056 adrp-ldr-got
115745 adrp-add
121578 adrp-ldr-got-ldr

@BertalanD
Copy link
Member

LOH_ARM64_ADRP_ADD_LDR will be added in https://reviews.llvm.org/D130505.

@int3
Copy link
Contributor

int3 commented Sep 13, 2022

@BertalanD is there anything left to do here?

@BertalanD
Copy link
Member

We are still missing LOH_ARM64_ADRP_ADD_STR and LOH_ARM64_ADRP_LDR_GOT_STR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla lld:MachO
Projects
None yet
Development

No branches or pull requests

5 participants