Skip to content

[llvm-exegesis] Minor changes for downstream consumers #74211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

boomanaiden154
Copy link
Contributor

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.

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.
@llvmbot
Copy link
Member

llvmbot commented Dec 2, 2023

@llvm/pr-subscribers-tools-llvm-exegesis

Author: Aiden Grossman (boomanaiden154)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/74211.diff

3 Files Affected:

  • (modified) llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp (+4-3)
  • (modified) llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h (+3-3)
  • (modified) llvm/tools/llvm-exegesis/lib/Error.h (+2)
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index f5d73a8bd6a3..51c9c6cd0935 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 24f208628940..eb8c9f55722c 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 8d3f394ed8d6..8c95439d63ac 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;

@boomanaiden154
Copy link
Contributor Author

This seemed to be the most minimally invasive set of changes to achieve what I needed to be able to use things downstream. I tried a couple alternatives, but couldn't get them to work or they weren't as clean. Happy if there are other suggestions that make things cleaner however.

@boomanaiden154
Copy link
Contributor Author

Bump on this when reviewers have a chance. Thanks!

legrosbuffle added a commit to legrosbuffle/llvm-project that referenced this pull request Dec 7, 2023
…ndling.

Returns an error *and* a benchmark rather than an error *or* a benchmark. This allows users
to have custom error handling while still being able to inspect the benchmark.

Apart from this small API change, this is an NFC.

This is an alternative to llvm#74211.
@boomanaiden154
Copy link
Contributor Author

Closed in favor of #74711. Will add the getter as part of #74210.

legrosbuffle added a commit that referenced this pull request Dec 8, 2023
#74711)

…ndling.

Returns an error *and* a benchmark rather than an error *or* a
benchmark. This allows users to have custom error handling while still
being able to inspect the benchmark.

Apart from this small API change, this is an NFC.

This is an alternative to #74211.
@boomanaiden154 boomanaiden154 deleted the users/boomanaiden154/exegesis-segfault-consumer branch December 17, 2023 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants