diff options
author | vitalyisaev <vitalyisaev@yandex-team.com> | 2023-06-29 10:00:50 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@yandex-team.com> | 2023-06-29 10:00:50 +0300 |
commit | 6ffe9e53658409f212834330e13564e4952558f6 (patch) | |
tree | 85b1e00183517648b228aafa7c8fb07f5276f419 /contrib/libs/llvm14/include/llvm/IR/PassTimingInfo.h | |
parent | 726057070f9c5a91fc10fde0d5024913d10f1ab9 (diff) | |
download | ydb-6ffe9e53658409f212834330e13564e4952558f6.tar.gz |
YQ Connector: support managed ClickHouse
Со стороны dqrun можно обратиться к инстансу коннектора, который работает на streaming стенде, и извлечь данные из облачного CH.
Diffstat (limited to 'contrib/libs/llvm14/include/llvm/IR/PassTimingInfo.h')
-rw-r--r-- | contrib/libs/llvm14/include/llvm/IR/PassTimingInfo.h | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/contrib/libs/llvm14/include/llvm/IR/PassTimingInfo.h b/contrib/libs/llvm14/include/llvm/IR/PassTimingInfo.h new file mode 100644 index 0000000000..a789835387 --- /dev/null +++ b/contrib/libs/llvm14/include/llvm/IR/PassTimingInfo.h @@ -0,0 +1,115 @@ +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PassTimingInfo.h - pass execution timing -----------------*- 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 +// +//===----------------------------------------------------------------------===// +/// \file +/// +/// This header defines classes/functions to handle pass execution timing +/// information with interfaces for both pass managers. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_IR_PASSTIMINGINFO_H +#define LLVM_IR_PASSTIMINGINFO_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Timer.h" +#include <memory> +#include <utility> + +namespace llvm { + +class Pass; +class PassInstrumentationCallbacks; +class raw_ostream; + +/// If -time-passes has been specified, report the timings immediately and then +/// reset the timers to zero. By default it uses the stream created by +/// CreateInfoOutputFile(). +void reportAndResetTimings(raw_ostream *OutStream = nullptr); + +/// Request the timer for this legacy-pass-manager's pass instance. +Timer *getPassTimer(Pass *); + +/// This class implements -time-passes functionality for new pass manager. +/// It provides the pass-instrumentation callbacks that measure the pass +/// execution time. They collect timing info into individual timers as +/// passes are being run. At the end of its life-time it prints the resulting +/// timing report. +class TimePassesHandler { + /// Value of this type is capable of uniquely identifying pass invocations. + /// It is a pair of string Pass-Identifier (which for now is common + /// to all the instance of a given pass) + sequential invocation counter. + using PassInvocationID = std::pair<StringRef, unsigned>; + + /// A group of all pass-timing timers. + TimerGroup TG; + + using TimerVector = llvm::SmallVector<std::unique_ptr<Timer>, 4>; + /// Map of timers for pass invocations + StringMap<TimerVector> TimingData; + + /// Stack of currently active timers. + SmallVector<Timer *, 8> TimerStack; + + /// Custom output stream to print timing information into. + /// By default (== nullptr) we emit time report into the stream created by + /// CreateInfoOutputFile(). + raw_ostream *OutStream = nullptr; + + bool Enabled; + bool PerRun; + +public: + TimePassesHandler(); + TimePassesHandler(bool Enabled, bool PerRun = false); + + /// Destructor handles the print action if it has not been handled before. + ~TimePassesHandler() { print(); } + + /// Prints out timing information and then resets the timers. + void print(); + + // We intend this to be unique per-compilation, thus no copies. + TimePassesHandler(const TimePassesHandler &) = delete; + void operator=(const TimePassesHandler &) = delete; + + void registerCallbacks(PassInstrumentationCallbacks &PIC); + + /// Set a custom output stream for subsequent reporting. + void setOutStream(raw_ostream &OutStream); + +private: + /// Dumps information for running/triggered timers, useful for debugging + LLVM_DUMP_METHOD void dump() const; + + /// Returns the new timer for each new run of the pass. + Timer &getPassTimer(StringRef PassID); + + void startTimer(StringRef PassID); + void stopTimer(StringRef PassID); + + // Implementation of pass instrumentation callbacks. + void runBeforePass(StringRef PassID); + void runAfterPass(StringRef PassID); +}; + +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif |