summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-exegesis/llvm-exegesis.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/llvm-exegesis.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
index a1848c3f14f..e59843b4aca 100644
--- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -45,7 +45,7 @@ static llvm::cl::opt<std::string>
llvm::cl::init(""));
static llvm::cl::opt<std::string>
- BenchmarkFile("benchmarks-file", llvm::cl::desc(""), llvm::cl::init("-"));
+ BenchmarkFile("benchmarks-file", llvm::cl::desc(""), llvm::cl::init(""));
enum class BenchmarkModeE { Latency, Uops, Analysis };
static llvm::cl::opt<BenchmarkModeE> BenchmarkMode(
@@ -79,6 +79,8 @@ static llvm::cl::opt<std::string>
namespace exegesis {
+static llvm::ExitOnError ExitOnErr;
+
static unsigned GetOpcodeOrDie(const llvm::MCInstrInfo &MCInstrInfo) {
if (OpcodeName.empty() && (OpcodeIndex == 0))
llvm::report_fatal_error(
@@ -138,8 +140,13 @@ void benchmarkMain() {
if (NumRepetitions == 0)
llvm::report_fatal_error("--num-repetitions must be greater than zero");
- Runner->run(GetOpcodeOrDie(State.getInstrInfo()), Filter, NumRepetitions)
- .writeYamlOrDie(getBenchmarkResultContext(State), BenchmarkFile);
+ // Write to standard output if file is not set.
+ if (BenchmarkFile.empty())
+ BenchmarkFile = "-";
+
+ ExitOnErr(
+ Runner->run(GetOpcodeOrDie(State.getInstrInfo()), Filter, NumRepetitions)
+ .writeYaml(getBenchmarkResultContext(State), BenchmarkFile));
exegesis::pfm::pfmTerminate();
}
@@ -157,21 +164,21 @@ static void maybeRunAnalysis(const Analysis &Analyzer, const std::string &Name,
std::error_code ErrorCode;
llvm::raw_fd_ostream ClustersOS(OutputFilename, ErrorCode,
llvm::sys::fs::F_RW);
- if (ErrorCode)
- llvm::report_fatal_error("cannot open out file: " + OutputFilename);
- if (auto Err = Analyzer.run<Pass>(ClustersOS))
- llvm::report_fatal_error(std::move(Err));
+ ExitOnErr(llvm::errorCodeToError(ErrorCode));
+ ExitOnErr(Analyzer.run<Pass>(ClustersOS));
}
static void analysisMain() {
+ if (BenchmarkFile.empty())
+ llvm::report_fatal_error("--benchmarks-file must be set.");
+
llvm::InitializeNativeTarget();
llvm::InitializeNativeTargetAsmPrinter();
-
// Read benchmarks.
const LLVMState State;
const std::vector<InstructionBenchmark> Points =
- InstructionBenchmark::readYamlsOrDie(getBenchmarkResultContext(State),
- BenchmarkFile);
+ ExitOnErr(InstructionBenchmark::readYamls(
+ getBenchmarkResultContext(State), BenchmarkFile));
llvm::outs() << "Parsed " << Points.size() << " benchmark points\n";
if (Points.empty()) {
llvm::errs() << "no benchmarks to analyze\n";
OpenPOWER on IntegriCloud