Path: blob/main/contrib/llvm-project/llvm/lib/TableGen/TGTimer.cpp
213765 views
//===- TGTimer.cpp - TableGen Timer implementation --------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// Implement the tablegen timer class.9//10//===----------------------------------------------------------------------===//1112#include "llvm/TableGen/TGTimer.h"13using namespace llvm;1415// These functions implement the phase timing facility. Starting a timer16// when one is already running stops the running one.17void TGTimer::startTimer(StringRef Name) {18if (!TimingGroup)19return;20if (LastTimer && LastTimer->isRunning()) {21LastTimer->stopTimer();22if (BackendTimer) {23LastTimer->clear();24BackendTimer = false;25}26}2728LastTimer = std::make_unique<Timer>("", Name, *TimingGroup);29LastTimer->startTimer();30}3132void TGTimer::stopTimer() {33if (!TimingGroup)34return;3536assert(LastTimer && "No phase timer was started");37LastTimer->stopTimer();38}3940void TGTimer::startBackendTimer(StringRef Name) {41if (!TimingGroup)42return;4344startTimer(Name);45BackendTimer = true;46}4748void TGTimer::stopBackendTimer() {49if (!TimingGroup || !BackendTimer)50return;51stopTimer();52BackendTimer = false;53}545556