[ORC] Move CWrapperFunctionResult out of the detail:: namespace.

This type has been moved up into the llvm::orc::shared namespace.

This type was originally put in the detail:: namespace on the assumption that
few (if any) LLVM source files would need to use it. In practice it has been
needed in many places, and will continue to be needed until/unless
OrcTargetProcess is fully merged into the ORC runtime.
This commit is contained in:
Lang Hames 2021-10-30 15:43:21 -07:00
parent 2d48b19136
commit 213666f804
19 changed files with 58 additions and 63 deletions

View File

@ -456,7 +456,7 @@ private:
void writeBuffersAsync(ArrayRef<tpctypes::BufferWrite> Ws,
WriteResultFn OnWriteComplete) override;
static shared::detail::CWrapperFunctionResult
static shared::CWrapperFunctionResult
jitDispatchViaWrapperFunctionManager(void *Ctx, const void *FnTag,
const char *Data, size_t Size);

View File

@ -81,8 +81,8 @@ struct WrapperFunctionCall {
: Func(Func), ArgData(ArgData) {}
shared::WrapperFunctionResult run() {
using FnTy = shared::detail::CWrapperFunctionResult(const char *ArgData,
size_t ArgSize);
using FnTy =
shared::CWrapperFunctionResult(const char *ArgData, size_t ArgSize);
return shared::WrapperFunctionResult(
Func.toPtr<FnTy *>()(ArgData.Start.toPtr<const char *>(),
static_cast<size_t>(ArgData.size().getValue())));

View File

@ -23,24 +23,18 @@ namespace llvm {
namespace orc {
namespace shared {
namespace detail {
// DO NOT USE DIRECTLY.
// Must be kept in-sync with compiler-rt/lib/orc/c-api.h.
union CWrapperFunctionResultDataUnion {
char *ValuePtr;
char Value[sizeof(ValuePtr)];
};
// DO NOT USE DIRECTLY.
// Must be kept in-sync with compiler-rt/lib/orc/c-api.h.
typedef struct {
CWrapperFunctionResultDataUnion Data;
size_t Size;
} CWrapperFunctionResult;
} // end namespace detail
/// C++ wrapper function result: Same as CWrapperFunctionResult but
/// auto-releases memory.
class WrapperFunctionResult {
@ -49,11 +43,11 @@ public:
WrapperFunctionResult() { init(R); }
/// Create a WrapperFunctionResult by taking ownership of a
/// detail::CWrapperFunctionResult.
/// CWrapperFunctionResult.
///
/// Warning: This should only be used by clients writing wrapper-function
/// caller utilities (like TargetProcessControl).
WrapperFunctionResult(detail::CWrapperFunctionResult R) : R(R) {
WrapperFunctionResult(CWrapperFunctionResult R) : R(R) {
// Reset R.
init(R);
}
@ -78,12 +72,12 @@ public:
free(R.Data.ValuePtr);
}
/// Release ownership of the contained detail::CWrapperFunctionResult.
/// Release ownership of the contained CWrapperFunctionResult.
/// Warning: Do not use -- this method will be removed in the future. It only
/// exists to temporarily support some code that will eventually be moved to
/// the ORC runtime.
detail::CWrapperFunctionResult release() {
detail::CWrapperFunctionResult Tmp;
CWrapperFunctionResult release() {
CWrapperFunctionResult Tmp;
init(Tmp);
std::swap(R, Tmp);
return Tmp;
@ -164,12 +158,12 @@ public:
}
private:
static void init(detail::CWrapperFunctionResult &R) {
static void init(CWrapperFunctionResult &R) {
R.Data.ValuePtr = nullptr;
R.Size = 0;
}
detail::CWrapperFunctionResult R;
CWrapperFunctionResult R;
};
namespace detail {

View File

@ -16,7 +16,7 @@
#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
#include <cstdint>
extern "C" llvm::orc::shared::detail::CWrapperFunctionResult
extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_registerJITLoaderGDBWrapper(const char *Data, uint64_t Size);
#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_JITLOADERGDB_H

View File

@ -37,7 +37,7 @@ Error deregisterEHFrameSection(const void *EHFrameSectionAddr,
/// call. This function expects the direct address and size of the eh-frame
/// section to register as its arguments (it does not treat its arguments as
/// pointers to an SPS-serialized arg buffer).
extern "C" llvm::orc::shared::detail::CWrapperFunctionResult
extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_registerEHFrameSectionCustomDirectWrapper(
const char *EHFrameSectionAddr, uint64_t Size);
@ -45,14 +45,14 @@ llvm_orc_registerEHFrameSectionCustomDirectWrapper(
/// call. This function expects the direct address and size of the eh-frame
/// section to register as its arguments (it does not treat its arguments as
/// pointers to an SPS-serialized arg buffer).
extern "C" llvm::orc::shared::detail::CWrapperFunctionResult
extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_deregisterEHFrameSectionCustomDirectWrapper(
const char *EHFrameSectionAddr, uint64_t Size);
extern "C" llvm::orc::shared::detail::CWrapperFunctionResult
extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_registerEHFrameSectionWrapper(const char *Data, uint64_t Size);
extern "C" llvm::orc::shared::detail::CWrapperFunctionResult
extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_deregisterEHFrameSectionWrapper(const char *Data, uint64_t Size);
#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_REGISTEREHFRAMES_H

View File

@ -46,10 +46,10 @@ public:
private:
using DylibsMap = DenseMap<uint64_t, sys::DynamicLibrary>;
static llvm::orc::shared::detail::CWrapperFunctionResult
static llvm::orc::shared::CWrapperFunctionResult
openWrapper(const char *ArgData, size_t ArgSize);
static llvm::orc::shared::detail::CWrapperFunctionResult
static llvm::orc::shared::CWrapperFunctionResult
lookupWrapper(const char *ArgData, size_t ArgSize);
std::mutex M;

View File

@ -50,13 +50,13 @@ private:
Error deallocateImpl(void *Base, Allocation &A);
static llvm::orc::shared::detail::CWrapperFunctionResult
static llvm::orc::shared::CWrapperFunctionResult
reserveWrapper(const char *ArgData, size_t ArgSize);
static llvm::orc::shared::detail::CWrapperFunctionResult
static llvm::orc::shared::CWrapperFunctionResult
finalizeWrapper(const char *ArgData, size_t ArgSize);
static llvm::orc::shared::detail::CWrapperFunctionResult
static llvm::orc::shared::CWrapperFunctionResult
deallocateWrapper(const char *ArgData, size_t ArgSize);
std::mutex M;

View File

@ -151,9 +151,10 @@ private:
shared::WrapperFunctionResult
doJITDispatch(const void *FnTag, const char *ArgData, size_t ArgSize);
static shared::detail::CWrapperFunctionResult
jitDispatchEntry(void *DispatchCtx, const void *FnTag, const char *ArgData,
size_t ArgSize);
static shared::CWrapperFunctionResult jitDispatchEntry(void *DispatchCtx,
const void *FnTag,
const char *ArgData,
size_t ArgSize);
uint64_t getNextSeqNo() { return NextSeqNo++; }
void releaseSeqNo(uint64_t) {}

View File

@ -125,7 +125,7 @@ void SelfExecutorProcessControl::callWrapperAsync(ExecutorAddr WrapperFnAddr,
IncomingWFRHandler SendResult,
ArrayRef<char> ArgBuffer) {
using WrapperFnTy =
shared::detail::CWrapperFunctionResult (*)(const char *Data, size_t Size);
shared::CWrapperFunctionResult (*)(const char *Data, size_t Size);
auto *WrapperFn = WrapperFnAddr.toPtr<WrapperFnTy>();
SendResult(WrapperFn(ArgBuffer.data(), ArgBuffer.size()));
}
@ -170,7 +170,7 @@ void SelfExecutorProcessControl::writeBuffersAsync(
OnWriteComplete(Error::success());
}
shared::detail::CWrapperFunctionResult
shared::CWrapperFunctionResult
SelfExecutorProcessControl::jitDispatchViaWrapperFunctionManager(
void *Ctx, const void *FnTag, const char *Data, size_t Size) {

View File

@ -93,7 +93,7 @@ static void registerJITLoaderGDBImpl(ExecutorAddrRange DebugObjRange) {
__jit_debug_register_code();
}
extern "C" orc::shared::detail::CWrapperFunctionResult
extern "C" orc::shared::CWrapperFunctionResult
llvm_orc_registerJITLoaderGDBWrapper(const char *Data, uint64_t Size) {
using namespace orc::shared;
return WrapperFunction<void(SPSExecutorAddrRange)>::handle(

View File

@ -22,7 +22,7 @@ namespace orc {
namespace rt_bootstrap {
template <typename WriteT, typename SPSWriteT>
static llvm::orc::shared::detail::CWrapperFunctionResult
static llvm::orc::shared::CWrapperFunctionResult
writeUIntsWrapper(const char *ArgData, size_t ArgSize) {
return WrapperFunction<void(SPSSequence<SPSWriteT>)>::handle(
ArgData, ArgSize,
@ -33,7 +33,7 @@ writeUIntsWrapper(const char *ArgData, size_t ArgSize) {
.release();
}
static llvm::orc::shared::detail::CWrapperFunctionResult
static llvm::orc::shared::CWrapperFunctionResult
writeBuffersWrapper(const char *ArgData, size_t ArgSize) {
return WrapperFunction<void(SPSSequence<SPSMemoryAccessBufferWrite>)>::handle(
ArgData, ArgSize,
@ -45,7 +45,7 @@ writeBuffersWrapper(const char *ArgData, size_t ArgSize) {
.release();
}
static llvm::orc::shared::detail::CWrapperFunctionResult
static llvm::orc::shared::CWrapperFunctionResult
runAsMainWrapper(const char *ArgData, size_t ArgSize) {
return WrapperFunction<rt::SPSRunAsMainSignature>::handle(
ArgData, ArgSize,

View File

@ -158,22 +158,22 @@ Error deregisterEHFrameSection(const void *EHFrameSectionAddr,
} // end namespace orc
} // end namespace llvm
extern "C" llvm::orc::shared::detail::CWrapperFunctionResult
extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_registerEHFrameSectionCustomDirectWrapper(
const char *EHFrameSectionAddr, uint64_t Size) {
if (auto Err = registerEHFrameSection(EHFrameSectionAddr, Size))
return WrapperFunctionResult::createOutOfBandError(toString(std::move(Err)))
.release();
return llvm::orc::shared::detail::CWrapperFunctionResult();
return llvm::orc::shared::CWrapperFunctionResult();
}
extern "C" llvm::orc::shared::detail::CWrapperFunctionResult
extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_deregisterEHFrameSectionCustomDirectWrapper(
const char *EHFrameSectionAddr, uint64_t Size) {
if (auto Err = deregisterEHFrameSection(EHFrameSectionAddr, Size))
return WrapperFunctionResult::createOutOfBandError(toString(std::move(Err)))
.release();
return llvm::orc::shared::detail::CWrapperFunctionResult();
return llvm::orc::shared::CWrapperFunctionResult();
}
static Error registerEHFrameWrapper(ExecutorAddr Addr, uint64_t Size) {
@ -184,14 +184,14 @@ static Error deregisterEHFrameWrapper(ExecutorAddr Addr, uint64_t Size) {
return llvm::orc::deregisterEHFrameSection(Addr.toPtr<const void *>(), Size);
}
extern "C" orc::shared::detail::CWrapperFunctionResult
extern "C" orc::shared::CWrapperFunctionResult
llvm_orc_registerEHFrameSectionWrapper(const char *Data, uint64_t Size) {
return WrapperFunction<SPSError(SPSExecutorAddr, uint64_t)>::handle(
Data, Size, registerEHFrameWrapper)
.release();
}
extern "C" orc::shared::detail::CWrapperFunctionResult
extern "C" orc::shared::CWrapperFunctionResult
llvm_orc_deregisterEHFrameSectionWrapper(const char *Data, uint64_t Size) {
return WrapperFunction<SPSError(SPSExecutorAddr, uint64_t)>::handle(
Data, Size, deregisterEHFrameWrapper)

View File

@ -104,7 +104,7 @@ void SimpleExecutorDylibManager::addBootstrapSymbols(
ExecutorAddr::fromPtr(&lookupWrapper);
}
llvm::orc::shared::detail::CWrapperFunctionResult
llvm::orc::shared::CWrapperFunctionResult
SimpleExecutorDylibManager::openWrapper(const char *ArgData, size_t ArgSize) {
return shared::
WrapperFunction<rt::SPSSimpleExecutorDylibManagerOpenSignature>::handle(
@ -114,7 +114,7 @@ SimpleExecutorDylibManager::openWrapper(const char *ArgData, size_t ArgSize) {
.release();
}
llvm::orc::shared::detail::CWrapperFunctionResult
llvm::orc::shared::CWrapperFunctionResult
SimpleExecutorDylibManager::lookupWrapper(const char *ArgData, size_t ArgSize) {
return shared::
WrapperFunction<rt::SPSSimpleExecutorDylibManagerLookupSignature>::handle(

View File

@ -223,7 +223,7 @@ Error SimpleExecutorMemoryManager::deallocateImpl(void *Base, Allocation &A) {
return Err;
}
llvm::orc::shared::detail::CWrapperFunctionResult
llvm::orc::shared::CWrapperFunctionResult
SimpleExecutorMemoryManager::reserveWrapper(const char *ArgData,
size_t ArgSize) {
return shared::WrapperFunction<
@ -234,7 +234,7 @@ SimpleExecutorMemoryManager::reserveWrapper(const char *ArgData,
.release();
}
llvm::orc::shared::detail::CWrapperFunctionResult
llvm::orc::shared::CWrapperFunctionResult
SimpleExecutorMemoryManager::finalizeWrapper(const char *ArgData,
size_t ArgSize) {
return shared::WrapperFunction<
@ -245,7 +245,7 @@ SimpleExecutorMemoryManager::finalizeWrapper(const char *ArgData,
.release();
}
llvm::orc::shared::detail::CWrapperFunctionResult
llvm::orc::shared::CWrapperFunctionResult
SimpleExecutorMemoryManager::deallocateWrapper(const char *ArgData,
size_t ArgSize) {
return shared::WrapperFunction<

View File

@ -246,7 +246,7 @@ void SimpleRemoteEPCServer::handleCallWrapper(
SimpleRemoteEPCArgBytesVector ArgBytes) {
D->dispatch([this, RemoteSeqNo, TagAddr, ArgBytes = std::move(ArgBytes)]() {
using WrapperFnTy =
shared::detail::CWrapperFunctionResult (*)(const char *, size_t);
shared::CWrapperFunctionResult (*)(const char *, size_t);
auto *Fn = TagAddr.toPtr<WrapperFnTy>();
shared::WrapperFunctionResult ResultBytes(
Fn(ArgBytes.data(), ArgBytes.size()));
@ -281,7 +281,7 @@ SimpleRemoteEPCServer::doJITDispatch(const void *FnTag, const char *ArgData,
return ResultF.get();
}
shared::detail::CWrapperFunctionResult
shared::CWrapperFunctionResult
SimpleRemoteEPCServer::jitDispatchEntry(void *DispatchCtx, const void *FnTag,
const char *ArgData, size_t ArgSize) {
return reinterpret_cast<SimpleRemoteEPCServer *>(DispatchCtx)

View File

@ -78,24 +78,24 @@ private:
DenseMap<void *, sys::OwningMemoryBlock> Blocks;
};
llvm::orc::shared::detail::CWrapperFunctionResult
testReserve(const char *ArgData, size_t ArgSize) {
llvm::orc::shared::CWrapperFunctionResult testReserve(const char *ArgData,
size_t ArgSize) {
return WrapperFunction<rt::SPSSimpleExecutorMemoryManagerReserveSignature>::
handle(ArgData, ArgSize,
makeMethodWrapperHandler(&SimpleAllocator::reserve))
.release();
}
llvm::orc::shared::detail::CWrapperFunctionResult
testFinalize(const char *ArgData, size_t ArgSize) {
llvm::orc::shared::CWrapperFunctionResult testFinalize(const char *ArgData,
size_t ArgSize) {
return WrapperFunction<rt::SPSSimpleExecutorMemoryManagerFinalizeSignature>::
handle(ArgData, ArgSize,
makeMethodWrapperHandler(&SimpleAllocator::finalize))
.release();
}
llvm::orc::shared::detail::CWrapperFunctionResult
testDeallocate(const char *ArgData, size_t ArgSize) {
llvm::orc::shared::CWrapperFunctionResult testDeallocate(const char *ArgData,
size_t ArgSize) {
return WrapperFunction<
rt::SPSSimpleExecutorMemoryManagerDeallocateSignature>::
handle(ArgData, ArgSize,

View File

@ -18,8 +18,8 @@ using namespace llvm::orc::shared;
namespace {
template <typename WriteT, typename SPSWriteT>
llvm::orc::shared::detail::CWrapperFunctionResult
testWriteUInts(const char *ArgData, size_t ArgSize) {
llvm::orc::shared::CWrapperFunctionResult testWriteUInts(const char *ArgData,
size_t ArgSize) {
return WrapperFunction<void(SPSSequence<SPSWriteT>)>::handle(
ArgData, ArgSize,
[](std::vector<WriteT> Ws) {
@ -29,8 +29,8 @@ testWriteUInts(const char *ArgData, size_t ArgSize) {
.release();
}
llvm::orc::shared::detail::CWrapperFunctionResult
testWriteBuffers(const char *ArgData, size_t ArgSize) {
llvm::orc::shared::CWrapperFunctionResult testWriteBuffers(const char *ArgData,
size_t ArgSize) {
return WrapperFunction<void(SPSSequence<SPSMemoryAccessBufferWrite>)>::handle(
ArgData, ArgSize,
[](std::vector<tpctypes::BufferWrite> Ws) {

View File

@ -18,8 +18,8 @@ using namespace llvm;
using namespace llvm::orc;
using namespace llvm::orc::shared;
static llvm::orc::shared::detail::CWrapperFunctionResult
addWrapper(const char *ArgData, size_t ArgSize) {
static llvm::orc::shared::CWrapperFunctionResult addWrapper(const char *ArgData,
size_t ArgSize) {
return WrapperFunction<int32_t(int32_t, int32_t)>::handle(
ArgData, ArgSize, [](int32_t X, int32_t Y) { return X + Y; })
.release();
@ -30,7 +30,7 @@ static void addAsyncWrapper(unique_function<void(int32_t)> SendResult,
SendResult(X + Y);
}
static llvm::orc::shared::detail::CWrapperFunctionResult
static llvm::orc::shared::CWrapperFunctionResult
voidWrapper(const char *ArgData, size_t ArgSize) {
return WrapperFunction<void()>::handle(ArgData, ArgSize, []() {}).release();
}

View File

@ -20,8 +20,8 @@ using namespace llvm::orc::rt_bootstrap;
namespace {
orc::shared::detail::CWrapperFunctionResult
incrementWrapper(const char *ArgData, size_t ArgSize) {
orc::shared::CWrapperFunctionResult incrementWrapper(const char *ArgData,
size_t ArgSize) {
return WrapperFunction<void(SPSExecutorAddr)>::handle(
ArgData, ArgSize, [](ExecutorAddr A) { *A.toPtr<int *>() += 1; })
.release();