[llvm] [llvm-exegesis] Add explicit error message with segfault address (PR #72774)

via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 18 19:43:52 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Aiden Grossman (boomanaiden154)

<details>
<summary>Changes</summary>

This patch special cases the segfault case for the subprocess executor, giving the exact address of a segfault when one occurs in the subprocess. This makes it a lot easier to debug where things are going wrong in the snippet.

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


2 Files Affected:

- (modified) llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s (+2-2) 
- (modified) llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp (+6) 


``````````diff
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s b/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s
index bc01c607f0721ca..643d36022893a89 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s
@@ -2,10 +2,10 @@
 
 # RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mode=latency -snippets-file=%s -execution-mode=subprocess | FileCheck %s
 
-# CHECK: error:           'The benchmarking subprocess sent unexpected signal: Segmentation fault'
+# CHECK: error:           A segmentation fault occurred at address 10000
 
 # TODO: Sometimes transiently fails on PTRACE_ATTACH
 # ALLOW_RETRIES: 2
 
-# LLVM-EXEGESIS-DEFREG RBX 0
+# LLVM-EXEGESIS-DEFREG RBX 10000
 movq (%rbx), %rax
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 7ec24eb2f866f86..b735b4d1037c53d 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -343,6 +343,12 @@ class SubProcessFunctionExecutorImpl
                                  Twine(strerror(errno)));
     }
 
+    if (ChildSignalInfo.si_signo == SIGSEGV)
+      return make_error<SnippetCrash>(
+          "A segmentation fault occurred at address " +
+          Twine::utohexstr(
+              reinterpret_cast<intptr_t>(ChildSignalInfo.si_addr)));
+
     return make_error<SnippetCrash>(
         "The benchmarking subprocess sent unexpected signal: " +
         Twine(strsignal(ChildSignalInfo.si_signo)));

``````````

</details>


https://github.com/llvm/llvm-project/pull/72774


More information about the llvm-commits mailing list