class raw_fd_ostream;
class StringRef;
-class StatisticBase {
+class TrackingStatistic {
public:
- const char *DebugType;
- const char *Name;
- const char *Desc;
+ const char *const DebugType;
+ const char *const Name;
+ const char *const Desc;
- 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) {}
+ : DebugType(DebugType), Name(Name), Desc(Desc), Value(0),
+ Initialized(false) {}
+
+ const char *getDebugType() const { return DebugType; }
+ const char *getName() const { return Name; }
+ const char *getDesc() const { return Desc; }
unsigned getValue() const { return Value.load(std::memory_order_relaxed); }
void RegisterStatistic();
};
-class NoopStatistic : public StatisticBase {
+class NoopStatistic {
public:
- using StatisticBase::StatisticBase;
+ NoopStatistic(const char * /*DebugType*/, const char * /*Name*/,
+ const char * /*Desc*/) {}
unsigned getValue() const { return 0; }
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;
}
};
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)
<< "]: " << 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.
/// Assign the statistic to the given value.
Statistic &operator=(unsigned value);
-
- private:
- /// Hide some of the details of llvm::Statistic that we don't use.
- using llvm::Statistic::getDebugType;
};
/// Returns the main statistics for this pass instance.
// If this is not an adaptor, add the stats to the list if there are any.
if (!adaptor) {
+#if LLVM_ENABLE_STATS
auto statistics = pass->getStatistics();
if (statistics.empty())
return;
for (auto &it : llvm::enumerate(pass->getStatistics()))
passEntry[it.index()].value += it.value()->getValue();
}
+#endif
return;
}
/// Print the results in pipeline mode that mirrors the internal pass manager
/// structure.
static void printResultsAsPipeline(raw_ostream &os, OpPassManager &pm) {
+#if LLVM_ENABLE_STATS
std::function<void(unsigned, Pass *)> printPass = [&](unsigned indent,
Pass *pass) {
if (auto *adaptor = dyn_cast<OpToOpPassAdaptor>(pass)) {
};
for (Pass &pass : pm.getPasses())
printPass(/*indent=*/0, &pass);
+#endif
}
static void printStatistics(OpPassManager &pm, PassDisplayMode displayMode) {
+// REQUIRES: asserts
// RUN: mlir-opt %s -verify-each=true -pass-pipeline='func(test-stats-pass,test-stats-pass)' -pass-statistics -pass-statistics-display=list 2>&1 | FileCheck -check-prefix=LIST %s
// RUN: mlir-opt %s -verify-each=true -pass-pipeline='func(test-stats-pass,test-stats-pass)' -pass-statistics -pass-statistics-display=pipeline 2>&1 | FileCheck -check-prefix=PIPELINE %s