[PATCH] D128093: [lld-macho] Initial support for Linker Optimization Hints

Daniel Bertalan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 17 13:06:59 PDT 2022


BertalanD created this revision.
BertalanD added reviewers: int3, thakis, lld-macho.
Herald added a subscriber: kristof.beyls.
Herald added projects: lld-macho, All.
BertalanD requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Linker optimization hints are used for marking a sequence of
instructions used for synthesizing an address, like ADRP+ADD. If the
referenced symbol ends up close enough, it can be replaced by a faster
sequence of instructions like ADR+NOP.

This commit adds support for 2 of the 7 defined ARM64 optimization
hints:

- LOH_ARM64_ADRP_ADD, which transforms a pair of ADRP+ADD into ADR+NOP if the referenced address is within +/- 1 MiB
- LOH_ARM64_ADRP_ADRP, which transforms two ADRP instructions into ADR+NOP if they reference the same page

These two kinds already cover more than 50% of all cases in Chromium.

---

I test-built Chromium with this patch applied.

A slight problem with this change is that it increases Chromium's link time by about 5% as reading the optimization hints into the `std::vector<OptimizationHint>`s takes an obscene amount of time. Suggestions on how to make it quicker are appreciated :)

Please commit this diff with the following author info:
Daniel Bertalan <dani at danielbertalan.dev>


https://reviews.llvm.org/D128093

Files:
  lld/MachO/Arch/ARM64.cpp
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/InputFiles.h
  lld/MachO/InputSection.cpp
  lld/MachO/InputSection.h
  lld/MachO/Options.td
  lld/MachO/Relocations.h
  lld/MachO/Target.h
  lld/test/MachO/hint-adrp-add.s
  llvm/include/llvm/BinaryFormat/MachO.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128093.438021.patch
Type: text/x-patch
Size: 14900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220617/07cf3e35/attachment.bin>


More information about the llvm-commits mailing list