https://github.com/c-rhodes updated 
https://github.com/llvm/llvm-project/pull/178947

>From 467b3bb6c3dbee2ed866be3e0fa476c4b1deeee3 Mon Sep 17 00:00:00 2001
From: Min-Yih Hsu <[email protected]>
Date: Thu, 29 Jan 2026 10:24:25 -0800
Subject: [PATCH] [ELFDebugObjectPlugin] Do not wait for std::future in
 post-fixup phase in the absent of debug info (#178541)

If there is no debug information, we wouldn't call
`DebugObject::collectTargetAlloc` in the post-allocation phase.
Therefore, when it's in the post-fixup phase,
`DebugObject::awaitTargetMem` will fail with _"std::future_error: No
associated state"_ because the std::future was not even populated.

(cherry picked from commit 696ea11b94d119416c9618b5add09d5ac09428aa)
---
 .../Orc/Debugging/ELFDebugObjectPlugin.cpp    | 15 +++++++++++++-
 .../JITLink/x86-64/ELF_no_debug_info.s        | 20 +++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/ExecutionEngine/JITLink/x86-64/ELF_no_debug_info.s

diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.cpp 
b/llvm/lib/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.cpp
index e67eb323c3540..10e9dfdfea79f 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.cpp
@@ -75,7 +75,14 @@ class DebugObject {
 
   void trackFinalizedAlloc(FinalizedAlloc FA) { Alloc = std::move(FA); }
 
-  Expected<ExecutorAddrRange> awaitTargetMem() { return FinalizeFuture.get(); }
+  bool hasPendingTargetMem() const { return FinalizeFuture.valid(); }
+
+  Expected<ExecutorAddrRange> awaitTargetMem() {
+    assert(FinalizeFuture.valid() &&
+           "FinalizeFuture is not valid. Perhaps there is no pending target "
+           "memory transaction?");
+    return FinalizeFuture.get();
+  }
 
   void reportTargetMem(ExecutorAddrRange TargetMem) {
     FinalizePromise.set_value(TargetMem);
@@ -342,6 +349,12 @@ void 
ELFDebugObjectPlugin::modifyPassConfig(MaterializationResponsibility &MR,
     // register the memory range with the GDB JIT Interface in an allocation
     // action of the LinkGraph's own allocation
     DebugObject *DebugObj = getPendingDebugObj(MR);
+    assert(DebugObj && "Don't inject passes if we have no debug object");
+    // Post-allocation phases would bail out if there is no debug section,
+    // in which case we wouldn't collect target memory and therefore shouldn't
+    // wait for the transaction to finish.
+    if (!DebugObj->hasPendingTargetMem())
+      return Error::success();
     Expected<ExecutorAddrRange> R = DebugObj->awaitTargetMem();
     if (!R)
       return R.takeError();
diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_no_debug_info.s 
b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_no_debug_info.s
new file mode 100644
index 0000000000000..141b04078e36b
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_no_debug_info.s
@@ -0,0 +1,20 @@
+# REQUIRES: native && x86_64-linux
+
+# RUN: rm -rf %t && mkdir %t
+# RUN: llvm-mc -triple=x86_64-unknown-linux \
+# RUN:     -filetype=obj -o %t/ELF_x86-64_no_debug_info.o %s
+# RUN: llvm-jitlink %t/ELF_x86-64_no_debug_info.o
+
+# Check if everything works in the absent of any debug information.
+
+       .text
+       .globl  main                            # -- Begin function main
+       .p2align        4
+       .type   main,@function
+main:                                   # @main
+       pushq   %rbp
+       movq    %rsp, %rbp
+       movl    $0, -4(%rbp)
+       movl    $0, %eax
+       popq    %rbp
+       retq

_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to