forked from OSchip/llvm-project
Recommit: "[llvm-exegesis] Improve error reporting in Target.cpp"
Summary: Commit141915963b
was reverted inabe01e17f6
because it broke builds testing without libpfm. A preparatory commit <commit_sha1> was added to enable this recommit. Original commit message: Followup to D74085. Replace the use of `report_fatal_error()` with returning the error to `llvm-exegesis.cpp` and handling it there. Differential Revision: https://reviews.llvm.org/D74113
This commit is contained in:
parent
830af528a5
commit
4bd40f71a7
|
@ -53,7 +53,7 @@ std::unique_ptr<SnippetGenerator> ExegesisTarget::createSnippetGenerator(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<BenchmarkRunner>
|
Expected<std::unique_ptr<BenchmarkRunner>>
|
||||||
ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
|
ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
|
||||||
const LLVMState &State) const {
|
const LLVMState &State) const {
|
||||||
PfmCountersInfo PfmCounters = State.getPfmCounters();
|
PfmCountersInfo PfmCounters = State.getPfmCounters();
|
||||||
|
@ -66,14 +66,16 @@ ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
|
||||||
const char *ModeName = Mode == InstructionBenchmark::Latency
|
const char *ModeName = Mode == InstructionBenchmark::Latency
|
||||||
? "latency"
|
? "latency"
|
||||||
: "inverse_throughput";
|
: "inverse_throughput";
|
||||||
report_fatal_error(Twine("can't run '").concat(ModeName).concat("' mode, "
|
return make_error<Failure>(
|
||||||
"sched model does not define a cycle counter."));
|
Twine("can't run '")
|
||||||
|
.concat(ModeName)
|
||||||
|
.concat("' mode, sched model does not define a cycle counter."));
|
||||||
}
|
}
|
||||||
return createLatencyBenchmarkRunner(State, Mode);
|
return createLatencyBenchmarkRunner(State, Mode);
|
||||||
case InstructionBenchmark::Uops:
|
case InstructionBenchmark::Uops:
|
||||||
if (!PfmCounters.UopsCounter && !PfmCounters.IssueCounters)
|
if (!PfmCounters.UopsCounter && !PfmCounters.IssueCounters)
|
||||||
report_fatal_error("can't run 'uops' mode, sched model does not define "
|
return make_error<Failure>("can't run 'uops' mode, sched model does not "
|
||||||
"uops or issue counters.");
|
"define uops or issue counters.");
|
||||||
return createUopsBenchmarkRunner(State);
|
return createUopsBenchmarkRunner(State);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -132,7 +132,7 @@ public:
|
||||||
const LLVMState &State,
|
const LLVMState &State,
|
||||||
const SnippetGenerator::Options &Opts) const;
|
const SnippetGenerator::Options &Opts) const;
|
||||||
// Creates a benchmark runner for the given mode.
|
// Creates a benchmark runner for the given mode.
|
||||||
std::unique_ptr<BenchmarkRunner>
|
Expected<std::unique_ptr<BenchmarkRunner>>
|
||||||
createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
|
createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
|
||||||
const LLVMState &State) const;
|
const LLVMState &State) const;
|
||||||
|
|
||||||
|
|
|
@ -263,8 +263,8 @@ void benchmarkMain() {
|
||||||
|
|
||||||
const LLVMState State(CpuName);
|
const LLVMState State(CpuName);
|
||||||
|
|
||||||
const std::unique_ptr<BenchmarkRunner> Runner =
|
const std::unique_ptr<BenchmarkRunner> Runner = ExitOnErr(
|
||||||
State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State);
|
State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State));
|
||||||
if (!Runner) {
|
if (!Runner) {
|
||||||
ExitWithError("cannot create benchmark runner");
|
ExitWithError("cannot create benchmark runner");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue