[all-commits] [llvm/llvm-project] 428a7c: [lld-macho] Have ICF operate on all sections at once

Jez Ng via All-commits all-commits at lists.llvm.org
Sat Jul 17 10:43:17 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 428a7c1b38d2cde21c63744561e5f17830e17697
      https://github.com/llvm/llvm-project/commit/428a7c1b38d2cde21c63744561e5f17830e17697
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-07-17 (Sat, 17 Jul 2021)

  Changed paths:
    M lld/MachO/ConcatOutputSection.cpp
    M lld/MachO/ConcatOutputSection.h
    M lld/MachO/Driver.cpp
    M lld/MachO/ICF.cpp
    M lld/MachO/InputSection.cpp
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/SyntheticSections.h
    M lld/MachO/UnwindInfoSection.cpp
    M lld/MachO/Writer.cpp
    M lld/MachO/Writer.h
    M lld/test/MachO/icf.s

  Log Message:
  -----------
  [lld-macho] Have ICF operate on all sections at once

ICF previously operated only within a given OutputSection. We would
merge all CFStrings first, then merge all regular code sections in a
second phase. This worked fine since CFStrings would never reference
regular `__text` sections. However, I would like to expand ICF to merge
functions that reference unwind info. Unwind info references the LSDA
section, which can in turn reference the `__text` section, so we cannot
perform ICF in phases.

In order to have ICF operate on InputSections spanning multiple
OutputSections, we need a way to distinguish InputSections that are
destined for different OutputSections, so that we don't fold across
section boundaries. We achieve this by creating OutputSections early,
and setting `InputSection::parent` to point to them. This is what
LLD-ELF does. (This change should also make it easier to implement the
`section$start$` symbols.)

This diff also folds InputSections w/o checking their flags, which I
think is the right behavior -- if they are destined for the same
OutputSection, they will have the same flags in the output (even if
their input flags differ). I.e. the `parent` pointer check subsumes the
`flags` check. In practice this has nearly no effect (ICF did not become
any more effective on chromium_framework).

I've also updated ICF.cpp's block comment to better reflect its current
status.

Reviewed By: #lld-macho, smeenai

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




More information about the All-commits mailing list