llvm.org GIT mirror llvm / 01b9856
[tblgen] Add a timer covering the time spent reading the Instruction defs This patch adds a -time-regions option to tablegen that can enable timers (currently only one) that assess the performance of tablegen itself. This can be useful for identifying scaling problems with tablegen backends. This particular timer has allowed me to ignore time that is not attributed the GISel combiner pass. It's useful by itself but it is particularly useful in combination with https://reviews.llvm.org/D52954 which causes this period of time to be annotated within Xcode Instruments which in turn allows profile samples and recorded allocations attributed to reading instructions to be filtered out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353763 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 8 months ago
3 changed file(s) with 17 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2121 /// raw_ostream.
2222 void emitSourceFileHeader(StringRef Desc, raw_ostream &OS);
2323
24 extern bool TimeRegions;
25
2426 } // End llvm namespace
2527
2628 #endif
1919 #include "llvm/ADT/STLExtras.h"
2020 #include "llvm/ADT/StringExtras.h"
2121 #include "llvm/Support/CommandLine.h"
22 #include "llvm/Support/Timer.h"
2223 #include "llvm/TableGen/Error.h"
2324 #include "llvm/TableGen/Record.h"
25 #include "llvm/TableGen/TableGenBackend.h"
2426 #include
2527 using namespace llvm;
2628
325327 }
326328
327329 void CodeGenTarget::ReadInstructions() const {
330 NamedRegionTimer T("Read Instructions", "Time spent reading instructions",
331 "CodeGenTarget", "CodeGenTarget", TimeRegions);
328332 std::vector Insts = Records.getAllDerivedDefinitions("Instruction");
329333 if (Insts.size() <= 2)
330334 PrintFatalError("No 'Instruction' subclasses defined!");
5353 GenRegisterBank,
5454 GenExegesis,
5555 };
56
57 namespace llvm {
58 /// Storage for TimeRegionsOpt as a global so that backends aren't required to
59 /// include CommandLine.h
60 bool TimeRegions = false;
61 } // end namespace llvm
5662
5763 namespace {
5864 cl::opt
125131 Class("class", cl::desc("Print Enum list for this class"),
126132 cl::value_desc("class name"), cl::cat(PrintEnumsCat));
127133
134 cl::opt
135 TimeRegionsOpt("time-regions",
136 cl::desc("Time regions of tablegens execution"),
137 cl::location(TimeRegions));
138
128139 bool LLVMTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
129140 switch (Action) {
130141 case PrintRecords: