[llvm] [BOLT] Report JITLink errors appropriately (PR #67633)

Rafael Auler via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 22:00:24 PDT 2023


https://github.com/rafaelauler created https://github.com/llvm/llvm-project/pull/67633

Previously we would crash with an assertion failure (unreachable code) whenever we had an error in JITLink. Change this to use JITLink API correctly and let it print the error to output, so we can read and more easily diagnose what's happening.

Before this patch:
unexpected abandoned allocation
UNREACHABLE executed at...

After this patch:
BOLT-ERROR: JITLink failed: In graph in-memory object file, section .local.foo: relocation target .text + 0x1 at address 0xa7c00000 is out of range of BranchPCRel32 fixup at 0x132d40f1 (bar, 0x132d40f0 + 0x1)

>From 7cc2dccd9fdf9096095deefeac3b79772a405b87 Mon Sep 17 00:00:00 2001
From: Rafael Auler <rafaelauler at fb.com>
Date: Wed, 27 Sep 2023 21:28:10 -0700
Subject: [PATCH] [BOLT] Report JITLink errors appropriately

Previously we would crash with an assertion failure (unreachable code)
whenever we had an error in JITLink. Change this to use JITLink API
correctly and let it print the error to output, so we can read and
more easily diagnose what's happening.

Before this patch:
unexpected abandoned allocation
UNREACHABLE executed at...

After this patch:
BOLT-ERROR: JITLink failed: In graph in-memory object file, section
.local.foo: relocation target .text + 0x1 at address 0xa7c00000 is out
of range of BranchPCRel32 fixup at 0x132d40f1 (bar, 0x132d40f0 + 0x1)
---
 bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp b/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
index 27183897e81bf7e..aa5c8344aa6f542 100644
--- a/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
+++ b/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
@@ -90,7 +90,7 @@ struct BOLTInFlightAlloc : ExecutableFileMemoryManager::InFlightAlloc {
       : Alloc(std::move(Alloc)) {}
 
   virtual void abandon(OnAbandonedFunction OnAbandoned) override {
-    llvm_unreachable("unexpected abandoned allocation");
+    OnAbandoned(Error::success());
   }
 
   virtual void finalize(OnFinalizedFunction OnFinalized) override {



More information about the llvm-commits mailing list