diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h index 01e41541bf044..f856ff4cbd34b 100644 --- a/llvm/include/llvm/TableGen/Record.h +++ b/llvm/include/llvm/TableGen/Record.h @@ -51,6 +51,7 @@ class RecordVal; class Resolver; class StringInit; class TypedInit; +class TGTimer; //===----------------------------------------------------------------------===// // Type Classes @@ -1785,11 +1786,13 @@ class Record { } RecordVal *getValue(const Init *Name) { - return const_cast(static_cast(this)->getValue(Name)); + return const_cast( + static_cast(this)->getValue(Name)); } RecordVal *getValue(StringRef Name) { - return const_cast(static_cast(this)->getValue(Name)); + return const_cast( + static_cast(this)->getValue(Name)); } void addTemplateArg(Init *Name) { @@ -2033,29 +2036,7 @@ class RecordKeeper { Init *getNewAnonymousName(); - /// Start phase timing; called if the --time-phases option is specified. - void startPhaseTiming() { - TimingGroup = new TimerGroup("TableGen", "TableGen Phase Timing"); - } - - /// Start timing a phase. Automatically stops any previous phase timer. - void startTimer(StringRef Name) const; - - /// Stop timing a phase. - void stopTimer(); - - /// Start timing the overall backend. If the backend itself starts a timer, - /// then this timer is cleared. - void startBackendTimer(StringRef Name); - - /// Stop timing the overall backend. - void stopBackendTimer(); - - /// Stop phase timing and print the report. - void stopPhaseTiming() { - if (TimingGroup) - delete TimingGroup; - } + TGTimer &getTimer() const { return *Timer; } //===--------------------------------------------------------------------===// // High-level helper methods, useful for tablegen backends. @@ -2089,16 +2070,9 @@ class RecordKeeper { mutable std::map> Cache; GlobalMap ExtraGlobals; - // TODO: Move timing related code out of RecordKeeper. - // These members are for the phase timing feature. We need a timer group, - // the last timer started, and a flag to say whether the last timer - // is the special "backend overall timer." - mutable TimerGroup *TimingGroup = nullptr; - mutable Timer *LastTimer = nullptr; - mutable bool BackendTimer = false; - /// The internal uniquer implementation of the RecordKeeper. std::unique_ptr Impl; + std::unique_ptr Timer; }; /// Sorting predicate to sort record pointers by name. diff --git a/llvm/include/llvm/TableGen/TGTimer.h b/llvm/include/llvm/TableGen/TGTimer.h new file mode 100644 index 0000000000000..31753f54028cb --- /dev/null +++ b/llvm/include/llvm/TableGen/TGTimer.h @@ -0,0 +1,59 @@ +//===- llvm/TableGen/TGTimer.h - Class for TableGen Timer -------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the TableGen timer class. It's a thin wrapper around timer +// support in llvm/Support/Timer.h. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TABLEGEN_TGTIMER_H +#define LLVM_TABLEGEN_TGTIMER_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Timer.h" +#include + +namespace llvm { + +// Timer related functionality f or TableGen backends. +class TGTimer { +private: + std::unique_ptr TimingGroup; + std::unique_ptr LastTimer; + bool BackendTimer = false; // Is last timer special backend overall timer? + +public: + TGTimer() = default; + ~TGTimer() = default; + + /// Start phase timing; called if the --time-phases option is specified. + void startPhaseTiming() { + TimingGroup = + std::make_unique("TableGen", "TableGen Phase Timing"); + } + + /// Start timing a phase. Automatically stops any previous phase timer. + void startTimer(StringRef Name); + + /// Stop timing a phase. + void stopTimer(); + + /// Start timing the overall backend. If the backend itself starts a timer, + /// then this timer is cleared. + void startBackendTimer(StringRef Name); + + /// Stop timing the overall backend. + void stopBackendTimer(); + + /// Stop phase timing and print the report. + void stopPhaseTiming() { TimingGroup.reset(); } +}; + +} // end namespace llvm + +#endif // LLVM_TABLEGEN_TGTIMER_H diff --git a/llvm/lib/TableGen/CMakeLists.txt b/llvm/lib/TableGen/CMakeLists.txt index c550840f147d7..84815c7736997 100644 --- a/llvm/lib/TableGen/CMakeLists.txt +++ b/llvm/lib/TableGen/CMakeLists.txt @@ -11,6 +11,7 @@ add_llvm_component_library(LLVMTableGen TableGenBackendSkeleton.cpp TGLexer.cpp TGParser.cpp + TGTimer.cpp ADDITIONAL_HEADER_DIRS ${LLVM_MAIN_INCLUDE_DIR}/llvm/TableGen diff --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp index a4c41223c0762..55a99cbfc58ac 100644 --- a/llvm/lib/TableGen/Main.cpp +++ b/llvm/lib/TableGen/Main.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TGTimer.h" #include "llvm/TableGen/TableGenBackend.h" #include #include @@ -98,13 +99,14 @@ static int createDependencyFile(const TGParser &Parser, const char *argv0) { int llvm::TableGenMain(const char *argv0, std::function MainFn) { RecordKeeper Records; + TGTimer &Timer = Records.getTimer(); if (TimePhases) - Records.startPhaseTiming(); + Timer.startPhaseTiming(); // Parse the input file. - Records.startTimer("Parse, build records"); + Timer.startTimer("Parse, build records"); ErrorOr> FileOrErr = MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true); if (std::error_code EC = FileOrErr.getError()) @@ -124,10 +126,10 @@ int llvm::TableGenMain(const char *argv0, if (Parser.ParseFile()) return 1; - Records.stopTimer(); + Timer.stopTimer(); // Write output to memory. - Records.startBackendTimer("Backend overall"); + Timer.startBackendTimer("Backend overall"); std::string OutString; raw_string_ostream Out(OutString); unsigned status = 0; @@ -135,7 +137,7 @@ int llvm::TableGenMain(const char *argv0, // case, attempt to apply the MainFn. if (TableGen::Emitter::ApplyCallback(Records, Out)) status = MainFn ? MainFn(Out, Records) : 1; - Records.stopBackendTimer(); + Timer.stopBackendTimer(); if (status) return 1; @@ -148,7 +150,7 @@ int llvm::TableGenMain(const char *argv0, return Ret; } - Records.startTimer("Write output"); + Timer.startTimer("Write output"); bool WriteFile = true; if (WriteIfChanged) { // Only updates the real output file if there are any differences. @@ -169,9 +171,9 @@ int llvm::TableGenMain(const char *argv0, if (ErrorsPrinted == 0) OutFile.keep(); } - - Records.stopTimer(); - Records.stopPhaseTiming(); + + Timer.stopTimer(); + Timer.stopPhaseTiming(); if (ErrorsPrinted > 0) return reportError(argv0, Twine(ErrorsPrinted) + " errors.\n"); diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index 9307987df6a87..447ecb7d74d24 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/SMLoc.h" #include "llvm/Support/raw_ostream.h" #include "llvm/TableGen/Error.h" +#include "llvm/TableGen/TGTimer.h" #include #include #include @@ -3218,7 +3219,9 @@ void Record::checkUnusedTemplateArgs() { } RecordKeeper::RecordKeeper() - : Impl(std::make_unique(*this)) {} + : Impl(std::make_unique(*this)), + Timer(std::make_unique()) {} + RecordKeeper::~RecordKeeper() = default; #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) @@ -3242,47 +3245,6 @@ Init *RecordKeeper::getNewAnonymousName() { return AnonymousNameInit::get(*this, getImpl().AnonCounter++); } -// These functions implement the phase timing facility. Starting a timer -// when one is already running stops the running one. - -void RecordKeeper::startTimer(StringRef Name) const { - if (TimingGroup) { - if (LastTimer && LastTimer->isRunning()) { - LastTimer->stopTimer(); - if (BackendTimer) { - LastTimer->clear(); - BackendTimer = false; - } - } - - LastTimer = new Timer("", Name, *TimingGroup); - LastTimer->startTimer(); - } -} - -void RecordKeeper::stopTimer() { - if (TimingGroup) { - assert(LastTimer && "No phase timer was started"); - LastTimer->stopTimer(); - } -} - -void RecordKeeper::startBackendTimer(StringRef Name) { - if (TimingGroup) { - startTimer(Name); - BackendTimer = true; - } -} - -void RecordKeeper::stopBackendTimer() { - if (TimingGroup) { - if (BackendTimer) { - stopTimer(); - BackendTimer = false; - } - } -} - ArrayRef RecordKeeper::getAllDerivedDefinitions(StringRef ClassName) const { // We cache the record vectors for single classes. Many backends request diff --git a/llvm/lib/TableGen/TGTimer.cpp b/llvm/lib/TableGen/TGTimer.cpp new file mode 100644 index 0000000000000..d95bd2e6be9da --- /dev/null +++ b/llvm/lib/TableGen/TGTimer.cpp @@ -0,0 +1,54 @@ +//===- TGTimer.cpp - TableGen Timer implementation --------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Implement the tablegen timer class. +// +//===----------------------------------------------------------------------===// + +#include "llvm/TableGen/TGTimer.h" +using namespace llvm; + +// These functions implement the phase timing facility. Starting a timer +// when one is already running stops the running one. +void TGTimer::startTimer(StringRef Name) { + if (!TimingGroup) + return; + if (LastTimer && LastTimer->isRunning()) { + LastTimer->stopTimer(); + if (BackendTimer) { + LastTimer->clear(); + BackendTimer = false; + } + } + + LastTimer = std::make_unique("", Name, *TimingGroup); + LastTimer->startTimer(); +} + +void TGTimer::stopTimer() { + if (!TimingGroup) + return; + + assert(LastTimer && "No phase timer was started"); + LastTimer->stopTimer(); +} + +void TGTimer::startBackendTimer(StringRef Name) { + if (!TimingGroup) + return; + + startTimer(Name); + BackendTimer = true; +} + +void TGTimer::stopBackendTimer() { + if (!TimingGroup || !BackendTimer) + return; + stopTimer(); + BackendTimer = false; +} diff --git a/llvm/utils/TableGen/CallingConvEmitter.cpp b/llvm/utils/TableGen/CallingConvEmitter.cpp index fefc407c354a5..c8f263e15d96b 100644 --- a/llvm/utils/TableGen/CallingConvEmitter.cpp +++ b/llvm/utils/TableGen/CallingConvEmitter.cpp @@ -14,6 +14,7 @@ #include "Common/CodeGenTarget.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TGTimer.h" #include "llvm/TableGen/TableGenBackend.h" #include #include @@ -51,7 +52,7 @@ void CallingConvEmitter::run(raw_ostream &O) { // Emit prototypes for all of the non-custom CC's so that they can forward ref // each other. - Records.startTimer("Emit prototypes"); + Records.getTimer().startTimer("Emit prototypes"); O << "#ifndef GET_CC_REGISTER_LISTS\n\n"; for (const Record *CC : CCs) { if (!CC->getValueAsBit("Custom")) { @@ -71,7 +72,7 @@ void CallingConvEmitter::run(raw_ostream &O) { } // Emit each non-custom calling convention description in full. - Records.startTimer("Emit full descriptions"); + Records.getTimer().startTimer("Emit full descriptions"); for (const Record *CC : CCs) { if (!CC->getValueAsBit("Custom")) { EmitCallingConv(CC, O); diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp index 2cceb22afdb99..d3b653b0fba27 100644 --- a/llvm/utils/TableGen/DAGISelEmitter.cpp +++ b/llvm/utils/TableGen/DAGISelEmitter.cpp @@ -16,6 +16,7 @@ #include "Common/DAGISelMatcher.h" #include "llvm/Support/Debug.h" #include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TGTimer.h" #include "llvm/TableGen/TableGenBackend.h" using namespace llvm; @@ -132,7 +133,8 @@ struct PatternSortingPredicate { } // End anonymous namespace void DAGISelEmitter::run(raw_ostream &OS) { - Records.startTimer("Parse patterns"); + TGTimer &Timer = Records.getTimer(); + Timer.startTimer("Parse patterns"); emitSourceFileHeader("DAG Instruction Selector for the " + CGP.getTargetInfo().getName().str() + " target", OS); @@ -163,7 +165,7 @@ void DAGISelEmitter::run(raw_ostream &OS) { }); // Add all the patterns to a temporary list so we can sort them. - Records.startTimer("Sort patterns"); + Timer.startTimer("Sort patterns"); std::vector Patterns; for (const PatternToMatch &PTM : CGP.ptms()) Patterns.push_back(&PTM); @@ -173,7 +175,7 @@ void DAGISelEmitter::run(raw_ostream &OS) { llvm::stable_sort(Patterns, PatternSortingPredicate(CGP)); // Convert each variant of each pattern into a Matcher. - Records.startTimer("Convert to matchers"); + Timer.startTimer("Convert to matchers"); SmallVector PatternMatchers; for (const PatternToMatch *PTM : Patterns) { for (unsigned Variant = 0;; ++Variant) { @@ -187,12 +189,12 @@ void DAGISelEmitter::run(raw_ostream &OS) { std::unique_ptr TheMatcher = std::make_unique(std::move(PatternMatchers)); - Records.startTimer("Optimize matchers"); + Timer.startTimer("Optimize matchers"); OptimizeMatcher(TheMatcher, CGP); // Matcher->dump(); - Records.startTimer("Emit matcher table"); + Timer.startTimer("Emit matcher table"); EmitMatcherTable(TheMatcher.get(), CGP, OS); } diff --git a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp index 78496fbe1b860..2524a443f3454 100644 --- a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp @@ -53,6 +53,7 @@ #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/StringMatcher.h" +#include "llvm/TableGen/TGTimer.h" #include "llvm/TableGen/TableGenBackend.h" #include @@ -2718,7 +2719,8 @@ void GICombinerEmitter::run(raw_ostream &OS) { InstructionOpcodeMatcher::initOpcodeValuesMap(Target); LLTOperandMatcher::initTypeIDValuesMap(); - Records.startTimer("Gather rules"); + TGTimer &Timer = Records.getTimer(); + Timer.startTimer("Gather rules"); std::vector Rules; gatherRules(Rules, Combiner->getValueAsListOfDefs("Rules")); if (ErrorsPrinted) @@ -2727,7 +2729,7 @@ void GICombinerEmitter::run(raw_ostream &OS) { if (StopAfterParse) return; - Records.startTimer("Creating Match Table"); + Timer.startTimer("Creating Match Table"); unsigned MaxTemporaries = 0; for (const auto &Rule : Rules) MaxTemporaries = std::max(MaxTemporaries, Rule.countRendererFns()); @@ -2744,7 +2746,7 @@ void GICombinerEmitter::run(raw_ostream &OS) { const MatchTable Table = buildMatchTable(Rules); - Records.startTimer("Emit combiner"); + Timer.startTimer("Emit combiner"); emitSourceFileHeader(getClassName().str() + " Combiner Match Table", OS); diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp index 5653434ddd682..a7039ff7e31e9 100644 --- a/llvm/utils/TableGen/InstrInfoEmitter.cpp +++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TGTimer.h" #include "llvm/TableGen/TableGenBackend.h" #include #include @@ -934,14 +935,15 @@ void InstrInfoEmitter::run(raw_ostream &OS) { const Record *InstrInfo = Target.getInstructionSet(); // Collect all of the operand info records. - Records.startTimer("Collect operand info"); + TGTimer &Timer = Records.getTimer(); + Timer.startTimer("Collect operand info"); OperandInfoListTy OperandInfoList; OperandInfoMapTy OperandInfoMap; unsigned OperandInfoSize = CollectOperandInfo(OperandInfoList, OperandInfoMap); // Collect all of the instruction's implicit uses and defs. - Records.startTimer("Collect uses/defs"); + Timer.startTimer("Collect uses/defs"); std::map, unsigned> EmittedLists; std::vector> ImplicitLists; unsigned ImplicitListSize = 0; @@ -979,7 +981,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) { OS << "namespace llvm {\n\n"; // Emit all of the MCInstrDesc records in reverse ENUM ordering. - Records.startTimer("Emit InstrDesc records"); + Timer.startTimer("Emit InstrDesc records"); OS << "static_assert(sizeof(MCOperandInfo) % sizeof(MCPhysReg) == 0);\n"; OS << "static constexpr unsigned " << TargetName << "ImpOpBase = sizeof " << TargetName << "InstrTable::OperandInfo / (sizeof(MCPhysReg));\n\n"; @@ -998,13 +1000,13 @@ void InstrInfoEmitter::run(raw_ostream &OS) { OS << " }, {\n"; // Emit all of the operand info records. - Records.startTimer("Emit operand info"); + Timer.startTimer("Emit operand info"); EmitOperandInfo(OS, OperandInfoList); OS << " }, {\n"; // Emit all of the instruction's implicit uses and defs. - Records.startTimer("Emit uses/defs"); + Timer.startTimer("Emit uses/defs"); for (auto &List : ImplicitLists) { OS << " /* " << EmittedLists[List] << " */"; for (auto &Reg : List) @@ -1015,7 +1017,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) { OS << " }\n};\n\n"; // Emit the array of instruction names. - Records.startTimer("Emit instruction names"); + Timer.startTimer("Emit instruction names"); InstrNames.layout(); InstrNames.emitStringLiteralDef(OS, Twine("extern const char ") + TargetName + "InstrNameData[]"); @@ -1076,7 +1078,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) { } // MCInstrInfo initialization routine. - Records.startTimer("Emit initialization routine"); + Timer.startTimer("Emit initialization routine"); OS << "static inline void Init" << TargetName << "MCInstrInfo(MCInstrInfo *II) {\n"; OS << " II->InitMCInstrInfo(" << TargetName << "Descs.Insts, " << TargetName @@ -1156,22 +1158,22 @@ void InstrInfoEmitter::run(raw_ostream &OS) { OS << "#endif // GET_INSTRINFO_CTOR_DTOR\n\n"; - Records.startTimer("Emit operand name mappings"); + Timer.startTimer("Emit operand name mappings"); emitOperandNameMappings(OS, Target, NumberedInstructions); - Records.startTimer("Emit operand type mappings"); + Timer.startTimer("Emit operand type mappings"); emitOperandTypeMappings(OS, Target, NumberedInstructions); - Records.startTimer("Emit logical operand size mappings"); + Timer.startTimer("Emit logical operand size mappings"); emitLogicalOperandSizeMappings(OS, TargetName, NumberedInstructions); - Records.startTimer("Emit logical operand type mappings"); + Timer.startTimer("Emit logical operand type mappings"); emitLogicalOperandTypeMappings(OS, TargetName, NumberedInstructions); - Records.startTimer("Emit helper methods"); + Timer.startTimer("Emit helper methods"); emitMCIIHelperMethods(OS, TargetName); - Records.startTimer("Emit verifier methods"); + Timer.startTimer("Emit verifier methods"); emitFeatureVerifier(OS, Target); } @@ -1357,11 +1359,12 @@ void InstrInfoEmitter::emitEnums(raw_ostream &OS) { OS << "#endif // GET_INSTRINFO_SCHED_ENUM\n\n"; } -static void EmitInstrInfo(const RecordKeeper &RK, raw_ostream &OS) { - RK.startTimer("Analyze DAG patterns"); - InstrInfoEmitter(RK).run(OS); - RK.startTimer("Emit map table"); - EmitMapTable(RK, OS); +static void EmitInstrInfo(const RecordKeeper &Records, raw_ostream &OS) { + TGTimer &Timer = Records.getTimer(); + Timer.startTimer("Analyze DAG patterns"); + InstrInfoEmitter(Records).run(OS); + Timer.startTimer("Emit map table"); + EmitMapTable(Records, OS); } static TableGen::Emitter::Opt X("gen-instr-info", EmitInstrInfo, diff --git a/llvm/utils/TableGen/PseudoLoweringEmitter.cpp b/llvm/utils/TableGen/PseudoLoweringEmitter.cpp index 9e09bdae76fd4..d2d2bd91445a1 100644 --- a/llvm/utils/TableGen/PseudoLoweringEmitter.cpp +++ b/llvm/utils/TableGen/PseudoLoweringEmitter.cpp @@ -15,6 +15,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TGTimer.h" #include "llvm/TableGen/TableGenBackend.h" #include using namespace llvm; @@ -298,13 +299,14 @@ void PseudoLoweringEmitter::run(raw_ostream &OS) { StringRef Classes[] = {"PseudoInstExpansion", "Instruction"}; // Process the pseudo expansion definitions, validating them as we do so. - Records.startTimer("Process definitions"); + TGTimer &Timer = Records.getTimer(); + Timer.startTimer("Process definitions"); for (const Record *Inst : Records.getAllDerivedDefinitions(Classes)) evaluateExpansion(Inst); // Generate expansion code to lower the pseudo to an MCInst of the real // instruction. - Records.startTimer("Emit expansion code"); + Timer.startTimer("Emit expansion code"); emitLoweringEmitter(OS); } diff --git a/llvm/utils/TableGen/RegisterBankEmitter.cpp b/llvm/utils/TableGen/RegisterBankEmitter.cpp index 460f286543b17..a2fcf55e85132 100644 --- a/llvm/utils/TableGen/RegisterBankEmitter.cpp +++ b/llvm/utils/TableGen/RegisterBankEmitter.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/MathExtras.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TGTimer.h" #include "llvm/TableGen/TableGenBackend.h" #define DEBUG_TYPE "register-bank-emitter" @@ -385,7 +386,8 @@ void RegisterBankEmitter::run(raw_ostream &OS) { const CodeGenRegBank &RegisterClassHierarchy = Target.getRegBank(); const CodeGenHwModes &CGH = Target.getHwModes(); - Records.startTimer("Analyze records"); + TGTimer &Timer = Records.getTimer(); + Timer.startTimer("Analyze records"); std::vector Banks; for (const auto &V : Records.getAllDerivedDefinitions("RegisterBank")) { SmallPtrSet VisitedRCs; @@ -407,7 +409,7 @@ void RegisterBankEmitter::run(raw_ostream &OS) { } // Warn about ambiguous MIR caused by register bank/class name clashes. - Records.startTimer("Warn ambiguous"); + Timer.startTimer("Warn ambiguous"); for (const auto &Class : RegisterClassHierarchy.getRegClasses()) { for (const auto &Bank : Banks) { if (Bank.getName().lower() == StringRef(Class.getName()).lower()) { @@ -420,7 +422,7 @@ void RegisterBankEmitter::run(raw_ostream &OS) { } } - Records.startTimer("Emit output"); + Timer.startTimer("Emit output"); emitSourceFileHeader("Register Bank Source Fragments", OS); OS << "#ifdef GET_REGBANK_DECLARATIONS\n" << "#undef GET_REGBANK_DECLARATIONS\n"; diff --git a/llvm/utils/TableGen/RegisterInfoEmitter.cpp b/llvm/utils/TableGen/RegisterInfoEmitter.cpp index 7d81a83ef2b0a..371ee75d1b49e 100644 --- a/llvm/utils/TableGen/RegisterInfoEmitter.cpp +++ b/llvm/utils/TableGen/RegisterInfoEmitter.cpp @@ -33,6 +33,7 @@ #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/SetTheory.h" +#include "llvm/TableGen/TGTimer.h" #include "llvm/TableGen/TableGenBackend.h" #include #include @@ -1802,16 +1803,17 @@ void RegisterInfoEmitter::runTargetDesc(raw_ostream &OS) { } void RegisterInfoEmitter::run(raw_ostream &OS) { - Records.startTimer("Print enums"); + TGTimer &Timer = Records.getTimer(); + Timer.startTimer("Print enums"); runEnums(OS); - Records.startTimer("Print MC registers"); + Timer.startTimer("Print MC registers"); runMCDesc(OS); - Records.startTimer("Print header fragment"); + Timer.startTimer("Print header fragment"); runTargetHeader(OS); - Records.startTimer("Print target registers"); + Timer.startTimer("Print target registers"); runTargetDesc(OS); if (RegisterInfoDebug) diff --git a/llvm/utils/gn/secondary/llvm/lib/TableGen/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/TableGen/BUILD.gn index bd2402bf8d381..d90df7bc0e57a 100644 --- a/llvm/utils/gn/secondary/llvm/lib/TableGen/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/TableGen/BUILD.gn @@ -12,6 +12,7 @@ static_library("TableGen") { "StringMatcher.cpp", "TGLexer.cpp", "TGParser.cpp", + "TGTimer.cpp", "TableGenBackend.cpp", "TableGenBackendSkeleton.cpp", ]