[llvm] [ADT] Remove zombie-instance handling from SmallDenseMapStorage (NFC) (PR #228925)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 10:48:07 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

This patch removes the redundant storage.Large.NumBuckets == 0 check
and the two dead stores to the field from SmallDenseMapStorage.

SmallDenseMapStorage used to have a zombie state:

    !Small && storage.Large.NumBuckets == 0

in grow() so that ~DenseMapBase(), which calls deallocateBuckets(),
could safely destruct the moved-from temporary DenseMapBase instance.

With #<!-- -->228802, grow() directly uses StorageT for the temporary storage,
so SmallDenseMapStorage no longer enters the zombie state.

Assisted-by: Antigravity


---
Full diff: https://github.com/llvm/llvm-project/pull/228925.diff


1 Files Affected:

- (modified) llvm/include/llvm/ADT/DenseMap.h (+1-5) 


``````````diff
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 92eae370e0219..f25358dd79744 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -462,15 +462,12 @@ class SmallDenseMapStorage {
   }
 
   void deallocateBuckets() {
-    // Fast path in case storage.Large.NumBuckets == 0, just like destroyAll.
-    // This path is used to destruct zombie instances after moves.
-    if (Small || storage.Large.NumBuckets == 0)
+    if (Small)
       return;
 
     deallocate_buffer(storage.Large.Buckets,
                       allocBytes<BucketT>(storage.Large.NumBuckets),
                       allocAlign<BucketT>());
-    storage.Large.NumBuckets = 0;
   }
 
   bool allocateBuckets(unsigned Num) {
@@ -513,7 +510,6 @@ class SmallDenseMapStorage {
     Small = false;
     NumEntries = Other.NumEntries;
     storage.Large = Other.storage.Large;
-    Other.storage.Large.NumBuckets = 0;
     return true;
   }
 };

``````````

</details>


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


More information about the llvm-commits mailing list