From 254e289d45337ec1da930ef93b4b1dd92f791153 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 26 Apr 2021 18:27:41 -0400 Subject: [PATCH] Revert "[ADT] Remove StatisticBase and make NoopStatistic empty" This reverts commit b5403117814a7c39b944839e10492493f2ceb4ac because it breaks MLIR build: https://buildkite.com/mlir/mlir-core/builds/13299#ad0f8901-dfa4-43cf-81b8-7940e2c6c15b --- llvm/include/llvm/ADT/Statistic.h | 30 +++++++++++++++++------------- llvm/lib/Transforms/Scalar/LoopFuse.cpp | 4 ---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/llvm/include/llvm/ADT/Statistic.h b/llvm/include/llvm/ADT/Statistic.h index de7dabc..aa338cc 100644 --- a/llvm/include/llvm/ADT/Statistic.h +++ b/llvm/include/llvm/ADT/Statistic.h @@ -46,22 +46,27 @@ class raw_ostream; class raw_fd_ostream; class StringRef; -class TrackingStatistic { +class StatisticBase { public: - const char *const DebugType; - const char *const Name; - const char *const Desc; + const char *DebugType; + const char *Name; + const char *Desc; - std::atomic Value; - std::atomic Initialized; - - TrackingStatistic(const char *DebugType, const char *Name, const char *Desc) - : DebugType(DebugType), Name(Name), Desc(Desc), Value(0), - Initialized(false) {} + StatisticBase(const char *DebugType, const char *Name, const char *Desc) + : DebugType(DebugType), Name(Name), Desc(Desc) {} const char *getDebugType() const { return DebugType; } const char *getName() const { return Name; } const char *getDesc() const { return Desc; } +}; + +class TrackingStatistic : public StatisticBase { +public: + std::atomic Value; + std::atomic Initialized; + + TrackingStatistic(const char *DebugType, const char *Name, const char *Desc) + : StatisticBase(DebugType, Name, Desc), Value(0), Initialized(false) {} unsigned getValue() const { return Value.load(std::memory_order_relaxed); } @@ -127,10 +132,9 @@ protected: void RegisterStatistic(); }; -class NoopStatistic { +class NoopStatistic : public StatisticBase { public: - NoopStatistic(const char * /*DebugType*/, const char * /*Name*/, - const char * /*Desc*/) {} + using StatisticBase::StatisticBase; unsigned getValue() const { return 0; } diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp index ca19913..63f02d0 100644 --- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp +++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp @@ -372,13 +372,11 @@ private: bool reportInvalidCandidate(llvm::Statistic &Stat) const { using namespace ore; assert(L && Preheader && "Fusion candidate not initialized properly!"); -#if LLVM_ENABLE_STATS ++Stat; ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, Stat.getName(), L->getStartLoc(), Preheader) << "[" << Preheader->getParent()->getName() << "]: " << "Loop is not a candidate for fusion: " << Stat.getDesc()); -#endif return false; } }; @@ -1535,7 +1533,6 @@ private: assert(FC0.Preheader && FC1.Preheader && "Expecting valid fusion candidates"); using namespace ore; -#if LLVM_ENABLE_STATS ++Stat; ORE.emit(RemarkKind(DEBUG_TYPE, Stat.getName(), FC0.L->getStartLoc(), FC0.Preheader) @@ -1543,7 +1540,6 @@ private: << "]: " << NV("Cand1", StringRef(FC0.Preheader->getName())) << " and " << NV("Cand2", StringRef(FC1.Preheader->getName())) << ": " << Stat.getDesc()); -#endif } /// Fuse two guarded fusion candidates, creating a new fused loop. -- 2.7.4