[PATCH] D94342: [lld-macho] Basic support for linkage and visibility attributes in LTO

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 8 14:16:06 PST 2021


int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added subscribers: steven_wu, hiraditya, inglorion.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94342

Files:
  lld/MachO/InputFiles.cpp
  lld/MachO/LTO.cpp
  lld/test/MachO/invalid/duplicate-symbol.ll
  lld/test/MachO/invalid/protected.ll
  lld/test/MachO/linkonce.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94342.315518.patch
Type: text/x-patch
Size: 5558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210108/bacf889d/attachment.bin>


More information about the llvm-commits mailing list