[all-commits] [llvm/llvm-project] eb5b7d: [lld-macho] LTO: Unset VisibleToRegularObj where p...

Jez Ng via All-commits all-commits at lists.llvm.org
Thu Apr 15 18:16:55 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eb5b7d4497e323cf6214eb3e008dc37bc5ed1fd7
      https://github.com/llvm/llvm-project/commit/eb5b7d4497e323cf6214eb3e008dc37bc5ed1fd7
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-04-15 (Thu, 15 Apr 2021)

  Changed paths:
    M lld/MachO/LTO.cpp
    M lld/MachO/SymbolTable.cpp
    M lld/MachO/SymbolTable.h
    M lld/MachO/Symbols.h
    A lld/test/MachO/internalize.ll
    M lld/test/MachO/lto-save-temps.ll

  Log Message:
  -----------
  [lld-macho] LTO: Unset VisibleToRegularObj where possible

This allows LLVM's LTO to internalize symbols that are not referenced
directly by regular objects. Naturally, this means we need to track
which symbols are referenced by regular objects. The approach taken here
is similar to LLD-COFF's: like the COFF port, we extend
`SymbolTable::insert()` to set the isVisibleToRegularObj bit. (LLD-ELF
relies on the Symbol constructor and `Symbol::mergeProperties()`, but
the Mach-O port does not have a `mergeProperties()` equivalent.)

>From what I can tell, ld64 (which uses libLTO) doesn't do this
optimization at all. I'm not even sure libLTO provides a way to do this.
Not having ld64's behavior as a reference implementation is unfortunate;
instead, I am relying on LLD-ELF/COFF's behavior as references while
erring on the conservative side. In particular, LLD-MachO will only do
this optimization for executables right now.

We also don't attempt it when `-flat_namespace` is used -- otherwise
we'd need scan the symbol table to find matches for every un-namespaced
symbol reference, which is expensive.

internalize.ll is based off the LLD-ELF tests `internalize-basic.ll` and
`internalize-undef.ll`. Looks like @davide added some of LLD-ELF's internalize
tests, so adding him as a reviewer...

Reviewed By: #lld-macho, gkm

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


  Commit: db7a413e51c5134375d564a1599b8657ca1c8161
      https://github.com/llvm/llvm-project/commit/db7a413e51c5134375d564a1599b8657ca1c8161
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-04-15 (Thu, 15 Apr 2021)

  Changed paths:
    M lld/MachO/Driver.cpp
    M lld/test/MachO/dependency-info.s
    A lld/test/MachO/reroot-path.s

  Log Message:
  -----------
  [lld-macho] Re-root absolute input file paths if -syslibroot is specified

Reviewed By: #lld-macho, gkm

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


  Commit: 3bc88eb3924f6491457a787db3a8cf5ab45c92c1
      https://github.com/llvm/llvm-project/commit/3bc88eb3924f6491457a787db3a8cf5ab45c92c1
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-04-15 (Thu, 15 Apr 2021)

  Changed paths:
    M lld/MachO/Arch/ARM64.cpp
    A lld/MachO/Arch/ARM64Common.cpp
    A lld/MachO/Arch/ARM64Common.h
    A lld/MachO/Arch/ARM64_32.cpp
    M lld/MachO/CMakeLists.txt
    M lld/MachO/Driver.cpp
    M lld/MachO/MachOStructs.h
    M lld/MachO/Target.h
    M lld/MachO/Writer.cpp
    A lld/test/MachO/Inputs/WatchOS.sdk/usr/lib/libSystem.tbd
    A lld/test/MachO/Inputs/WatchOS.sdk/usr/lib/libc++.tbd
    A lld/test/MachO/Inputs/WatchOS.sdk/usr/lib/libc++abi.tbd
    A lld/test/MachO/arm64-32-stubs.s
    M lld/test/MachO/header.s
    M lld/test/MachO/lit.local.cfg
    M lld/test/MachO/segments.s

  Log Message:
  -----------
  [lld-macho] Add support for arm64_32

>From what I can tell, it's pretty similar to arm64. The two main differences
are:

1. No 64-bit relocations
2. Stub code writes to 32-bit registers instead of 64-bit

Plus of course the various on-disk structures like `segment_command` are using
the 32-bit instead of the 64-bit variants.

Reviewed By: #lld-macho, gkm

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


  Commit: 1460942c15a71f5e9ad55344c0e17771ea0ecb57
      https://github.com/llvm/llvm-project/commit/1460942c15a71f5e9ad55344c0e17771ea0ecb57
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-04-15 (Thu, 15 Apr 2021)

  Changed paths:
    M lld/MachO/Relocations.h
    M lld/MachO/SyntheticSections.h
    M lld/MachO/UnwindInfoSection.cpp
    M lld/MachO/UnwindInfoSection.h
    M lld/MachO/Writer.cpp
    M lld/test/MachO/compact-unwind.s

  Log Message:
  -----------
  [lld-macho] Add 32-bit compact unwind support

This could probably have been part of D99633, but I split it up to make
things a bit more reviewable. I also fixed some bugs in the implementation that
were masked through integer underflows when operating in 64-bit mode.

Reviewed By: #lld-macho, gkm

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


  Commit: 1acda12d00ec2ea769998af4f3df6e98781185d1
      https://github.com/llvm/llvm-project/commit/1acda12d00ec2ea769998af4f3df6e98781185d1
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-04-15 (Thu, 15 Apr 2021)

  Changed paths:
    M lld/MachO/Arch/ARM64Common.cpp
    A lld/test/MachO/arm64-32-reloc-got-load.s

  Log Message:
  -----------
  [lld-macho] Make load relaxation work for arm64_32

arm64_32 uses 32-bit GOT loads, so we should accept those
instructions in `ARM64Common::relaxGotLoad()` too.

Reviewed By: #lld-macho, gkm

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


  Commit: 4938b090cf0b8c0f716119a7f16205e53608cae2
      https://github.com/llvm/llvm-project/commit/4938b090cf0b8c0f716119a7f16205e53608cae2
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-04-15 (Thu, 15 Apr 2021)

  Changed paths:
    M lld/MachO/Arch/ARM64.cpp
    M lld/MachO/Arch/ARM64Common.h
    M lld/MachO/Arch/ARM64_32.cpp

  Log Message:
  -----------
  [lld-macho] Don't use arrays as template parameters

MSVC from VSCode 2017 appears unhappy with it (causes an
internal compiler error.)

This also means that we need to avoid doing `sizeof(stubCode)` as
`sizeof(int[N])` on function array parameters decays into `sizeof(int *)`.

Reviewed By: #lld-macho, gkm

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


Compare: https://github.com/llvm/llvm-project/compare/f7c9de0de580...4938b090cf0b


More information about the All-commits mailing list