diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h b/llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h index 52f284c89bdad..ef42cc5f798fd 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> Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &JD) { - Error Err = Error::success(); - auto RM = std::unique_ptr( - 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("Architecture not supported", + inconvertibleErrorCode()); + return std::unique_ptr( + new JITLinkRedirectableSymbolManager( + ObjLinkingLayer, JD, AnonymousPtrCreator, PtrJumpStubCreator)); } void emitRedirectableSymbols(std::unique_ptr 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("Architecture not supported", - inconvertibleErrorCode()); - if (Err) - return; + AnonymousPtrCreator(std::move(AnonymousPtrCreator)), + PtrJumpStubCreator(std::move(PtrJumpStubCreator)) { ObjLinkingLayer.getExecutionSession().registerResourceManager(*this); }