From 4b6eb0e63c698094db5506763df44cc83c19f643 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 20 Mar 2022 12:40:34 +0100 Subject: Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-14-init-10186-gff7f2cfa959b. PR: 261742 MFC after: 2 weeks (cherry picked from commit 349cc55c9796c4596a5b9904cd3281af295f878f) --- .../ExecutionEngine/Orc/ExecutorProcessControl.cpp | 72 +++++++++++++--------- 1 file changed, 43 insertions(+), 29 deletions(-) (limited to 'contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp') diff --git a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp index 7d86d125d1db..2eb835551adb 100644 --- a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp +++ b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp @@ -24,20 +24,22 @@ ExecutorProcessControl::MemoryAccess::~MemoryAccess() {} ExecutorProcessControl::~ExecutorProcessControl() {} SelfExecutorProcessControl::SelfExecutorProcessControl( - std::shared_ptr SSP, Triple TargetTriple, - unsigned PageSize, std::unique_ptr MemMgr) - : ExecutorProcessControl(std::move(SSP)) { + std::shared_ptr SSP, std::unique_ptr D, + Triple TargetTriple, unsigned PageSize, + std::unique_ptr MemMgr) + : ExecutorProcessControl(std::move(SSP), std::move(D)) { OwnedMemMgr = std::move(MemMgr); if (!OwnedMemMgr) - OwnedMemMgr = std::make_unique(); + OwnedMemMgr = std::make_unique( + sys::Process::getPageSizeEstimate()); this->TargetTriple = std::move(TargetTriple); this->PageSize = PageSize; this->MemMgr = OwnedMemMgr.get(); this->MemAccess = this; - this->JDI = {ExecutorAddress::fromPtr(jitDispatchViaWrapperFunctionManager), - ExecutorAddress::fromPtr(this)}; + this->JDI = {ExecutorAddr::fromPtr(jitDispatchViaWrapperFunctionManager), + ExecutorAddr::fromPtr(this)}; if (this->TargetTriple.isOSBinFormatMachO()) GlobalManglingPrefix = '_'; } @@ -45,11 +47,20 @@ SelfExecutorProcessControl::SelfExecutorProcessControl( Expected> SelfExecutorProcessControl::Create( std::shared_ptr SSP, + std::unique_ptr D, std::unique_ptr MemMgr) { if (!SSP) SSP = std::make_shared(); + if (!D) { +#if LLVM_ENABLE_THREADS + D = std::make_unique(); +#else + D = std::make_unique(); +#endif + } + auto PageSize = sys::Process::getPageSize(); if (!PageSize) return PageSize.takeError(); @@ -57,7 +68,8 @@ SelfExecutorProcessControl::Create( Triple TT(sys::getProcessTriple()); return std::make_unique( - std::move(SSP), std::move(TT), *PageSize, std::move(MemMgr)); + std::move(SSP), std::move(D), std::move(TT), *PageSize, + std::move(MemMgr)); } Expected @@ -93,7 +105,7 @@ SelfExecutorProcessControl::lookupSymbols(ArrayRef Request) { // FIXME: Collect all failing symbols before erroring out. SymbolNameVector MissingSymbols; MissingSymbols.push_back(Sym); - return make_error(std::move(MissingSymbols)); + return make_error(SSP, std::move(MissingSymbols)); } R.back().push_back(pointerToJITTargetAddress(Addr)); } @@ -103,60 +115,62 @@ SelfExecutorProcessControl::lookupSymbols(ArrayRef Request) { } Expected -SelfExecutorProcessControl::runAsMain(JITTargetAddress MainFnAddr, +SelfExecutorProcessControl::runAsMain(ExecutorAddr MainFnAddr, ArrayRef Args) { using MainTy = int (*)(int, char *[]); - return orc::runAsMain(jitTargetAddressToFunction(MainFnAddr), Args); + return orc::runAsMain(MainFnAddr.toPtr(), Args); } -void SelfExecutorProcessControl::callWrapperAsync( - SendResultFunction SendResult, JITTargetAddress WrapperFnAddr, - ArrayRef ArgBuffer) { +void SelfExecutorProcessControl::callWrapperAsync(ExecutorAddr WrapperFnAddr, + IncomingWFRHandler SendResult, + ArrayRef ArgBuffer) { using WrapperFnTy = - shared::detail::CWrapperFunctionResult (*)(const char *Data, size_t Size); - auto *WrapperFn = jitTargetAddressToFunction(WrapperFnAddr); + shared::CWrapperFunctionResult (*)(const char *Data, size_t Size); + auto *WrapperFn = WrapperFnAddr.toPtr(); SendResult(WrapperFn(ArgBuffer.data(), ArgBuffer.size())); } -Error SelfExecutorProcessControl::disconnect() { return Error::success(); } +Error SelfExecutorProcessControl::disconnect() { + D->shutdown(); + return Error::success(); +} -void SelfExecutorProcessControl::writeUInt8s(ArrayRef Ws, - WriteResultFn OnWriteComplete) { +void SelfExecutorProcessControl::writeUInt8sAsync( + ArrayRef Ws, WriteResultFn OnWriteComplete) { for (auto &W : Ws) - *jitTargetAddressToPointer(W.Address) = W.Value; + *W.Addr.toPtr() = W.Value; OnWriteComplete(Error::success()); } -void SelfExecutorProcessControl::writeUInt16s( +void SelfExecutorProcessControl::writeUInt16sAsync( ArrayRef Ws, WriteResultFn OnWriteComplete) { for (auto &W : Ws) - *jitTargetAddressToPointer(W.Address) = W.Value; + *W.Addr.toPtr() = W.Value; OnWriteComplete(Error::success()); } -void SelfExecutorProcessControl::writeUInt32s( +void SelfExecutorProcessControl::writeUInt32sAsync( ArrayRef Ws, WriteResultFn OnWriteComplete) { for (auto &W : Ws) - *jitTargetAddressToPointer(W.Address) = W.Value; + *W.Addr.toPtr() = W.Value; OnWriteComplete(Error::success()); } -void SelfExecutorProcessControl::writeUInt64s( +void SelfExecutorProcessControl::writeUInt64sAsync( ArrayRef Ws, WriteResultFn OnWriteComplete) { for (auto &W : Ws) - *jitTargetAddressToPointer(W.Address) = W.Value; + *W.Addr.toPtr() = W.Value; OnWriteComplete(Error::success()); } -void SelfExecutorProcessControl::writeBuffers( +void SelfExecutorProcessControl::writeBuffersAsync( ArrayRef Ws, WriteResultFn OnWriteComplete) { for (auto &W : Ws) - memcpy(jitTargetAddressToPointer(W.Address), W.Buffer.data(), - W.Buffer.size()); + memcpy(W.Addr.toPtr(), W.Buffer.data(), W.Buffer.size()); OnWriteComplete(Error::success()); } -shared::detail::CWrapperFunctionResult +shared::CWrapperFunctionResult SelfExecutorProcessControl::jitDispatchViaWrapperFunctionManager( void *Ctx, const void *FnTag, const char *Data, size_t Size) { -- cgit v1.2.3