Skip to content

Commit

Permalink
[IR] Use SmallDenseSet (NFC) (#79556)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kazutakahirata committed Jan 27, 2024
1 parent c1a155b commit c9790f8
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions llvm/lib/IR/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,9 +1167,7 @@ void Instruction::copyMetadata(const Instruction &SrcInst,
if (!SrcInst.hasMetadata())
return;

DenseSet<unsigned> WLS;
for (unsigned M : WL)
WLS.insert(M);
SmallDenseSet<unsigned, 4> WLS(WL.begin(), WL.end());

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

0 comments on commit c9790f8

Please sign in to comment.