Index: llvm/trunk/tools/llvm-exegesis/lib/Latency.h =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/Latency.h +++ llvm/trunk/tools/llvm-exegesis/lib/Latency.h @@ -38,6 +38,8 @@ std::vector runMeasurements(const ExecutableFunction &EF, const unsigned NumRepetitions) const override; + + virtual const char *getCounterName() const; }; } // namespace exegesis Index: llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp +++ llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp @@ -94,6 +94,18 @@ return generateTwoInstructionPrototype(Instr); } +const char *LatencyBenchmarkRunner::getCounterName() const { + if (!State.getSubtargetInfo().getSchedModel().hasExtraProcessorInfo()) + llvm::report_fatal_error("sched model is missing extra processor info!"); + const char *CounterName = State.getSubtargetInfo() + .getSchedModel() + .getExtraProcessorInfo() + .PfmCounters.CycleCounter; + if (!CounterName) + llvm::report_fatal_error("sched model does not define a cycle counter"); + return CounterName; +} + std::vector LatencyBenchmarkRunner::runMeasurements(const ExecutableFunction &Function, const unsigned NumRepetitions) const { @@ -101,12 +113,9 @@ // measure several times and take the minimum value. constexpr const int NumMeasurements = 30; int64_t MinLatency = std::numeric_limits::max(); - const char *CounterName = State.getSubtargetInfo() - .getSchedModel() - .getExtraProcessorInfo() - .PfmCounters.CycleCounter; + const char *CounterName = getCounterName(); if (!CounterName) - llvm::report_fatal_error("sched model does not define a cycle counter"); + llvm::report_fatal_error("could not determine cycle counter name"); const pfm::PerfEvent CyclesPerfEvent(CounterName); if (!CyclesPerfEvent.valid()) llvm::report_fatal_error("invalid perf event"); Index: llvm/trunk/tools/llvm-exegesis/llvm-exegesis.cpp =================================================================== --- llvm/trunk/tools/llvm-exegesis/llvm-exegesis.cpp +++ llvm/trunk/tools/llvm-exegesis/llvm-exegesis.cpp @@ -140,10 +140,6 @@ return; } - // FIXME: Do not require SchedModel for latency. - if (!State.getSubtargetInfo().getSchedModel().hasExtraProcessorInfo()) - llvm::report_fatal_error("sched model is missing extra processor info!"); - const std::unique_ptr Runner = State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State); if (!Runner) {