//===- PassStatistics.cpp -------------------------------------------------===// // // 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 "PassDetail.h" #include "mlir/Pass/PassManager.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Format.h" usingnamespacemlir; usingnamespacemlir::detail; constexpr StringLiteral kPassStatsDescription = …; namespace { /// Information pertaining to a specific statistic. struct Statistic { … }; } // namespace /// Utility to print a pass entry in the statistics output. static void printPassEntry(raw_ostream &os, unsigned indent, StringRef pass, MutableArrayRef<Statistic> stats = std::nullopt) { … } /// Print the statistics results in a list form, where each pass is sorted by /// name. static void printResultsAsList(raw_ostream &os, OpPassManager &pm) { … } /// Print the results in pipeline mode that mirrors the internal pass manager /// structure. static void printResultsAsPipeline(raw_ostream &os, OpPassManager &pm) { … } static void printStatistics(OpPassManager &pm, PassDisplayMode displayMode) { … } //===----------------------------------------------------------------------===// // PassStatistics //===----------------------------------------------------------------------===// Pass::Statistic::Statistic(Pass *owner, const char *name, const char *description) : … { … } auto Pass::Statistic::operator=(unsigned value) -> Statistic & { … } //===----------------------------------------------------------------------===// // PassManager //===----------------------------------------------------------------------===// /// Merge the pass statistics of this class into 'other'. void OpPassManager::mergeStatisticsInto(OpPassManager &other) { … } /// Prepare the statistics of passes within the given pass manager for /// consumption(e.g. dumping). static void prepareStatistics(OpPassManager &pm) { … } /// Dump the statistics of the passes within this pass manager. void PassManager::dumpStatistics() { … } /// Dump the statistics for each pass after running. void PassManager::enableStatistics(PassDisplayMode displayMode) { … }