//===- DebugCounter.cpp - Debug Counter Facilities ------------------------===// // // 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 // //===----------------------------------------------------------------------===// #include "mlir/Debug/Counter.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" usingnamespacemlir; usingnamespacemlir::tracing; //===----------------------------------------------------------------------===// // DebugCounter CommandLine Options //===----------------------------------------------------------------------===// namespace { /// This struct contains command line options that can be used to initialize /// various bits of a DebugCounter. This uses a struct wrapper to avoid the need /// for global command line options. struct DebugCounterOptions { … }; } // namespace static llvm::ManagedStatic<DebugCounterOptions> clOptions; //===----------------------------------------------------------------------===// // DebugCounter //===----------------------------------------------------------------------===// DebugCounter::DebugCounter() { … } DebugCounter::~DebugCounter() { … } /// Add a counter for the given debug action tag. `countToSkip` is the number /// of counter executions to skip before enabling execution of the action. /// `countToStopAfter` is the number of executions of the counter to allow /// before preventing the action from executing any more. void DebugCounter::addCounter(StringRef actionTag, int64_t countToSkip, int64_t countToStopAfter) { … } void DebugCounter::operator()(llvm::function_ref<void()> transform, const Action &action) { … } bool DebugCounter::shouldExecute(StringRef tag) { … } void DebugCounter::print(raw_ostream &os) const { … } /// Register a set of useful command-line options that can be used to configure /// various flags within the DebugCounter. These flags are used when /// constructing a DebugCounter for initialization. void DebugCounter::registerCLOptions() { … } bool DebugCounter::isActivated() { … } // This is called by the command line parser when it sees a value for the // debug-counter option defined above. void DebugCounter::applyCLOptions() { … }