[llvm] 254e289 - Revert "[ADT] Remove StatisticBase and make NoopStatistic empty"
Lei Zhang via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 26 15:31:23 PDT 2021
Author: Lei Zhang
Date: 2021-04-26T18:31:04-04:00
New Revision: 254e289d45337ec1da930ef93b4b1dd92f791153
URL: https://github.com/llvm/llvm-project/commit/254e289d45337ec1da930ef93b4b1dd92f791153
DIFF: https://github.com/llvm/llvm-project/commit/254e289d45337ec1da930ef93b4b1dd92f791153.diff
LOG: 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
Added:
Modified:
llvm/include/llvm/ADT/Statistic.h
llvm/lib/Transforms/Scalar/LoopFuse.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/Statistic.h b/llvm/include/llvm/ADT/Statistic.h
index de7dabc382c37..aa338ccff19a6 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<unsigned> Value;
- std::atomic<bool> 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<unsigned> Value;
+ std::atomic<bool> 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 @@ class TrackingStatistic {
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 ca19913e37ee1..63f02d0269160 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -372,13 +372,11 @@ struct FusionCandidate {
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 @@ struct LoopFuser {
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 @@ struct LoopFuser {
<< "]: " << 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.
More information about the llvm-commits
mailing list