[all-commits] [llvm/llvm-project] 8e6f26: [DenseMap] Share rehash and grow for relocatable b...

Fangrui Song via All-commits all-commits at lists.llvm.org
Sun Sep 27 12:15:06 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8e6f2603dc5d4a93400aa8ba28ea624644be0c9a
      https://github.com/llvm/llvm-project/commit/8e6f2603dc5d4a93400aa8ba28ea624644be0c9a
  Author: Fangrui Song <i at maskray.me>
  Date:   2026-09-27 (Sun, 27 Sep 2026)

  Changed paths:
    M llvm/include/llvm/ADT/DenseMap.h
    M llvm/include/llvm/ADT/DenseMapInfo.h
    M llvm/lib/Support/CMakeLists.txt
    A llvm/lib/Support/DenseMap.cpp
    M llvm/unittests/ADT/DenseMapTest.cpp
    M llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn

  Log Message:
  -----------
  [DenseMap] Share rehash and grow for relocatable bucket types. NFC (#225018)

DenseMap is heavily instantiated and moveFrom and grow are among the
largest code families. For trivially copy constructible and destructible
bucket types (also satisfied by std::pair), call an out-of-line
`growRelocatable` with size/align/hasher (dictionary passing style).

A pointer key hashed by its value hashes inline, which a null
BucketHasher asks for, sparing a call per entry.
DenseMapInfo<T *>::PointerValueHash names the class declaring it, so an
info that specializes or inherits it to hash the pointee -- Attributor's
InstExclusionSet, VPCSEDenseMapInfo, MachineInstrExpressionTrait --
keeps its own hash. Any other key hashes through a thunk, one per
(KeyT, KeyInfoT) whatever the map's value type.

SmallDenseMap's in-place rehash for remove_if shares the loop through
`rehashRelocatable`. It rehashes once rather than into a temporary map
and back, which can reorder a probe chain that wraps around the table.

Building clang takes 0.86% fewer instructions and the binary is 0.64%
smaller.

Aided by Opus 5



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