diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h new file mode 100644 index 0000000000000..688439f539e0a --- /dev/null +++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h @@ -0,0 +1,46 @@ +//===---- OrcRTBridge.h -- Utils for interacting with orc-rt ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Declares types and symbol names provided by the ORC runtime. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_ORCRTBRIDGE_H +#define LLVM_EXECUTIONENGINE_ORC_SHARED_ORCRTBRIDGE_H + +#include "llvm/ADT/StringMap.h" +#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h" +#include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h" + +namespace llvm { +namespace orc { +namespace rt { + +extern const char *MemoryReserveWrapperName; +extern const char *MemoryFinalizeWrapperName; +extern const char *MemoryDeallocateWrapperName; +extern const char *MemoryWriteUInt8sWrapperName; +extern const char *MemoryWriteUInt16sWrapperName; +extern const char *MemoryWriteUInt32sWrapperName; +extern const char *MemoryWriteUInt64sWrapperName; +extern const char *MemoryWriteBuffersWrapperName; +extern const char *RunAsMainWrapperName; + +using SPSMemoryReserveSignature = + shared::SPSExpected(uint64_t); +using SPSMemoryFinalizeSignature = shared::SPSError(shared::SPSFinalizeRequest); +using SPSMemoryDeallocateSignature = + shared::SPSError(shared::SPSExecutorAddress, uint64_t); +using SPSRunAsMainSignature = int64_t(shared::SPSExecutorAddress, + shared::SPSSequence); + +} // end namespace rt +} // end namespace orc +} // end namespace llvm + +#endif // LLVM_EXECUTIONENGINE_ORC_SHARED_ORCRTBRIDGE_H diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h index c9d0d9889d3d2..3a1e9ae3783b9 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h @@ -211,9 +211,6 @@ class SPSSerializationTraits); - using SPSLoadDylibSignature = SPSExpected(SPSExecutorAddress, SPSString, uint64_t); diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h index 815dd73ff2877..f4fd6199ef012 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h @@ -222,9 +222,6 @@ class SPSSerializationTraits(uint64_t); -using SPSOrcTargetProcessFinalize = SPSError(SPSFinalizeRequest); -using SPSOrcTargetProcessDeallocate = SPSError(SPSExecutorAddress, uint64_t); } // end namespace shared } // end namespace orc diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp index 5303b7cf2e5a5..0cdb0aa7c04ab 100644 --- a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp @@ -8,6 +8,7 @@ #include "llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h" #include "llvm/ExecutionEngine/Orc/LookupAndRecordAddrs.h" +#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" #include @@ -58,7 +59,7 @@ class EPCGenericJITLinkMemoryManager::Alloc {WorkingMem, static_cast(KV.second.ContentSize)}}); WorkingMem += KV.second.ContentSize; } - Parent.EPC.callSPSWrapperAsync( + Parent.EPC.callSPSWrapperAsync( [OnFinalize = std::move(OnFinalize)](Error SerializationErr, Error FinalizeErr) { if (SerializationErr) @@ -71,9 +72,8 @@ class EPCGenericJITLinkMemoryManager::Alloc Error deallocate() override { Error Err = Error::success(); - if (auto E2 = - Parent.EPC.callSPSWrapper( - Parent.FAs.Deallocate.getValue(), Err, TargetAddr, TargetSize)) + if (auto E2 = Parent.EPC.callSPSWrapper( + Parent.FAs.Deallocate.getValue(), Err, TargetAddr, TargetSize)) return E2; return Err; } @@ -111,7 +111,7 @@ EPCGenericJITLinkMemoryManager::allocate(const jitlink::JITLinkDylib *JD, if (WorkingSize > 0) WorkingBuffer = std::make_unique(WorkingSize); Expected TargetAllocAddr((ExecutorAddress())); - if (auto Err = EPC.callSPSWrapper( + if (auto Err = EPC.callSPSWrapper( FAs.Reserve.getValue(), TargetAllocAddr, AllocSize)) return std::move(Err); if (!TargetAllocAddr) diff --git a/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt b/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt index 08f0f19213107..bf734ba99e171 100644 --- a/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt +++ b/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt @@ -1,5 +1,6 @@ add_llvm_component_library(LLVMOrcShared OrcError.cpp + OrcRTBridge.cpp RPCError.cpp SimpleRemoteEPCUtils.cpp ADDITIONAL_HEADER_DIRS diff --git a/llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp b/llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp new file mode 100644 index 0000000000000..16fee1fd03cab --- /dev/null +++ b/llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp @@ -0,0 +1,35 @@ +//===------ OrcRTBridge.cpp - Executor functions for bootstrap -----===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" + +namespace llvm { +namespace orc { +namespace rt { + +const char *MemoryReserveWrapperName = + "__llvm_orc_bootstrap_mem_reserve_wrapper"; +const char *MemoryFinalizeWrapperName = + "__llvm_orc_bootstrap_mem_finalize_wrapper"; +const char *MemoryDeallocateWrapperName = + "__llvm_orc_bootstrap_mem_deallocate_wrapper"; +const char *MemoryWriteUInt8sWrapperName = + "__llvm_orc_bootstrap_mem_write_uint8s_wrapper"; +const char *MemoryWriteUInt16sWrapperName = + "__llvm_orc_bootstrap_mem_write_uint16s_wrapper"; +const char *MemoryWriteUInt32sWrapperName = + "__llvm_orc_bootstrap_mem_write_uint32s_wrapper"; +const char *MemoryWriteUInt64sWrapperName = + "__llvm_orc_bootstrap_mem_write_uint64s_wrapper"; +const char *MemoryWriteBuffersWrapperName = + "__llvm_orc_bootstrap_mem_write_buffers_wrapper"; +const char *RunAsMainWrapperName = "__llvm_orc_bootstrap_run_as_main_wrapper"; + +} // end namespace rt +} // end namespace orc +} // end namespace llvm diff --git a/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp b/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp index 22e49eb69bcde..c9d7db21298ac 100644 --- a/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp +++ b/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp @@ -9,6 +9,7 @@ #include "llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h" #include "llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h" #include "llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h" +#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" #include "llvm/Support/FormatVariadic.h" #define DEBUG_TYPE "orc" @@ -89,7 +90,7 @@ SimpleRemoteEPC::lookupSymbols(ArrayRef Request) { Expected SimpleRemoteEPC::runAsMain(JITTargetAddress MainFnAddr, ArrayRef Args) { int64_t Result = 0; - if (auto Err = callSPSWrapper( + if (auto Err = callSPSWrapper( RunAsMainAddr.getValue(), Result, ExecutorAddress(MainFnAddr), Args)) return std::move(Err); return Result; @@ -171,9 +172,9 @@ Expected> SimpleRemoteEPC::createMemoryManager() { EPCGenericJITLinkMemoryManager::FuncAddrs FAs; if (auto Err = getBootstrapSymbols( - {{FAs.Reserve, "__llvm_orc_memory_reserve"}, - {FAs.Finalize, "__llvm_orc_memory_finalize"}, - {FAs.Deallocate, "__llvm_orc_memory_deallocate"}})) + {{FAs.Reserve, rt::MemoryReserveWrapperName}, + {FAs.Finalize, rt::MemoryFinalizeWrapperName}, + {FAs.Deallocate, rt::MemoryDeallocateWrapperName}})) return std::move(Err); return std::make_unique(*this, FAs); @@ -252,7 +253,7 @@ Error SimpleRemoteEPC::setup(std::unique_ptr T, {JDI.JITDispatchFunctionAddress, DispatchFnName}, {LoadDylibAddr, "__llvm_orc_load_dylib"}, {LookupSymbolsAddr, "__llvm_orc_lookup_symbols"}, - {RunAsMainAddr, "__llvm_orc_run_as_main"}})) + {RunAsMainAddr, rt::RunAsMainWrapperName}})) return Err; if (auto MemMgr = createMemoryManager()) { diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt b/llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt index 2cc89db8c0bee..1ae02c30298b4 100644 --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt @@ -1,5 +1,6 @@ add_llvm_component_library(LLVMOrcTargetProcess JITLoaderGDB.cpp + OrcRTBootstrap.cpp RegisterEHFrames.cpp SimpleRemoteEPCServer.cpp TargetExecutionUtils.cpp diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/OrcRTBootstrap.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/OrcRTBootstrap.cpp new file mode 100644 index 0000000000000..a95bcdbe1b79b --- /dev/null +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/OrcRTBootstrap.cpp @@ -0,0 +1,134 @@ +//===------------------------ OrcRTBootstrap.cpp --------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "OrcRTBootstrap.h" + +#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" +#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h" +#include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h" + +#define DEBUG_TYPE "orc" + +using namespace llvm::orc::shared; + +namespace llvm { +namespace orc { +namespace rt_bootstrap { + +static llvm::orc::shared::detail::CWrapperFunctionResult +reserveWrapper(const char *ArgData, size_t ArgSize) { + return WrapperFunction::handle( + ArgData, ArgSize, + [](uint64_t Size) -> Expected { + std::error_code EC; + auto MB = sys::Memory::allocateMappedMemory( + Size, 0, sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC); + if (EC) + return errorCodeToError(EC); + return ExecutorAddress::fromPtr(MB.base()); + }) + .release(); +} + +static llvm::orc::shared::detail::CWrapperFunctionResult +finalizeWrapper(const char *ArgData, size_t ArgSize) { + return WrapperFunction::handle( + ArgData, ArgSize, + [](const tpctypes::FinalizeRequest &FR) -> Error { + for (auto &Seg : FR) { + char *Mem = Seg.Addr.toPtr(); + memcpy(Mem, Seg.Content.data(), Seg.Content.size()); + memset(Mem + Seg.Content.size(), 0, + Seg.Size - Seg.Content.size()); + assert(Seg.Size <= std::numeric_limits::max()); + if (auto EC = sys::Memory::protectMappedMemory( + {Mem, static_cast(Seg.Size)}, + tpctypes::fromWireProtectionFlags(Seg.Prot))) + return errorCodeToError(EC); + if (Seg.Prot & tpctypes::WPF_Exec) + sys::Memory::InvalidateInstructionCache(Mem, Seg.Size); + } + return Error::success(); + }) + .release(); +} + +static llvm::orc::shared::detail::CWrapperFunctionResult +deallocateWrapper(const char *ArgData, size_t ArgSize) { + return WrapperFunction::handle( + ArgData, ArgSize, + [](ExecutorAddress Base, uint64_t Size) -> Error { + sys::MemoryBlock MB(Base.toPtr(), Size); + if (auto EC = sys::Memory::releaseMappedMemory(MB)) + return errorCodeToError(EC); + return Error::success(); + }) + .release(); +} + +template +static llvm::orc::shared::detail::CWrapperFunctionResult +writeUIntsWrapper(const char *ArgData, size_t ArgSize) { + return WrapperFunction)>::handle( + ArgData, ArgSize, + [](std::vector Ws) { + for (auto &W : Ws) + *jitTargetAddressToPointer(W.Address) = + W.Value; + }) + .release(); +} + +static llvm::orc::shared::detail::CWrapperFunctionResult +writeBuffersWrapper(const char *ArgData, size_t ArgSize) { + return WrapperFunction)>::handle( + ArgData, ArgSize, + [](std::vector Ws) { + for (auto &W : Ws) + memcpy(jitTargetAddressToPointer(W.Address), + W.Buffer.data(), W.Buffer.size()); + }) + .release(); +} + +static llvm::orc::shared::detail::CWrapperFunctionResult +runAsMainWrapper(const char *ArgData, size_t ArgSize) { + return WrapperFunction::handle( + ArgData, ArgSize, + [](ExecutorAddress MainAddr, + std::vector Args) -> int64_t { + return runAsMain(MainAddr.toPtr(), Args); + }) + .release(); +} + +void addTo(StringMap &M) { + M[rt::MemoryReserveWrapperName] = ExecutorAddress::fromPtr(&reserveWrapper); + M[rt::MemoryFinalizeWrapperName] = ExecutorAddress::fromPtr(&finalizeWrapper); + M[rt::MemoryDeallocateWrapperName] = + ExecutorAddress::fromPtr(&deallocateWrapper); + M[rt::MemoryWriteUInt8sWrapperName] = ExecutorAddress::fromPtr( + &writeUIntsWrapper); + M[rt::MemoryWriteUInt16sWrapperName] = ExecutorAddress::fromPtr( + &writeUIntsWrapper); + M[rt::MemoryWriteUInt32sWrapperName] = ExecutorAddress::fromPtr( + &writeUIntsWrapper); + M[rt::MemoryWriteUInt64sWrapperName] = ExecutorAddress::fromPtr( + &writeUIntsWrapper); + M[rt::MemoryWriteBuffersWrapperName] = + ExecutorAddress::fromPtr(&writeBuffersWrapper); + M[rt::RunAsMainWrapperName] = ExecutorAddress::fromPtr(&runAsMainWrapper); +} + +} // end namespace rt_bootstrap +} // end namespace orc +} // end namespace llvm diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/OrcRTBootstrap.h b/llvm/lib/ExecutionEngine/Orc/TargetProcess/OrcRTBootstrap.h new file mode 100644 index 0000000000000..008e87071eead --- /dev/null +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/OrcRTBootstrap.h @@ -0,0 +1,36 @@ +//===----------------------- OrcRTBootstrap.h -------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// OrcRTPrelinkImpl provides functions that should be linked into the executor +// to bootstrap common JIT functionality (e.g. memory allocation and memory +// access). +// +// Call rt_impl::addTo to add these functions to a bootstrap symbols map. +// +// FIXME: The functionality in this file should probably be moved to an ORC +// runtime bootstrap library in compiler-rt. +// +//===----------------------------------------------------------------------===// + +#ifndef LIB_EXECUTIONENGINE_ORC_TARGETPROCESS_ORCRTBOOTSTRAP_H +#define LIB_EXECUTIONENGINE_ORC_TARGETPROCESS_ORCRTBOOTSTRAP_H + +#include "llvm/ADT/StringMap.h" +#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h" + +namespace llvm { +namespace orc { +namespace rt_bootstrap { + +void addTo(StringMap &M); + +} // namespace rt_bootstrap +} // end namespace orc +} // end namespace llvm + +#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_ORCRTBOOTSTRAP_H diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp index ce341ff1583c4..e95c6cb1f3a74 100644 --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp @@ -9,11 +9,12 @@ #include "llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h" #include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h" -#include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Host.h" #include "llvm/Support/Process.h" +#include "OrcRTBootstrap.h" + #define DEBUG_TYPE "orc" using namespace llvm::orc::shared; @@ -21,93 +22,6 @@ using namespace llvm::orc::shared; namespace llvm { namespace orc { -static llvm::orc::shared::detail::CWrapperFunctionResult -reserveWrapper(const char *ArgData, size_t ArgSize) { - return WrapperFunction::handle( - ArgData, ArgSize, - [](uint64_t Size) -> Expected { - std::error_code EC; - auto MB = sys::Memory::allocateMappedMemory( - Size, 0, sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC); - if (EC) - return errorCodeToError(EC); - return ExecutorAddress::fromPtr(MB.base()); - }) - .release(); -} - -static llvm::orc::shared::detail::CWrapperFunctionResult -finalizeWrapper(const char *ArgData, size_t ArgSize) { - return WrapperFunction::handle( - ArgData, ArgSize, - [](const tpctypes::FinalizeRequest &FR) -> Error { - for (auto &Seg : FR) { - char *Mem = Seg.Addr.toPtr(); - memcpy(Mem, Seg.Content.data(), Seg.Content.size()); - memset(Mem + Seg.Content.size(), 0, - Seg.Size - Seg.Content.size()); - assert(Seg.Size <= std::numeric_limits::max()); - if (auto EC = sys::Memory::protectMappedMemory( - {Mem, static_cast(Seg.Size)}, - tpctypes::fromWireProtectionFlags(Seg.Prot))) - return errorCodeToError(EC); - if (Seg.Prot & tpctypes::WPF_Exec) - sys::Memory::InvalidateInstructionCache(Mem, Seg.Size); - } - return Error::success(); - }) - .release(); -} - -static llvm::orc::shared::detail::CWrapperFunctionResult -deallocateWrapper(const char *ArgData, size_t ArgSize) { - return WrapperFunction::handle( - ArgData, ArgSize, - [](ExecutorAddress Base, uint64_t Size) -> Error { - sys::MemoryBlock MB(Base.toPtr(), Size); - if (auto EC = sys::Memory::releaseMappedMemory(MB)) - return errorCodeToError(EC); - return Error::success(); - }) - .release(); -} - -template -static llvm::orc::shared::detail::CWrapperFunctionResult -writeUIntsWrapper(const char *ArgData, size_t ArgSize) { - return WrapperFunction)>::handle( - ArgData, ArgSize, - [](std::vector Ws) { - for (auto &W : Ws) - *jitTargetAddressToPointer(W.Address) = - W.Value; - }) - .release(); -} - -static llvm::orc::shared::detail::CWrapperFunctionResult -writeBuffersWrapper(const char *ArgData, size_t ArgSize) { - return WrapperFunction)>::handle( - ArgData, ArgSize, - [](std::vector Ws) { - for (auto &W : Ws) - memcpy(jitTargetAddressToPointer(W.Address), - W.Buffer.data(), W.Buffer.size()); - }) - .release(); -} - -static llvm::orc::shared::detail::CWrapperFunctionResult -runAsMainWrapper(const char *ArgData, size_t ArgSize) { - return WrapperFunction::handle( - ArgData, ArgSize, - [](ExecutorAddress MainAddr, - std::vector Args) -> int64_t { - return runAsMain(MainAddr.toPtr(), Args); - }) - .release(); -} - SimpleRemoteEPCServer::Dispatcher::~Dispatcher() {} #if LLVM_ENABLE_THREADS @@ -137,27 +51,7 @@ void SimpleRemoteEPCServer::ThreadDispatcher::shutdown() { StringMap SimpleRemoteEPCServer::defaultBootstrapSymbols() { StringMap DBS; - - DBS["__llvm_orc_memory_reserve"] = ExecutorAddress::fromPtr(&reserveWrapper); - DBS["__llvm_orc_memory_finalize"] = - ExecutorAddress::fromPtr(&finalizeWrapper); - DBS["__llvm_orc_memory_deallocate"] = - ExecutorAddress::fromPtr(&deallocateWrapper); - DBS["__llvm_orc_memory_write_uint8s"] = ExecutorAddress::fromPtr( - &writeUIntsWrapper); - DBS["__llvm_orc_memory_write_uint16s"] = ExecutorAddress::fromPtr( - &writeUIntsWrapper); - DBS["__llvm_orc_memory_write_uint32s"] = ExecutorAddress::fromPtr( - &writeUIntsWrapper); - DBS["__llvm_orc_memory_write_uint64s"] = ExecutorAddress::fromPtr( - &writeUIntsWrapper); - DBS["__llvm_orc_memory_write_buffers"] = - ExecutorAddress::fromPtr(&writeBuffersWrapper); - DBS["__llvm_orc_run_as_main"] = ExecutorAddress::fromPtr(&runAsMainWrapper); + rt_bootstrap::addTo(DBS); DBS["__llvm_orc_load_dylib"] = ExecutorAddress::fromPtr(&loadDylibWrapper); DBS["__llvm_orc_lookup_symbols"] = ExecutorAddress::fromPtr(&lookupSymbolsWrapper); diff --git a/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp index 186aa75b4966c..9a0481c2b10e9 100644 --- a/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp @@ -9,6 +9,7 @@ #include "OrcTestCommon.h" #include "llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h" +#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" #include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h" #include "llvm/Support/Memory.h" #include "llvm/Testing/Support/Error.h" @@ -23,7 +24,7 @@ namespace { llvm::orc::shared::detail::CWrapperFunctionResult testReserve(const char *ArgData, size_t ArgSize) { - return WrapperFunction::handle( + return WrapperFunction::handle( ArgData, ArgSize, [](uint64_t Size) -> Expected { std::error_code EC; @@ -38,7 +39,7 @@ testReserve(const char *ArgData, size_t ArgSize) { llvm::orc::shared::detail::CWrapperFunctionResult testFinalize(const char *ArgData, size_t ArgSize) { - return WrapperFunction::handle( + return WrapperFunction::handle( ArgData, ArgSize, [](const tpctypes::FinalizeRequest &FR) -> Error { for (auto &Seg : FR) { @@ -61,7 +62,7 @@ testFinalize(const char *ArgData, size_t ArgSize) { llvm::orc::shared::detail::CWrapperFunctionResult testDeallocate(const char *ArgData, size_t ArgSize) { - return WrapperFunction::handle( + return WrapperFunction::handle( ArgData, ArgSize, [](ExecutorAddress Base, uint64_t Size) -> Error { sys::MemoryBlock MB(Base.toPtr(), Size);