[llvm] [ProfileData] Use SortedVectorMap for BodySampleMap, TypeCountMap, and CallsiteTypeMap (PR #216530)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 17:18:58 PDT 2026


kazutakahirata wrote:

Thanks for the review!

- **Lifetime & Invalidation**: I have added `LLVM_LIFETIME_BOUND` to `getTypeSamplesAt()`, `findCallsiteTypeSamplesAt()`, `findCallTargetMapAt()`, and related accessors to catch temporary-lifetime issues at compile time. I have also added notes to their docstrings documenting that returned references/pointers may be invalidated by subsequent insertions or deletions in `FunctionSamples`.
- **Iterator Key Invariant**: Regarding `iterator.first`, `SortedVectorMap` follows the precedent of other flat/contiguous associative containers in LLVM (such as `DenseMap` and `MapVector`), which leave `.first` mutable so elements remain move- and copy-assignable for underlying vector storage without introducing proxy iterator complexity. Callers iterate over `const auto &` views in practice, and I've ensured this invariant is respected across the codebase.

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


More information about the llvm-commits mailing list