[clang] [llvm] [clang][Sema] Use DenseMap for SpecialMemberCache (NFC) (PR #221304)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 4 11:50:57 PDT 2026


kazutakahirata wrote:

@erichkeane Here is the memory impact measured by instrumenting `LookupSpecialMember` on a compile of `SLPVectorizer.ii` (where the cache reaches 27,016 entries):

- **Before (`FoldingSet` + `BumpAlloc`)**:
  - Each `SpecialMemberOverloadResultEntry` is 160 bytes (152-byte `FastFoldingSetNode` + 8-byte result) allocated on `BumpAlloc`.
  - Arena allocations: 27,016 × 160 bytes = ~4.12 MiB (unreclaimable until `Sema` teardown).
  - Hash buckets with pointers: 65,536 × 8 bytes = ~0.50 MiB.
  - Total: ~4.62 MiB.

- **After (`DenseMap`)**:
  - Each bucket is 24 bytes (16-byte key + 8-byte result).
  - Arena allocations: 0 bytes.
  - Hash buckets with key-value pairs: 65,536 × 24 bytes = ~1.50 MiB.
  - Total: ~1.50 MiB.

As far as performance goes, compiling about 25,000 C++ source files sped up by 0.05% — pretty much a wash despite N = 25,000.


https://github.com/llvm/llvm-project/pull/221304


More information about the cfe-commits mailing list