This is an archive of the discontinued LLVM Phabricator instance.

[llvm] Remove SmallSet from MachineInstr.h
ClosedPublic

Authored by IncludeGuardian on Aug 11 2023, 7:55 AM.

Details

Summary

MachineInstr.h is a commonly included file and this includes
llvm/ADT/SmallSet.h for one function getUsedDebugRegs(), which is
used only in one place.

According to ClangBuildAnalyzer (run solely on building LLVM, no other
projects) the second most expensive template to instantiate is the
SmallSet::insert method used in the inline implementation in
getUsedDebugRegs():

**** Templates that took longest to instantiate:
554239 ms: std::unordered_map<int, int> (2826 times, avg 196 ms)
521187 ms: llvm::SmallSet<llvm::Register, 4>::insert (930 times, avg 560 ms)
...

By removing this method and putting its implementation in the one call
site we greatly reduce the template instantiation time and reduce the
number of includes.

When copying the implementation, I removed a check on MO.getReg() as
this is checked within MO.isVirtual().

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2023, 7:55 AM
Herald added subscribers: luke, pmatos, asb and 28 others. · View Herald Transcript
IncludeGuardian edited the summary of this revision. (Show Details)Aug 11 2023, 7:56 AM
IncludeGuardian published this revision for review.Aug 11 2023, 12:16 PM

The full output of ClangBuildAnalyzer with the removed template line highlighted is here

MaskRay accepted this revision.Aug 11 2023, 12:34 PM
This revision is now accepted and ready to land.Aug 11 2023, 12:34 PM
arsenm accepted this revision.Aug 11 2023, 2:39 PM
arsenm added a subscriber: arsenm.
arsenm added inline comments.
llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
22

I'm surprised there are any uses of std::set around

This revision was automatically updated to reflect the committed changes.