[all-commits] [llvm/llvm-project] e0c7f0: [lld-macho] Refactor BPSectionOrderer with CRTP. NFC

Fangrui Song via All-commits all-commits at lists.llvm.org
Mon Jan 27 18:25:20 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e0c7f081f1582d49f81ec4c6cdbf5d6ef13c58ba
      https://github.com/llvm/llvm-project/commit/e0c7f081f1582d49f81ec4c6cdbf5d6ef13c58ba
  Author: Fangrui Song <i at maskray.me>
  Date:   2025-01-27 (Mon, 27 Jan 2025)

  Changed paths:
    R lld/Common/BPSectionOrdererBase.cpp
    M lld/Common/CMakeLists.txt
    M lld/MachO/BPSectionOrderer.cpp
    M lld/MachO/BPSectionOrderer.h
    M lld/MachO/CMakeLists.txt
    R lld/include/lld/Common/BPSectionOrdererBase.h
    A lld/include/lld/Common/BPSectionOrdererBase.inc

  Log Message:
  -----------
  [lld-macho] Refactor BPSectionOrderer with CRTP. NFC

PR #117514 refactored BPSectionOrderer to be used by the ELF port
but introduced some inefficiency:

* BPSectionBase/BPSymbol are wrappers around a single pointer.
  The numbers of sections and symbols could be huge, and the extra
  allocations are memory inefficient.
* Reconstructing the returned DenseMap (since BPSectionBase != InputSectin)
  is wasteful.

This patch refactors BPSectionOrderer with Curiously Recurring Template
Pattern and eliminates the inefficiency. In addition,
`symbolToSectionIdxs` is removed and `rootSymbolToSectionIdxs` building
is moved to lld/MachO: while getting sections for symbols is cheap in
Mach-O, it is awkward and inefficient in the ELF port.

While here, add a file-level comment and replace some `StringMap<*>`
(which copies strings) with `DenseMap<CachedHashStringRef, *>`.

Pull Request: https://github.com/llvm/llvm-project/pull/124482



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