[llvm] [ADT] Extract DenseMapStorage from DenseMap (NFC) (PR #226664)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 27 18:28:49 PDT 2026
================
@@ -192,6 +192,101 @@ LLVM_ABI void *growRelocatable(void *OldBuckets, const UsedT *OldUsed,
size_t BucketSize, size_t Align,
BucketHasher Hasher, bool FreeOld);
+// A snapshot of the three fields the hot lookup paths need. Fetching them
+// together lets SmallDenseMap test its Small discriminator once rather than
+// once per accessor; for plain DenseMap it is three member loads either way.
+template <typename BucketT> struct StorageRep {
+ const BucketT *Buckets;
+ const UsedT *Used;
+ unsigned NumBuckets;
+};
+
+template <typename BucketT> class DenseMapStorage {
+ BucketT *Buckets = nullptr;
+ UsedT *Used = nullptr;
+ unsigned NumEntries = 0;
+ unsigned NumBuckets = 0;
+
+public:
+ DenseMapStorage() = default;
----------------
MaskRay wrote:
unneeded user-providied default ctor
https://github.com/llvm/llvm-project/pull/226664
More information about the llvm-commits
mailing list