diff --git a/llvm/tools/llvm-exegesis/lib/Target.h b/llvm/tools/llvm-exegesis/lib/Target.h --- a/llvm/tools/llvm-exegesis/lib/Target.h +++ b/llvm/tools/llvm-exegesis/lib/Target.h @@ -132,7 +132,7 @@ const LLVMState &State, const SnippetGenerator::Options &Opts) const; // Creates a benchmark runner for the given mode. - std::unique_ptr + Expected> createBenchmarkRunner(InstructionBenchmark::ModeE Mode, const LLVMState &State) const; diff --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp --- a/llvm/tools/llvm-exegesis/lib/Target.cpp +++ b/llvm/tools/llvm-exegesis/lib/Target.cpp @@ -53,7 +53,7 @@ return nullptr; } -std::unique_ptr +Expected> ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode, const LLVMState &State) const { PfmCountersInfo PfmCounters = State.getPfmCounters(); @@ -66,14 +66,16 @@ const char *ModeName = Mode == InstructionBenchmark::Latency ? "latency" : "inverse_throughput"; - report_fatal_error(Twine("can't run '").concat(ModeName).concat("' mode, " - "sched model does not define a cycle counter.")); + return make_error( + Twine("can't run '") + .concat(ModeName) + .concat("' mode, sched model does not define a cycle counter.")); } return createLatencyBenchmarkRunner(State, Mode); case InstructionBenchmark::Uops: if (!PfmCounters.UopsCounter && !PfmCounters.IssueCounters) - report_fatal_error("can't run 'uops' mode, sched model does not define " - "uops or issue counters."); + return make_error("can't run 'uops' mode, sched model does not " + "define uops or issue counters."); return createUopsBenchmarkRunner(State); } return nullptr; diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp --- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp +++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp @@ -263,8 +263,8 @@ const LLVMState State(CpuName); - const std::unique_ptr Runner = - State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State); + const std::unique_ptr Runner = ExitOnErr( + State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State)); if (!Runner) { ExitWithError("cannot create benchmark runner"); }