diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/llvm12/lib/Support/Signposts.cpp | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Support/Signposts.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/Support/Signposts.cpp | 202 |
1 files changed, 101 insertions, 101 deletions
diff --git a/contrib/libs/llvm12/lib/Support/Signposts.cpp b/contrib/libs/llvm12/lib/Support/Signposts.cpp index eebaeca202..8de6e0cc04 100644 --- a/contrib/libs/llvm12/lib/Support/Signposts.cpp +++ b/contrib/libs/llvm12/lib/Support/Signposts.cpp @@ -1,122 +1,122 @@ -//===-- Signposts.cpp - Interval debug annotations ------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/Signposts.h" -#include "llvm/Support/Timer.h" - -#include "llvm/Config/config.h" -#if LLVM_SUPPORT_XCODE_SIGNPOSTS -#include "llvm/ADT/DenseMap.h" +//===-- Signposts.cpp - Interval debug annotations ------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/Signposts.h" +#include "llvm/Support/Timer.h" + +#include "llvm/Config/config.h" +#if LLVM_SUPPORT_XCODE_SIGNPOSTS +#include "llvm/ADT/DenseMap.h" #include "llvm/Support/Mutex.h" -#error #include <os/signpost.h> -#endif // if LLVM_SUPPORT_XCODE_SIGNPOSTS - -using namespace llvm; - -#if LLVM_SUPPORT_XCODE_SIGNPOSTS -namespace { -os_log_t *LogCreator() { - os_log_t *X = new os_log_t; - *X = os_log_create("org.llvm.signposts", OS_LOG_CATEGORY_POINTS_OF_INTEREST); - return X; -} -void LogDeleter(os_log_t *X) { - os_release(*X); - delete X; -} -} // end anonymous namespace - -namespace llvm { -class SignpostEmitterImpl { +#error #include <os/signpost.h> +#endif // if LLVM_SUPPORT_XCODE_SIGNPOSTS + +using namespace llvm; + +#if LLVM_SUPPORT_XCODE_SIGNPOSTS +namespace { +os_log_t *LogCreator() { + os_log_t *X = new os_log_t; + *X = os_log_create("org.llvm.signposts", OS_LOG_CATEGORY_POINTS_OF_INTEREST); + return X; +} +void LogDeleter(os_log_t *X) { + os_release(*X); + delete X; +} +} // end anonymous namespace + +namespace llvm { +class SignpostEmitterImpl { using LogPtrTy = std::unique_ptr<os_log_t, std::function<void(os_log_t *)>>; - using LogTy = LogPtrTy::element_type; - - LogPtrTy SignpostLog; + using LogTy = LogPtrTy::element_type; + + LogPtrTy SignpostLog; DenseMap<const void *, os_signpost_id_t> Signposts; sys::SmartMutex<true> Mutex; - - LogTy &getLogger() const { return *SignpostLog; } + + LogTy &getLogger() const { return *SignpostLog; } os_signpost_id_t getSignpostForObject(const void *O) { sys::SmartScopedLock<true> Lock(Mutex); const auto &I = Signposts.find(O); - if (I != Signposts.end()) - return I->second; - - const auto &Inserted = Signposts.insert( + if (I != Signposts.end()) + return I->second; + + const auto &Inserted = Signposts.insert( std::make_pair(O, os_signpost_id_make_with_pointer(getLogger(), O))); - return Inserted.first->second; - } - -public: - SignpostEmitterImpl() : SignpostLog(LogCreator(), LogDeleter), Signposts() {} - - bool isEnabled() const { return os_signpost_enabled(*SignpostLog); } - + return Inserted.first->second; + } + +public: + SignpostEmitterImpl() : SignpostLog(LogCreator(), LogDeleter), Signposts() {} + + bool isEnabled() const { return os_signpost_enabled(*SignpostLog); } + void startInterval(const void *O, llvm::StringRef Name) { - if (isEnabled()) { + if (isEnabled()) { // Both strings used here are required to be constant literal strings. os_signpost_interval_begin(getLogger(), getSignpostForObject(O), "LLVM Timers", "Begin %s", Name.data()); - } - } - + } + } + void endInterval(const void *O, llvm::StringRef Name) { - if (isEnabled()) { + if (isEnabled()) { // Both strings used here are required to be constant literal strings. os_signpost_interval_end(getLogger(), getSignpostForObject(O), "LLVM Timers", "End %s", Name.data()); - } - } -}; -} // end namespace llvm -#endif // if LLVM_SUPPORT_XCODE_SIGNPOSTS - -#if LLVM_SUPPORT_XCODE_SIGNPOSTS -#define HAVE_ANY_SIGNPOST_IMPL 1 -#else -#define HAVE_ANY_SIGNPOST_IMPL 0 -#endif - -SignpostEmitter::SignpostEmitter() { -#if HAVE_ANY_SIGNPOST_IMPL - Impl = new SignpostEmitterImpl(); + } + } +}; +} // end namespace llvm +#endif // if LLVM_SUPPORT_XCODE_SIGNPOSTS + +#if LLVM_SUPPORT_XCODE_SIGNPOSTS +#define HAVE_ANY_SIGNPOST_IMPL 1 +#else +#define HAVE_ANY_SIGNPOST_IMPL 0 +#endif + +SignpostEmitter::SignpostEmitter() { +#if HAVE_ANY_SIGNPOST_IMPL + Impl = new SignpostEmitterImpl(); #else // if HAVE_ANY_SIGNPOST_IMPL - Impl = nullptr; -#endif // if !HAVE_ANY_SIGNPOST_IMPL -} - -SignpostEmitter::~SignpostEmitter() { -#if HAVE_ANY_SIGNPOST_IMPL - delete Impl; -#endif // if HAVE_ANY_SIGNPOST_IMPL -} - -bool SignpostEmitter::isEnabled() const { -#if HAVE_ANY_SIGNPOST_IMPL - return Impl->isEnabled(); -#else - return false; -#endif // if !HAVE_ANY_SIGNPOST_IMPL -} - + Impl = nullptr; +#endif // if !HAVE_ANY_SIGNPOST_IMPL +} + +SignpostEmitter::~SignpostEmitter() { +#if HAVE_ANY_SIGNPOST_IMPL + delete Impl; +#endif // if HAVE_ANY_SIGNPOST_IMPL +} + +bool SignpostEmitter::isEnabled() const { +#if HAVE_ANY_SIGNPOST_IMPL + return Impl->isEnabled(); +#else + return false; +#endif // if !HAVE_ANY_SIGNPOST_IMPL +} + void SignpostEmitter::startInterval(const void *O, StringRef Name) { -#if HAVE_ANY_SIGNPOST_IMPL - if (Impl == nullptr) - return; +#if HAVE_ANY_SIGNPOST_IMPL + if (Impl == nullptr) + return; return Impl->startInterval(O, Name); -#endif // if !HAVE_ANY_SIGNPOST_IMPL -} - +#endif // if !HAVE_ANY_SIGNPOST_IMPL +} + void SignpostEmitter::endInterval(const void *O, StringRef Name) { -#if HAVE_ANY_SIGNPOST_IMPL - if (Impl == nullptr) - return; +#if HAVE_ANY_SIGNPOST_IMPL + if (Impl == nullptr) + return; Impl->endInterval(O, Name); -#endif // if !HAVE_ANY_SIGNPOST_IMPL -} +#endif // if !HAVE_ANY_SIGNPOST_IMPL +} |