[llvm] [ADT] Skip destroying trivially destructible values in DenseMap (PR #106934)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 1 18:47:56 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

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


``````````diff
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index f71cd5b4771b75..68f3f1defc2bd0 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -392,6 +392,11 @@ class DenseMapBase : public DebugEpochBase {
   DenseMapBase() = default;
 
   void destroyAll() {
+    // Don't bother destroying trivially destructible stuff.
+    if constexpr (std::is_trivially_destructible_v<KeyT> &&
+                  std::is_trivially_destructible_v<ValueT>)
+      return;
+
     if (getNumBuckets() == 0) // Nothing to do.
       return;
 

``````````

</details>


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


More information about the llvm-commits mailing list