[llvm] [JIT] Fix crash in unit tests (PR #113492)

Kai Nacke via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 24 05:56:42 PDT 2024


https://github.com/redstar updated https://github.com/llvm/llvm-project/pull/113492

>From 09444174a7640c6b1ae68639423fb75de0e7d3b5 Mon Sep 17 00:00:00 2001
From: Kai Nacke <kai.peter.nacke at ibm.com>
Date: Wed, 23 Oct 2024 16:13:39 -0400
Subject: [PATCH 1/3] [JIT] Fix crash in unit tests

The unit tests `ReOptimizeLayerTest.BasicReOptimization` and `JITLinkRedirectionManagerTest.BasicRedirectionOperation` are failing for me with the error:

```
Program aborted due to an unhandled Error:
Error value was Success. (Note: Success values must still be checked prior to being destroyed).
```

The error is raised when a value is assigned to `Err`, due to the the missing `ErrorAsOutParameter`.
---
 .../llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h  | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h b/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
index 52f284c89bdade..5b73635d3b1cac 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
@@ -59,6 +59,7 @@ class JITLinkRedirectableSymbolManager : public RedirectableSymbolManager,
             ObjLinkingLayer.getExecutionSession().getTargetTriple())),
         PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
             ObjLinkingLayer.getExecutionSession().getTargetTriple())) {
+    ErrorAsOutParameter _(&Err);
     if (!AnonymousPtrCreator || !PtrJumpStubCreator)
       Err = make_error<StringError>("Architecture not supported",
                                     inconvertibleErrorCode());

>From a837581fdd8d82829f4c7da36ecae50301a672d3 Mon Sep 17 00:00:00 2001
From: Kai Nacke <kai.peter.nacke at ibm.com>
Date: Wed, 23 Oct 2024 17:11:10 -0400
Subject: [PATCH 2/3] Fix another problem

---
 .../llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h b/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
index 5b73635d3b1cac..69489fb50bc59a 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
@@ -60,12 +60,12 @@ class JITLinkRedirectableSymbolManager : public RedirectableSymbolManager,
         PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
             ObjLinkingLayer.getExecutionSession().getTargetTriple())) {
     ErrorAsOutParameter _(&Err);
+    ObjLinkingLayer.getExecutionSession().registerResourceManager(*this);
     if (!AnonymousPtrCreator || !PtrJumpStubCreator)
       Err = make_error<StringError>("Architecture not supported",
                                     inconvertibleErrorCode());
     if (Err)
       return;
-    ObjLinkingLayer.getExecutionSession().registerResourceManager(*this);
   }
 
   ~JITLinkRedirectableSymbolManager() {

>From 61508af6cb2452f959eeef37aae51758c884e970 Mon Sep 17 00:00:00 2001
From: Kai Nacke <kai.peter.nacke at ibm.com>
Date: Thu, 24 Oct 2024 08:56:11 -0400
Subject: [PATCH 3/3] Remove now useless if

---
 .../llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h b/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
index 69489fb50bc59a..a7c551f279cbc2 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
@@ -64,8 +64,6 @@ class JITLinkRedirectableSymbolManager : public RedirectableSymbolManager,
     if (!AnonymousPtrCreator || !PtrJumpStubCreator)
       Err = make_error<StringError>("Architecture not supported",
                                     inconvertibleErrorCode());
-    if (Err)
-      return;
   }
 
   ~JITLinkRedirectableSymbolManager() {



More information about the llvm-commits mailing list