Skip to content

Commit e47bf3d

Browse files
committed
[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.
1 parent bbc0e63 commit e47bf3d

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ class JITLinkRedirectableSymbolManager : public RedirectableSymbolManager,
2626
/// Create redirection manager that uses JITLink based implementaion.
2727
static Expected<std::unique_ptr<RedirectableSymbolManager>>
2828
Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &JD) {
29-
Error Err = Error::success();
30-
auto RM = std::unique_ptr<RedirectableSymbolManager>(
31-
new JITLinkRedirectableSymbolManager(ObjLinkingLayer, JD, Err));
32-
if (Err)
33-
return Err;
34-
return std::move(RM);
29+
auto AnonymousPtrCreator(jitlink::getAnonymousPointerCreator(
30+
ObjLinkingLayer.getExecutionSession().getTargetTriple()));
31+
auto PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
32+
ObjLinkingLayer.getExecutionSession().getTargetTriple()));
33+
if (!AnonymousPtrCreator || !PtrJumpStubCreator)
34+
return make_error<StringError>("Architecture not supported",
35+
inconvertibleErrorCode());
36+
return std::unique_ptr<RedirectableSymbolManager>(
37+
new JITLinkRedirectableSymbolManager(
38+
ObjLinkingLayer, JD, AnonymousPtrCreator, PtrJumpStubCreator));
3539
}
3640

3741
void emitRedirectableSymbols(std::unique_ptr<MaterializationResponsibility> R,
@@ -52,18 +56,13 @@ class JITLinkRedirectableSymbolManager : public RedirectableSymbolManager,
5256
constexpr static StringRef JumpStubTableName = "$IND_JUMP_";
5357
constexpr static StringRef StubPtrTableName = "$__IND_JUMP_PTRS";
5458

55-
JITLinkRedirectableSymbolManager(ObjectLinkingLayer &ObjLinkingLayer,
56-
JITDylib &JD, Error &Err)
59+
JITLinkRedirectableSymbolManager(
60+
ObjectLinkingLayer &ObjLinkingLayer, JITDylib &JD,
61+
jitlink::AnonymousPointerCreator &AnonymousPtrCreator,
62+
jitlink::PointerJumpStubCreator &PtrJumpStubCreator)
5763
: ObjLinkingLayer(ObjLinkingLayer), JD(JD),
58-
AnonymousPtrCreator(jitlink::getAnonymousPointerCreator(
59-
ObjLinkingLayer.getExecutionSession().getTargetTriple())),
60-
PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
61-
ObjLinkingLayer.getExecutionSession().getTargetTriple())) {
62-
if (!AnonymousPtrCreator || !PtrJumpStubCreator)
63-
Err = make_error<StringError>("Architecture not supported",
64-
inconvertibleErrorCode());
65-
if (Err)
66-
return;
64+
AnonymousPtrCreator(std::move(AnonymousPtrCreator)),
65+
PtrJumpStubCreator(std::move(PtrJumpStubCreator)) {
6766
ObjLinkingLayer.getExecutionSession().registerResourceManager(*this);
6867
}
6968

0 commit comments

Comments
 (0)