Skip to content

Commit c9790f8

Browse files
[IR] Use SmallDenseSet (NFC) (#79556)
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.
1 parent c1a155b commit c9790f8

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

llvm/lib/IR/Instruction.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,7 @@ void Instruction::copyMetadata(const Instruction &SrcInst,
11671167
if (!SrcInst.hasMetadata())
11681168
return;
11691169

1170-
DenseSet<unsigned> WLS;
1171-
for (unsigned M : WL)
1172-
WLS.insert(M);
1170+
SmallDenseSet<unsigned, 4> WLS(WL.begin(), WL.end());
11731171

11741172
// Otherwise, enumerate and copy over metadata from the old instruction to the
11751173
// new one.

0 commit comments

Comments
 (0)