[all-commits] [llvm/llvm-project] 84579f: [lld-macho] Basic support for linkage and visibili...

Jez Ng via All-commits all-commits at lists.llvm.org
Thu Feb 25 10:28:07 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 84579fc24f03c8ca778e70325dad2166f1deaee3
      https://github.com/llvm/llvm-project/commit/84579fc24f03c8ca778e70325dad2166f1deaee3
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-02-25 (Thu, 25 Feb 2021)

  Changed paths:
    M lld/MachO/InputFiles.cpp
    M lld/MachO/LTO.cpp
    A lld/test/MachO/invalid/duplicate-symbol.ll
    A lld/test/MachO/invalid/protected.ll
    A lld/test/MachO/linkonce.ll

  Log Message:
  -----------
  [lld-macho] Basic support for linkage and visibility attributes in LTO

When parsing bitcode, convert LTO Symbols to LLD Symbols in order to perform
resolution. The "winning" symbol will then be marked as Prevailing at LTO
compilation time. This is similar to what the other LLD ports do.

This change allows us to handle `linkonce` symbols correctly, and to deal with
duplicate bitcode symbols gracefully. Previously, both scenarios would result in
an assertion failure inside the LTO code, complaining that multiple Prevailing
definitions are not allowed.

While at it, I also added basic logic around visibility. We don't do anything
useful with it yet, but we do check that its value is valid. LLD-ELF appears to
use it only to set FinalDefinitionInLinkageUnit for LTO, which I think is just a
performance optimization.

>From my local experimentation, the linker itself doesn't seem to do anything
differently when encountering linkonce / linkonce_odr / weak / weak_odr. So I've
only written a test for one of them. LLD-ELF has more, but they seem to mostly
be testing the intermediate bitcode output of their LTO backend...? I'm far from
an expert here though, so I might very well be missing things.

Reviewed By: #lld-macho, MaskRay, smeenai

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




More information about the All-commits mailing list