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

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 16 23:41:51 PDT 2021


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

The Mach-O format makes extensive use of embedded addends,
particularly for x86_64. This makes ICF's job a bit more difficult:
sections that are otherwise semantically identical may have different
raw bytes due to the embedded addends. Hashing and comparing the raw
bytes naively means that we miss folding opportunities.

This diff canonicalizes these sections by writing over those embedded
addends with zeros. In order to make this possible, the our previously
read-only MemoryBuffers need to be made into copy-on-write.

This requires some awkward casts, but I'm not sure there's a better way to do
things...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106213

Files:
  lld/MachO/Arch/ARM.cpp
  lld/MachO/Arch/ARM64Common.cpp
  lld/MachO/Arch/ARM64Common.h
  lld/MachO/Arch/X86_64.cpp
  lld/MachO/Driver.cpp
  lld/MachO/Driver.h
  lld/MachO/DriverUtils.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/InputFiles.h
  lld/MachO/LTO.cpp
  lld/MachO/LTO.h
  lld/MachO/ObjC.cpp
  lld/MachO/ObjC.h
  lld/MachO/Target.h
  llvm/include/llvm/LTO/Caching.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/include/llvm/Support/MemoryBufferRef.h
  llvm/lib/LTO/Caching.cpp
  llvm/lib/Object/Archive.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/MemoryBufferRef.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106213.359537.patch
Type: text/x-patch
Size: 31628 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210717/4331eb3f/attachment.bin>


More information about the llvm-commits mailing list