[llvm] 0aeaec1 - [Timer] Add a command option to enable/disable timer sorting.

Paul C. Anagnostopoulos via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 28 08:44:05 PST 2020


Author: Paul C. Anagnostopoulos
Date: 2020-11-28T11:43:38-05:00
New Revision: 0aeaec13e76a9b268cafd9b3cd3f24eb922777b0

URL: https://github.com/llvm/llvm-project/commit/0aeaec13e76a9b268cafd9b3cd3f24eb922777b0
DIFF: https://github.com/llvm/llvm-project/commit/0aeaec13e76a9b268cafd9b3cd3f24eb922777b0.diff

LOG: [Timer] Add a command option to enable/disable timer sorting.

Add one more timer to DAGISelEmitter to test the option.

Differential Revision: https://reviews.llvm.org/D92146

Added: 
    

Modified: 
    llvm/include/llvm/TableGen/Record.h
    llvm/lib/Support/Timer.cpp
    llvm/utils/TableGen/DAGISelEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index 567908f93e55..a26367a6fcc6 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1829,7 +1829,7 @@ class RecordKeeper {
   /// Stop timing a phase.
   void stopTimer();
 
-  /// Start timing the overall backend. If the backend starts a timer,
+  /// Start timing the overall backend. If the backend itself starts a timer,
   /// then this timer is cleared.
   void startBackendTimer(StringRef Name);
 

diff  --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index c97538cb560a..a3b86cfa6811 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -53,6 +53,11 @@ namespace {
   InfoOutputFilename("info-output-file", cl::value_desc("filename"),
                      cl::desc("File to append -stats and -timer output to"),
                    cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
+
+  static cl::opt<bool>
+  SortTimers("sort-timers", cl::desc("In the report, sort the timers in each group "
+                                     "in wall clock time order"),
+             cl::init(true), cl::Hidden);
 }
 
 std::unique_ptr<raw_fd_ostream> llvm::CreateInfoOutputFile() {
@@ -301,8 +306,9 @@ void TimerGroup::addTimer(Timer &T) {
 }
 
 void TimerGroup::PrintQueuedTimers(raw_ostream &OS) {
-  // Sort the timers in descending order by amount of time taken.
-  llvm::sort(TimersToPrint);
+  // Perhaps sort the timers in descending order by amount of time taken.
+  if (SortTimers)
+    llvm::sort(TimersToPrint);
 
   TimeRecord Total;
   for (const PrintRecord &Record : TimersToPrint)

diff  --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp
index 85a62855c19b..1652281b5193 100644
--- a/llvm/utils/TableGen/DAGISelEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelEmitter.cpp
@@ -189,6 +189,7 @@ void DAGISelEmitter::run(raw_ostream &OS) {
 namespace llvm {
 
 void EmitDAGISel(RecordKeeper &RK, raw_ostream &OS) {
+  RK.startTimer("Parse patterns");
   DAGISelEmitter(RK).run(OS);
 }
 


        


More information about the llvm-commits mailing list