[llvm] a78b19d - [IR] Use SmallSet with more inline elements in dropUnknownNonDebugMetadata (NFC) (#98853)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 09:19:18 PDT 2024


Author: Kazu Hirata
Date: 2024-07-15T09:19:15-07:00
New Revision: a78b19d8ea513a2e88fa431b549b65406384a12d

URL: https://github.com/llvm/llvm-project/commit/a78b19d8ea513a2e88fa431b549b65406384a12d
DIFF: https://github.com/llvm/llvm-project/commit/a78b19d8ea513a2e88fa431b549b65406384a12d.diff

LOG: [IR] Use SmallSet with more inline elements in dropUnknownNonDebugMetadata (NFC) (#98853)

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 SmallSet<unsigned, 32> to avoid memory
allocations.

The increased inline elements here save 0.57% of heap allocations during
the compilation of X86ISelLowering.cpp.ii, a preprocessed version of
X86ISelLowering.cpp.

Added: 
    

Modified: 
    llvm/lib/IR/Metadata.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 5f42ce22f72fe..3aec7140510a6 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -1590,7 +1590,7 @@ void Instruction::dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs) {
   if (!Value::hasMetadata())
     return; // Nothing to remove!
 
-  SmallSet<unsigned, 4> KnownSet;
+  SmallSet<unsigned, 32> KnownSet;
   KnownSet.insert(KnownIDs.begin(), KnownIDs.end());
 
   // A DIAssignID attachment is debug metadata, don't drop it.


        


More information about the llvm-commits mailing list