[llvm] 1419159 - [llvm-exegesis] Improve error reporting in Target.cpp
Miloš Stojanović via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 7 11:31:04 PST 2020
Author: Miloš Stojanović
Date: 2020-02-06T12:26:08+01:00
New Revision: 141915963b6ab36ee4e577d1b27673fa4d05b409
URL: https://github.com/llvm/llvm-project/commit/141915963b6ab36ee4e577d1b27673fa4d05b409
DIFF: https://github.com/llvm/llvm-project/commit/141915963b6ab36ee4e577d1b27673fa4d05b409.diff
LOG: [llvm-exegesis] Improve error reporting in Target.cpp
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
Added:
Modified:
llvm/tools/llvm-exegesis/lib/Target.cpp
llvm/tools/llvm-exegesis/lib/Target.h
llvm/tools/llvm-exegesis/llvm-exegesis.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp
index 701ff14be209..7fb22314f05a 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -53,7 +53,7 @@ std::unique_ptr<SnippetGenerator> ExegesisTarget::createSnippetGenerator(
return nullptr;
}
-std::unique_ptr<BenchmarkRunner>
+Expected<std::unique_ptr<BenchmarkRunner>>
ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
const LLVMState &State) const {
PfmCountersInfo PfmCounters = State.getPfmCounters();
@@ -66,14 +66,16 @@ ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
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<Failure>(
+ 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<Failure>("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/lib/Target.h b/llvm/tools/llvm-exegesis/lib/Target.h
index d9bddc56e824..1f35bfeed34c 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.h
+++ b/llvm/tools/llvm-exegesis/lib/Target.h
@@ -132,7 +132,7 @@ class ExegesisTarget {
const LLVMState &State,
const SnippetGenerator::Options &Opts) const;
// Creates a benchmark runner for the given mode.
- std::unique_ptr<BenchmarkRunner>
+ Expected<std::unique_ptr<BenchmarkRunner>>
createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
const LLVMState &State) const;
diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
index feb073d5c95f..9c3eef939141 100644
--- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -263,8 +263,8 @@ void benchmarkMain() {
const LLVMState State(CpuName);
- const std::unique_ptr<BenchmarkRunner> Runner =
- State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State);
+ const std::unique_ptr<BenchmarkRunner> Runner = ExitOnErr(
+ State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State));
if (!Runner) {
ExitWithError("cannot create benchmark runner");
}
More information about the llvm-commits
mailing list