[all-commits] [llvm/llvm-project] 93c855: [lld-macho] Implement branch-range-extension thunks

Greg McGary via All-commits all-commits at lists.llvm.org
Wed May 12 09:46:38 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 93c8559baf551a7a30ab17654569ac5ac92986f4
      https://github.com/llvm/llvm-project/commit/93c8559baf551a7a30ab17654569ac5ac92986f4
  Author: Greg McGary <gkm at fb.com>
  Date:   2021-05-12 (Wed, 12 May 2021)

  Changed paths:
    M lld/MachO/Arch/ARM64.cpp
    M lld/MachO/Driver.cpp
    M lld/MachO/InputSection.cpp
    M lld/MachO/InputSection.h
    M lld/MachO/MergedOutputSection.cpp
    M lld/MachO/MergedOutputSection.h
    M lld/MachO/Options.td
    M lld/MachO/Symbols.cpp
    M lld/MachO/Symbols.h
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/SyntheticSections.h
    M lld/MachO/Target.h
    M lld/MachO/Writer.cpp
    A lld/test/MachO/arm64-thunks.s
    A lld/test/MachO/tools/generate-thunkable-program.py

  Log Message:
  -----------
  [lld-macho] Implement branch-range-extension thunks

Extend the range of calls beyond an architecture's limited branch range by first calling a thunk, which loads the far address into a scratch register (x16 on ARM64) and branches through it.

Other ports (COFF, ELF) use multiple passes with successively-refined guesses regarding the expansion of text-space imposed by thunk-space overhead. This MachO algorithm places thunks during MergedOutputSection::finalize() in a single pass using exact thunk-space overheads. Thunks are kept in a separate vector to avoid the overhead of inserting into the `inputs` vector of `MergedOutputSection`.

FIXME:
* arm64-stubs.s test is broken
* add thunk tests
* Handle thunks to DylibSymbol in MergedOutputSection::finalize()

Differential Revision: https://reviews.llvm.org/D100818




More information about the All-commits mailing list