From 817096eff6d0d0d480ce95d23029ddd947577c58 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 24 Jan 2024 09:51:51 -0800 Subject: [PATCH] [IR] Use SmallDenseSet (NFC) The use of SmallDenseSet saves 0.39% of heap allocations during the compilation of a large preprocessed file, namely X86ISelLowering.cpp, for the X86 target. During the experiment, WL.size() was 2 or less 99.9% of the time. The inline size of 4 should accommodate up to 2 entries at the 3/4 occupancy rate. --- llvm/lib/IR/Instruction.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp index f9a38e48166c9..904ce17fb0e7c 100644 --- a/llvm/lib/IR/Instruction.cpp +++ b/llvm/lib/IR/Instruction.cpp @@ -1167,9 +1167,7 @@ void Instruction::copyMetadata(const Instruction &SrcInst, if (!SrcInst.hasMetadata()) return; - DenseSet WLS; - for (unsigned M : WL) - WLS.insert(M); + SmallDenseSet WLS(WL.begin(), WL.end()); // Otherwise, enumerate and copy over metadata from the old instruction to the // new one.