[PATCH] D106213: [lld-macho] Enable copy-on-write for input buffers

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 30 13:30:30 PDT 2021


dexonsmith added a comment.

In D106213#2905976 <https://reviews.llvm.org/D106213#2905976>, @int3 wrote:

> I am not able to get ld64 to dedup even the simplest of functions, let alone more complicated cases like these.

It's not safe to dedup symbols in general, since it's not always known if their addresses are compared.

Mach-O can be marked "autohide" or `.weak_def_can_be_hidden`, something LLVM sets on symbols when `GlobalValue::canBeOmittedFromSymbolTable` (see https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Globals.cpp#L311 or grep for `MCSA_WeakDefAutoPrivate`) -- that is, when a symbol is `linkonce_odr` and `unnamed_addr`. GlobalVariables that are also `const` can just be `local_unnamed_addr`. For C++ code, this should be true for most inlines and templates.

ld64 reuses this autohide flag to trigger dedup only when it's safe.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106213/new/

https://reviews.llvm.org/D106213



More information about the llvm-commits mailing list