[llvm-branch-commits] [llvm] [llvm-exegesis] Minor changes for downstream consumers (PR #74211)

Aiden Grossman via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Dec 2 14:31:44 PST 2023


https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/74211

>From 2bddb1011489651cb2e5f2f94d5fae89ddf63216 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sat, 2 Dec 2023 14:18:50 -0800
Subject: [PATCH 1/2] [llvm-exegesis] Minor changes for downstream consumers

This patch adjust the runConfiguration function to allow passing a
parameter to force returning SnippetCrashes as errors rather than
serializing them as strings in the returned Benchmark object. In
addition, this patch adds a getter for the signal information address in
the SnippetCrash object.

These are both needed to allow for downstream consumption of the
exegesis library within Gematria.
---
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | 7 ++++---
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h   | 6 +++---
 llvm/tools/llvm-exegesis/lib/Error.h             | 2 ++
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index f5d73a8bd6a31..51c9c6cd09358 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -545,9 +545,10 @@ BenchmarkRunner::createFunctionExecutor(
   llvm_unreachable("ExecutionMode is outside expected range");
 }
 
-Expected<Benchmark> BenchmarkRunner::runConfiguration(
-    RunnableConfiguration &&RC,
-    const std::optional<StringRef> &DumpFile) const {
+Expected<Benchmark>
+BenchmarkRunner::runConfiguration(RunnableConfiguration &&RC,
+                                  const std::optional<StringRef> &DumpFile,
+                                  bool ErrorOnSnippetCrash /*= false*/) const {
   Benchmark &InstrBenchmark = RC.InstrBenchmark;
   object::OwningBinary<object::ObjectFile> &ObjectFile = RC.ObjectFile;
 
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h
index 24f2086289408..eb8c9f55722ca 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h
@@ -65,9 +65,9 @@ class BenchmarkRunner {
                            unsigned NumRepetitions, unsigned LoopUnrollFactor,
                            const SnippetRepetitor &Repetitor) const;
 
-  Expected<Benchmark>
-  runConfiguration(RunnableConfiguration &&RC,
-                   const std::optional<StringRef> &DumpFile) const;
+  Expected<Benchmark> runConfiguration(RunnableConfiguration &&RC,
+                                       const std::optional<StringRef> &DumpFile,
+                                       bool ErrorOnSnippetCrash = false) const;
 
   // Scratch space to run instructions that touch memory.
   struct ScratchSpace {
diff --git a/llvm/tools/llvm-exegesis/lib/Error.h b/llvm/tools/llvm-exegesis/lib/Error.h
index 8d3f394ed8d6e..8c95439d63ac6 100644
--- a/llvm/tools/llvm-exegesis/lib/Error.h
+++ b/llvm/tools/llvm-exegesis/lib/Error.h
@@ -52,6 +52,8 @@ class SnippetCrash : public ErrorInfo<SnippetCrash> {
 
   std::error_code convertToErrorCode() const override;
 
+  intptr_t GetCrashAddress() const { return SIAddress; }
+
 private:
   std::string Msg;
   intptr_t SIAddress;

>From f13b5d31450a095d6e11176b3db787f1e0894337 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sat, 2 Dec 2023 14:31:33 -0800
Subject: [PATCH 2/2] Actually update code

---
 llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 51c9c6cd09358..bda7fb8b6ba9c 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -576,7 +576,7 @@ BenchmarkRunner::runConfiguration(RunnableConfiguration &&RC,
   auto NewMeasurements = runMeasurements(**Executor);
 
   if (Error E = NewMeasurements.takeError()) {
-    if (!E.isA<SnippetCrash>())
+    if (!E.isA<SnippetCrash>() || ErrorOnSnippetCrash)
       return std::move(E);
     InstrBenchmark.Error = toString(std::move(E));
     return std::move(InstrBenchmark);



More information about the llvm-branch-commits mailing list