[llvm] [IR] Use SmallDenseSet in dropUnknownNonDebugMetadata (NFC) (PR #98853)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 14 19:19:12 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
SmallSet here often ends up allocating memory via std::set inside
SmallSet because KnownIDs.size() goes up to 17 on an x86 host. This
patch switches to SmallDenseSet<unsigned, 32> to avoid memory
allocations.
The use of SmallDenseSet here saves 0.57% of heap allocations during
the compilation of X86ISelLowering.cpp.ii, a preprocessed version of
X86ISelLowering.cpp.
---
Full diff: https://github.com/llvm/llvm-project/pull/98853.diff
1 Files Affected:
- (modified) llvm/lib/IR/Metadata.cpp (+1-2)
``````````diff
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 5f42ce22f72fe..a1bae38b07ab6 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -20,7 +20,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
@@ -1590,7 +1589,7 @@ void Instruction::dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs) {
if (!Value::hasMetadata())
return; // Nothing to remove!
- SmallSet<unsigned, 4> KnownSet;
+ SmallDenseSet<unsigned, 32> KnownSet;
KnownSet.insert(KnownIDs.begin(), KnownIDs.end());
// A DIAssignID attachment is debug metadata, don't drop it.
``````````
</details>
https://github.com/llvm/llvm-project/pull/98853
More information about the llvm-commits
mailing list