[all-commits] [llvm/llvm-project] c416f3: [lld-macho][nfc] Remove file statics from ICF.cpp

Jez Ng via All-commits all-commits at lists.llvm.org
Mon Mar 7 09:37:06 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c416f3fafd8e6ed6249a181abe5c402386066811
      https://github.com/llvm/llvm-project/commit/c416f3fafd8e6ed6249a181abe5c402386066811
  Author: Jez Ng <jezng at fb.com>
  Date:   2022-03-07 (Mon, 07 Mar 2022)

  Changed paths:
    M lld/MachO/ICF.cpp

  Log Message:
  -----------
  [lld-macho][nfc] Remove file statics from ICF.cpp

This gets us closer to the [LLD-as-a-library goal][1].

[1]: https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html

Reviewed By: #lld-macho, thakis

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


  Commit: 53e7eef43f6928ff0daaed70d1a426c261621b1d
      https://github.com/llvm/llvm-project/commit/53e7eef43f6928ff0daaed70d1a426c261621b1d
  Author: Jez Ng <jezng at fb.com>
  Date:   2022-03-07 (Mon, 07 Mar 2022)

  Changed paths:
    M lld/MachO/ICF.cpp

  Log Message:
  -----------
  [lld-macho][nfc] Use llvm::function_ref instead of std::function


  Commit: 64cc719766ecc969e930a009f8c14302ba4faee8
      https://github.com/llvm/llvm-project/commit/64cc719766ecc969e930a009f8c14302ba4faee8
  Author: Jez Ng <jezng at fb.com>
  Date:   2022-03-07 (Mon, 07 Mar 2022)

  Changed paths:
    M lld/MachO/ICF.cpp

  Log Message:
  -----------
  [lld-macho][nfc] Track # of ICF calls to `equals*` methods

This is debug code that is disabled by default. It'll provide a easy way
to figure out the impact (if any) of tweaking ICF's hashing algorithm
(since a poor quality hash will result in many more `equals*` calls).

Reviewed By: #lld-macho, oontvoo

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


  Commit: 7028799ca3dcc91bee61cd086235296cabb33670
      https://github.com/llvm/llvm-project/commit/7028799ca3dcc91bee61cd086235296cabb33670
  Author: Jez Ng <jezng at fb.com>
  Date:   2022-03-07 (Mon, 07 Mar 2022)

  Changed paths:
    M lld/MachO/ICF.cpp

  Log Message:
  -----------
  [lld-macho][nfc] Rename isec -> referentIsec to avoid shadowing

I found the shadowing a bit confusing


  Commit: 112135e77444e8c8106efa77416af09f4b9a5012
      https://github.com/llvm/llvm-project/commit/112135e77444e8c8106efa77416af09f4b9a5012
  Author: Jez Ng <jezng at fb.com>
  Date:   2022-03-07 (Mon, 07 Mar 2022)

  Changed paths:
    M lld/MachO/ICF.cpp

  Log Message:
  -----------
  [lld-macho][nfc] Don't use `stubsHelperIndex` in ICF hash

The existing hashing of stubsHelperIndex has mostly been a no-op* for
some time now (ever since we made ICF run before dylib symbols get their
stubs indices assigned). I guess we could consider hashing the name +
filename of the DylibSymbol instead, but I'm not sure the overhead's
worth it... moreover, LLD/ELF only hashes their Defined symbols as well.

*: Technically it does change the hash value since stubsHelperIndex is
initialized to `UINT32_MAX` by default. But since all stubsHelperIndex
values are the same at when ICF runs, they don't add any useful
information to the hash.


  Commit: ad1c32e9b383c090ecfbebb5579b8cbac406564c
      https://github.com/llvm/llvm-project/commit/ad1c32e9b383c090ecfbebb5579b8cbac406564c
  Author: Jez Ng <jezng at fb.com>
  Date:   2022-03-07 (Mon, 07 Mar 2022)

  Changed paths:
    M lld/MachO/ICF.cpp
    M lld/MachO/InputSection.cpp
    M lld/MachO/InputSection.h

  Log Message:
  -----------
  [lld-macho][nfc] Reduce size of icfEqClass hash

... from a `uint64_t` to a `uint32_t`. (LLD-ELF uses a `uint32_t` too.)

About a 1.7% reduction in peak RSS when linking chromium_framework on my
3.2 GHz 16-Core Intel Xeon W Mac Pro, and no stat sig change in wall
time.

           </Users/jezng/test2.sh ["before"]>  </Users/jezng/test2.sh ["after"]>  difference (95% CI)
  RSS      1003036672.000 ± 9891065.259        985539505.231 ± 10272748.749       [  -2.3% ..   -1.2%]
  samples  27                                  26

             base           diff           difference (95% CI)
  sys_time   1.277 ± 0.023  1.277 ± 0.024  [  -0.9% ..   +0.9%]
  user_time  6.682 ± 0.046  6.598 ± 0.043  [  -1.6% ..   -0.9%]
  wall_time  5.904 ± 0.062  5.895 ± 0.063  [  -0.7% ..   +0.4%]
  samples    46             28

No appreciable change (~0.01%) in number of `equals` comparisons either:

Before:

  ld64.lld: ICF needed 8 iterations
  ld64.lld: equalsConstant() called 701643 times
  ld64.lld: equalsVariable() called 3438526 times

After:

  ld64.lld: ICF needed 8 iterations
  ld64.lld: equalsConstant() called 701729 times
  ld64.lld: equalsVariable() called 3438526 times

Reviewed By: #lld-macho, MaskRay, thakis

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


Compare: https://github.com/llvm/llvm-project/compare/2b5a16420f37...ad1c32e9b383


More information about the All-commits mailing list