[llvm-exegesis] Benchmark: gracefully handle lack of configurations to run
authorRoman Lebedev <lebedev.ri@gmail.com>
Sun, 18 Dec 2022 16:39:45 +0000 (19:39 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sun, 18 Dec 2022 17:07:02 +0000 (20:07 +0300)
Otherwise the progress meter would assert.

llvm/test/tools/llvm-exegesis/X86/latency/latency-SYSENTER.s [new file with mode: 0644]
llvm/tools/llvm-exegesis/llvm-exegesis.cpp

diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-SYSENTER.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-SYSENTER.s
new file mode 100644 (file)
index 0000000..b82b0bf
--- /dev/null
@@ -0,0 +1,4 @@
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SYSENTER -repetition-mode=duplicate 2>&1 | FileCheck %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SYSENTER -repetition-mode=loop 2>&1 | FileCheck %s
+
+CHECK: SYSENTER: unsupported opcode
index 459e980..6a9e475 100644 (file)
@@ -321,6 +321,7 @@ static void runBenchmarkConfigurations(
     const LLVMState &State, ArrayRef<BenchmarkCode> Configurations,
     ArrayRef<std::unique_ptr<const SnippetRepetitor>> Repetitors,
     const BenchmarkRunner &Runner) {
+  assert(!Configurations.empty() && "Don't have any configurations to run.");
   std::optional<raw_fd_ostream> FileOstr;
   if (BenchmarkFile != "-") {
     int ResultFD = 0;
@@ -468,7 +469,8 @@ void benchmarkMain() {
   if (BenchmarkFile.empty())
     BenchmarkFile = "-";
 
-  runBenchmarkConfigurations(State, Configurations, Repetitors, *Runner);
+  if (!Configurations.empty())
+    runBenchmarkConfigurations(State, Configurations, Repetitors, *Runner);
 
   exegesis::pfm::pfmTerminate();
 }