[all-commits] [llvm/llvm-project] 84afdb: [lld][MachO] Avoid quadratic iteration over alread...

Peter Rong via All-commits all-commits at lists.llvm.org
Sat Aug 1 12:44:47 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 84afdb477133cb04cf842d2d57d4e5e1461ba924
      https://github.com/llvm/llvm-project/commit/84afdb477133cb04cf842d2d57d4e5e1461ba924
  Author: Peter Rong <peterrong96 at gmail.com>
  Date:   2026-08-01 (Sat, 01 Aug 2026)

  Changed paths:
    M lld/MachO/InputSection.cpp
    A lld/test/MachO/icf-scale-same-class.s

  Log Message:
  -----------
  [lld][MachO] Avoid quadratic iteration over already-folded symbols during ICF (#213339)

`ConcatInputSection::foldIdentical()` clears the folded functions
`originalUnwindEntry`.
However, it cleared every symbol: with N members, the repeated clearing
is **O(N²)**.
This is redundant: we should only remove the incoming `copy->symbols`.

This patch moves the removing loop ahead and adds more clear comments on
why we need to skip the first element.
Also added a new `lld/test/MachO/icf-scale-same-class.s` with 500K
identical functions as a stress test, which would've taken minutes to
link, and less than a second with the patch.

Testing on real-world app (IRPGO instrumentation + ICF) find that we
achieved a 19x speed up (1:14:42 -> 3:55)



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list