[llvm] e47bf3d - [JIT] Fix crash in unit tests
Kai Nacke via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 25 08:11:23 PDT 2024
Author: Kai Nacke
Date: 2024-10-25T11:11:03-04:00
New Revision: e47bf3d08d51306f2e534951a1b77043dc540ceb
URL: https://github.com/llvm/llvm-project/commit/e47bf3d08d51306f2e534951a1b77043dc540ceb
DIFF: https://github.com/llvm/llvm-project/commit/e47bf3d08d51306f2e534951a1b77043dc540ceb.diff
LOG: [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`.
The fix is to move the error handling out of the constructor.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h b/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
index 52f284c89bdade..ef42cc5f798fd9 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h
@@ -26,12 +26,16 @@ class JITLinkRedirectableSymbolManager : public RedirectableSymbolManager,
/// Create redirection manager that uses JITLink based implementaion.
static Expected<std::unique_ptr<RedirectableSymbolManager>>
Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &JD) {
- Error Err = Error::success();
- auto RM = std::unique_ptr<RedirectableSymbolManager>(
- new JITLinkRedirectableSymbolManager(ObjLinkingLayer, JD, Err));
- if (Err)
- return Err;
- return std::move(RM);
+ auto AnonymousPtrCreator(jitlink::getAnonymousPointerCreator(
+ ObjLinkingLayer.getExecutionSession().getTargetTriple()));
+ auto PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
+ ObjLinkingLayer.getExecutionSession().getTargetTriple()));
+ if (!AnonymousPtrCreator || !PtrJumpStubCreator)
+ return make_error<StringError>("Architecture not supported",
+ inconvertibleErrorCode());
+ return std::unique_ptr<RedirectableSymbolManager>(
+ new JITLinkRedirectableSymbolManager(
+ ObjLinkingLayer, JD, AnonymousPtrCreator, PtrJumpStubCreator));
}
void emitRedirectableSymbols(std::unique_ptr<MaterializationResponsibility> R,
@@ -52,18 +56,13 @@ class JITLinkRedirectableSymbolManager : public RedirectableSymbolManager,
constexpr static StringRef JumpStubTableName = "$IND_JUMP_";
constexpr static StringRef StubPtrTableName = "$__IND_JUMP_PTRS";
- JITLinkRedirectableSymbolManager(ObjectLinkingLayer &ObjLinkingLayer,
- JITDylib &JD, Error &Err)
+ JITLinkRedirectableSymbolManager(
+ ObjectLinkingLayer &ObjLinkingLayer, JITDylib &JD,
+ jitlink::AnonymousPointerCreator &AnonymousPtrCreator,
+ jitlink::PointerJumpStubCreator &PtrJumpStubCreator)
: ObjLinkingLayer(ObjLinkingLayer), JD(JD),
- AnonymousPtrCreator(jitlink::getAnonymousPointerCreator(
- ObjLinkingLayer.getExecutionSession().getTargetTriple())),
- PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
- ObjLinkingLayer.getExecutionSession().getTargetTriple())) {
- if (!AnonymousPtrCreator || !PtrJumpStubCreator)
- Err = make_error<StringError>("Architecture not supported",
- inconvertibleErrorCode());
- if (Err)
- return;
+ AnonymousPtrCreator(std::move(AnonymousPtrCreator)),
+ PtrJumpStubCreator(std::move(PtrJumpStubCreator)) {
ObjLinkingLayer.getExecutionSession().registerResourceManager(*this);
}
More information about the llvm-commits
mailing list