Index: llvm/include/llvm/Support/Timer.h =================================================================== --- llvm/include/llvm/Support/Timer.h +++ llvm/include/llvm/Support/Timer.h @@ -187,6 +187,7 @@ std::string Description; Timer *FirstTimer = nullptr; ///< First timer in the group. std::vector TimersToPrint; + bool SortByWallTime = true; ///< Sort by wall time if true; otherwise no sort. TimerGroup **Prev; ///< Pointer to Next field of previous timergroup in list. TimerGroup *Next; ///< Pointer to next timergroup in list. @@ -206,6 +207,10 @@ Description.assign(NewDescription.begin(), NewDescription.end()); } + /// If true, sort report by wall time. If false, keep report in the + /// order timers were started. + void sortByWallTime(bool Sort) { SortByWallTime = Sort; } + /// Print any started timers in this group, optionally resetting timers after /// printing them. void print(raw_ostream &OS, bool ResetAfterPrint = false); Index: llvm/include/llvm/TableGen/Record.h =================================================================== --- llvm/include/llvm/TableGen/Record.h +++ llvm/include/llvm/TableGen/Record.h @@ -1821,6 +1821,7 @@ /// Start phase timing; called if the --time-phases option is specified. void startPhaseTiming() { TimingGroup = new TimerGroup("TableGen", "TableGen Phase Timing"); + TimingGroup->sortByWallTime(false); } /// Start timing a phase. Automatically stops any previous phase timer. Index: llvm/lib/Support/Timer.cpp =================================================================== --- llvm/lib/Support/Timer.cpp +++ llvm/lib/Support/Timer.cpp @@ -302,7 +302,8 @@ void TimerGroup::PrintQueuedTimers(raw_ostream &OS) { // Sort the timers in descending order by amount of time taken. - llvm::sort(TimersToPrint); + if (SortByWallTime) + llvm::sort(TimersToPrint); TimeRecord Total; for (const PrintRecord &Record : TimersToPrint) Index: llvm/utils/TableGen/DAGISelEmitter.cpp =================================================================== --- llvm/utils/TableGen/DAGISelEmitter.cpp +++ llvm/utils/TableGen/DAGISelEmitter.cpp @@ -189,6 +189,7 @@ namespace llvm { void EmitDAGISel(RecordKeeper &RK, raw_ostream &OS) { + RK.startTimer("Parse patterns"); DAGISelEmitter(RK).run(OS); }