[all-commits] [llvm/llvm-project] f27e45: [lld-macho] Implement ICF

Greg McGary via All-commits all-commits at lists.llvm.org
Thu Jun 17 10:09:30 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f27e4548fc42876f66dac260ca3b6df0d5fd5fd6
      https://github.com/llvm/llvm-project/commit/f27e4548fc42876f66dac260ca3b6df0d5fd5fd6
  Author: Greg McGary <gkm at fb.com>
  Date:   2021-06-17 (Thu, 17 Jun 2021)

  Changed paths:
    M lld/MachO/CMakeLists.txt
    M lld/MachO/ConcatOutputSection.cpp
    M lld/MachO/ConcatOutputSection.h
    M lld/MachO/Config.h
    M lld/MachO/Driver.cpp
    A lld/MachO/ICF.cpp
    A lld/MachO/ICF.h
    M lld/MachO/InputFiles.cpp
    M lld/MachO/InputSection.cpp
    M lld/MachO/InputSection.h
    M lld/MachO/Options.td
    M lld/MachO/Symbols.cpp
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/UnwindInfoSection.cpp
    M lld/MachO/UnwindInfoSection.h
    M lld/MachO/Writer.cpp
    M lld/test/MachO/Inputs/MacOSX.sdk/usr/lib/libSystem.tbd
    A lld/test/MachO/icf-options.s
    A lld/test/MachO/icf-scale.s
    A lld/test/MachO/icf.s

  Log Message:
  -----------
  [lld-macho] Implement ICF

ICF = Identical C(ode|OMDAT) Folding

This is the LLD ELF/COFF algorithm, adapted for MachO. So far, only `-icf all` is supported. In order to support `-icf safe`, we will need to port address-significance tables (`.addrsig` directives) to MachO, which will come in later diffs.

`check-{llvm,clang,lld}` have 0 regressions for `lld -icf all` vs. baseline ld64.

We only run ICF on `__TEXT,__text` for reasons explained in the block comment in `ConcatOutputSection.cpp`.

Here is the perf impact for linking `chromium_framekwork` on a Mac Pro (16-core Xeon W) for the non-ICF case vs. pre-ICF:
```
    N           Min           Max        Median           Avg        Stddev
x  20          4.27          4.44          4.34         4.349   0.043029977
+  20          4.37          4.46         4.405        4.4115   0.025188761
Difference at 95.0% confidence
        0.0625 +/- 0.0225658
        1.43711% +/- 0.518873%
        (Student's t, pooled s = 0.0352566)
```

Reviewed By: #lld-macho, int3

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




More information about the All-commits mailing list