[PATCH] D40170: [llvm-tblgen] - Stop using std:string in RecordKeeper.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 02:09:48 PST 2017


grimar created this revision.

I was wondering why building of LLVM takes so much time for me and
tried to profile llvm-tblgen, which calls for X86CommonTableGen module looks
take about 24 minutes on my i7-4970k@~4.0 under windows with MSVS 2015 for debug build.

I found `RecordKeeper::getDef()` shows up in profiling and it
creates std::string instance for each search in `RecordMap` though RecordKeeper::RecordMap
can use StringRef as a key instead to avoid that I believe.

Total time seem reduces for about 12 seconds (from initial ~24minutes) so it is not so significant, but still a bit better.
(During investigation I found LLVM_OPTIMIZED_TABLEGEN flag and going to check how it helps, but still looks
we can fix that place to avoid excessive allocations too).

Sorry I also not sure who should be reviewer for that, and code looks really old, 
so added people who modified code around that place.


https://reviews.llvm.org/D40170

Files:
  include/llvm/TableGen/Record.h


Index: include/llvm/TableGen/Record.h
===================================================================
--- include/llvm/TableGen/Record.h
+++ include/llvm/TableGen/Record.h
@@ -1525,7 +1525,7 @@
 };
 
 class RecordKeeper {
-  using RecordMap = std::map<std::string, std::unique_ptr<Record>>;
+  using RecordMap = std::map<StringRef, std::unique_ptr<Record>>;
   RecordMap Classes, Defs;
 
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40170.123306.patch
Type: text/x-patch
Size: 401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171117/c63be134/attachment.bin>


More information about the llvm-commits mailing list