[PATCH] D157720: [llvm] Remove SmallSet from MachineInstr.h

Elliot Goodrich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 12:16:42 PDT 2023


IncludeGuardian created this revision.
Herald added subscribers: luke, pmatos, asb, frasercrmck, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, jgravelle-google, arichardson, sbc100, dschuff, qcolombet, MatzeB.
Herald added a project: All.
IncludeGuardian edited the summary of this revision.
IncludeGuardian published this revision for review.
IncludeGuardian added a comment.
Herald added subscribers: llvm-commits, wangpc, MaskRay, aheejin.
Herald added a project: LLVM.

The full output of ClangBuildAnalyzer with the removed template line highlighted is here <https://gist.github.com/IncludeGuardian/f76788a1c9f4c63c1135a57dad313cb8#file-clangbuildanalyzer-txt-L33>


`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()`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157720

Files:
  llvm/include/llvm/CodeGen/GlobalISel/LoadStoreOpt.h
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/lib/CodeGen/CalcSpillWeights.cpp
  llvm/lib/CodeGen/RegAllocFast.cpp
  llvm/lib/Target/RISCV/RISCVOptWInstrs.cpp
  llvm/lib/Target/RISCV/RISCVRVVInitUndef.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyExceptionInfo.h
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
  llvm/lib/Target/X86/X86PreTileConfig.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157720.549396.patch
Type: text/x-patch
Size: 5819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230811/13475319/attachment.bin>


More information about the llvm-commits mailing list