[PATCH] D109944: [lld-macho] Associate compact unwind entries with function symbols

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 16 20:35:50 PDT 2021


int3 created this revision.
int3 added a reviewer: lld-macho.
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.

Compact unwind entries (CUEs) contain pointers to their respective
function symbols. However, during the link process, it's far more useful
to have pointers from the function symbol to the CUE than vice versa.
This diff adds that pointer in the form of `Defined::compactUnwind`.

In particular, when doing dead-stripping, we want to mark CUEs live when
their function symbol is live; and when doing ICF, we want to dedup
sections iff the symbols in that section have identical CUEs. In both
cases, we want to be able to locate the symbols within a given section,
as well as locate the CUEs belonging to those symbols. So this diff also
adds `InputSection::symbols`.

The ultimate goal of this refactor is to have ICF support dedup'ing
functions with unwind info, but that will be handled in subsequent
diffs. This diff focuses on simplifying `-dead_strip` --
`findFunctionsWithUnwindInfo` is no longer necessary, and
`Defined::isLive()` is now a lot simpler. Moreover, UnwindInfoSection no
longer has to check for dead CUEs -- we simply avoid adding them in the
first place.

Additionally, we now support stripping of dead LSDAs, which follows
quite naturally since `markLive()` can now reach them via the CUEs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109944

Files:
  lld/MachO/ConcatOutputSection.cpp
  lld/MachO/Driver.cpp
  lld/MachO/ICF.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/InputFiles.h
  lld/MachO/InputSection.cpp
  lld/MachO/InputSection.h
  lld/MachO/MarkLive.cpp
  lld/MachO/SymbolTable.cpp
  lld/MachO/Symbols.cpp
  lld/MachO/Symbols.h
  lld/MachO/SyntheticSections.cpp
  lld/MachO/UnwindInfoSection.cpp
  lld/MachO/UnwindInfoSection.h
  lld/MachO/Writer.cpp
  lld/test/MachO/dead-strip.s
  lld/test/MachO/invalid/cfstring.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109944.373130.patch
Type: text/x-patch
Size: 34551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210917/68efdf91/attachment.bin>


More information about the llvm-commits mailing list