]> granicus.if.org Git - llvm/commitdiff
[tblgen] Add a timer covering the time spent reading the Instruction defs
authorDaniel Sanders <daniel_l_sanders@apple.com>
Mon, 11 Feb 2019 23:02:02 +0000 (23:02 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Mon, 11 Feb 2019 23:02:02 +0000 (23:02 +0000)
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

include/llvm/TableGen/TableGenBackend.h
utils/TableGen/CodeGenTarget.cpp
utils/TableGen/TableGen.cpp

index 08c581519fcf2c83c2e454484d1ad8a37c840f60..a426e4217578438e60177b17fbf473834bf107d8 100644 (file)
@@ -22,6 +22,8 @@ class raw_ostream;
 /// raw_ostream.
 void emitSourceFileHeader(StringRef Desc, raw_ostream &OS);
 
+extern bool TimeRegions;
+
 } // End llvm namespace
 
 #endif
index 5dcb5e230ccbd8e57a943b0961dffa284ceaf57d..5c7be10cebcab864b4b7131db5f70de4df7f6d74 100644 (file)
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/TableGenBackend.h"
 #include <algorithm>
 using namespace llvm;
 
@@ -326,6 +328,8 @@ CodeGenSchedModels &CodeGenTarget::getSchedModels() const {
 }
 
 void CodeGenTarget::ReadInstructions() const {
+  NamedRegionTimer T("Read Instructions", "Time spent reading instructions",
+                     "CodeGenTarget", "CodeGenTarget", TimeRegions);
   std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
   if (Insts.size() <= 2)
     PrintFatalError("No 'Instruction' subclasses defined!");
index 38f81dc396c793f6bee87dcf0572701b8e391ff0..c485ed2feb7afd7eba66038558294f04ad37e3af 100644 (file)
@@ -55,6 +55,12 @@ enum ActionType {
   GenExegesis,
 };
 
+namespace llvm {
+/// Storage for TimeRegionsOpt as a global so that backends aren't required to
+/// include CommandLine.h
+bool TimeRegions = false;
+} // end namespace llvm
+
 namespace {
   cl::opt<ActionType>
   Action(cl::desc("Action to perform:"),
@@ -126,6 +132,11 @@ namespace {
   Class("class", cl::desc("Print Enum list for this class"),
         cl::value_desc("class name"), cl::cat(PrintEnumsCat));
 
+cl::opt<bool, true>
+    TimeRegionsOpt("time-regions",
+                   cl::desc("Time regions of tablegens execution"),
+                   cl::location(TimeRegions));
+
 bool LLVMTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
   switch (Action) {
   case PrintRecords: