[PATCH] D118169: [NFC][CodeGen] Use llvm::DenseMap for DeferredDecls

Dawid Jurczak via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 25 11:12:22 PST 2022


yurai007 created this revision.
yurai007 added reviewers: nikic, xbolva00, erichkeane, craig.topper, aeubanks, Tyker.
Herald added a subscriber: pengfei.
yurai007 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

CodeGenModule::DeferredDecls std::map operator[] seem to be hot especially while code generating huge compilation units.
In such cases using DenseMap instead gives observable compile time improvement. Patch was tested on Linux build with default config acting as benchmark.
Build was performed on isolated CPU cores in silent x86-64 Linux environment following: https://llvm.org/docs/Benchmarking.html#linux rules.
Compile time statistics diff produced by perf and time before and after change are following:
instructions -0.15%, cycles -0.7%, max-rss +0.65%.
Using StringMap instead DenseMap doesn't bring any visible gains.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118169

Files:
  clang/lib/CodeGen/CodeGenModule.h


Index: clang/lib/CodeGen/CodeGenModule.h
===================================================================
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -335,7 +335,7 @@
   /// for emission and therefore should only be output if they are actually
   /// used. If a decl is in this, then it is known to have not been referenced
   /// yet.
-  std::map<StringRef, GlobalDecl> DeferredDecls;
+  llvm::DenseMap<StringRef, GlobalDecl> DeferredDecls;
 
   /// This is a list of deferred decls which we have seen that *are* actually
   /// referenced. These get code generated when the module is done.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118169.402970.patch
Type: text/x-patch
Size: 630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220125/aaa60afe/attachment-0001.bin>


More information about the cfe-commits mailing list