[ORC] Switch from JITTargetAddress to ExecutorAddr for EPC-call APIs.

Part of the ongoing move to ExecutorAddr.
This commit is contained in:
Lang Hames
2021-09-27 16:47:24 -07:00
parent 027c036663
commit 21a06254a3
19 changed files with 76 additions and 77 deletions

View File

@@ -1482,8 +1482,7 @@ public:
///
/// The given OnComplete function will be called to return the result.
void callWrapperAsync(ExecutorProcessControl::SendResultFunction OnComplete,
JITTargetAddress WrapperFnAddr,
ArrayRef<char> ArgBuffer) {
ExecutorAddr WrapperFnAddr, ArrayRef<char> ArgBuffer) {
EPC->callWrapperAsync(std::move(OnComplete), WrapperFnAddr, ArgBuffer);
}
@@ -1493,7 +1492,7 @@ public:
/// \code{.cpp}
/// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
/// \endcode{.cpp}
shared::WrapperFunctionResult callWrapper(JITTargetAddress WrapperFnAddr,
shared::WrapperFunctionResult callWrapper(ExecutorAddr WrapperFnAddr,
ArrayRef<char> ArgBuffer) {
return EPC->callWrapper(WrapperFnAddr, ArgBuffer);
}
@@ -1501,8 +1500,7 @@ public:
/// Run a wrapper function using SPS to serialize the arguments and
/// deserialize the results.
template <typename SPSSignature, typename SendResultT, typename... ArgTs>
void callSPSWrapperAsync(SendResultT &&SendResult,
JITTargetAddress WrapperFnAddr,
void callSPSWrapperAsync(SendResultT &&SendResult, ExecutorAddr WrapperFnAddr,
const ArgTs &...Args) {
EPC->callSPSWrapperAsync<SPSSignature, SendResultT, ArgTs...>(
std::forward<SendResultT>(SendResult), WrapperFnAddr, Args...);
@@ -1514,7 +1512,7 @@ public:
/// If SPSSignature is a non-void function signature then the second argument
/// (the first in the Args list) should be a reference to a return value.
template <typename SPSSignature, typename... WrapperCallArgTs>
Error callSPSWrapper(JITTargetAddress WrapperFnAddr,
Error callSPSWrapper(ExecutorAddr WrapperFnAddr,
WrapperCallArgTs &&...WrapperCallArgs) {
return EPC->callSPSWrapper<SPSSignature, WrapperCallArgTs...>(
WrapperFnAddr, std::forward<WrapperCallArgTs>(WrapperCallArgs)...);

View File

@@ -40,14 +40,14 @@ public:
/// executor process.
class EPCDebugObjectRegistrar : public DebugObjectRegistrar {
public:
EPCDebugObjectRegistrar(ExecutionSession &ES, JITTargetAddress RegisterFn)
EPCDebugObjectRegistrar(ExecutionSession &ES, ExecutorAddr RegisterFn)
: ES(ES), RegisterFn(RegisterFn) {}
Error registerDebugObject(sys::MemoryBlock TargetMem) override;
private:
ExecutionSession &ES;
JITTargetAddress RegisterFn;
ExecutorAddr RegisterFn;
};
/// Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug

View File

@@ -14,6 +14,7 @@
#define LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H
#include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
namespace llvm {
namespace orc {
@@ -33,8 +34,8 @@ public:
/// Create a EPCEHFrameRegistrar with the given ExecutorProcessControl
/// object and registration/deregistration function addresses.
EPCEHFrameRegistrar(ExecutionSession &ES,
JITTargetAddress RegisterEHFrameWrapperFnAddr,
JITTargetAddress DeregisterEHFRameWrapperFnAddr)
ExecutorAddr RegisterEHFrameWrapperFnAddr,
ExecutorAddr DeregisterEHFRameWrapperFnAddr)
: ES(ES), RegisterEHFrameWrapperFnAddr(RegisterEHFrameWrapperFnAddr),
DeregisterEHFrameWrapperFnAddr(DeregisterEHFRameWrapperFnAddr) {}
@@ -45,8 +46,8 @@ public:
private:
ExecutionSession &ES;
JITTargetAddress RegisterEHFrameWrapperFnAddr;
JITTargetAddress DeregisterEHFrameWrapperFnAddr;
ExecutorAddr RegisterEHFrameWrapperFnAddr;
ExecutorAddr DeregisterEHFrameWrapperFnAddr;
};
} // end namespace orc

View File

@@ -43,35 +43,35 @@ public:
WriteResultFn OnWriteComplete) override {
using namespace shared;
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt8Write>)>(
std::move(OnWriteComplete), FAs.WriteUInt8s.getValue(), Ws);
std::move(OnWriteComplete), FAs.WriteUInt8s, Ws);
}
void writeUInt16sAsync(ArrayRef<tpctypes::UInt16Write> Ws,
WriteResultFn OnWriteComplete) override {
using namespace shared;
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt16Write>)>(
std::move(OnWriteComplete), FAs.WriteUInt16s.getValue(), Ws);
std::move(OnWriteComplete), FAs.WriteUInt16s, Ws);
}
void writeUInt32sAsync(ArrayRef<tpctypes::UInt32Write> Ws,
WriteResultFn OnWriteComplete) override {
using namespace shared;
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt32Write>)>(
std::move(OnWriteComplete), FAs.WriteUInt32s.getValue(), Ws);
std::move(OnWriteComplete), FAs.WriteUInt32s, Ws);
}
void writeUInt64sAsync(ArrayRef<tpctypes::UInt64Write> Ws,
WriteResultFn OnWriteComplete) override {
using namespace shared;
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt64Write>)>(
std::move(OnWriteComplete), FAs.WriteUInt64s.getValue(), Ws);
std::move(OnWriteComplete), FAs.WriteUInt64s, Ws);
}
void writeBuffersAsync(ArrayRef<tpctypes::BufferWrite> Ws,
WriteResultFn OnWriteComplete) override {
using namespace shared;
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessBufferWrite>)>(
std::move(OnWriteComplete), FAs.WriteBuffers.getValue(), Ws);
std::move(OnWriteComplete), FAs.WriteBuffers, Ws);
}
private:

View File

@@ -196,7 +196,7 @@ public:
lookupSymbols(ArrayRef<LookupRequest> Request) = 0;
/// Run function with a main-like signature.
virtual Expected<int32_t> runAsMain(JITTargetAddress MainFnAddr,
virtual Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) = 0;
/// Run a wrapper function in the executor.
@@ -209,7 +209,7 @@ public:
///
/// The given OnComplete function will be called to return the result.
virtual void callWrapperAsync(SendResultFunction OnComplete,
JITTargetAddress WrapperFnAddr,
ExecutorAddr WrapperFnAddr,
ArrayRef<char> ArgBuffer) = 0;
/// Run a wrapper function in the executor. The wrapper function should be
@@ -218,7 +218,7 @@ public:
/// \code{.cpp}
/// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
/// \endcode{.cpp}
shared::WrapperFunctionResult callWrapper(JITTargetAddress WrapperFnAddr,
shared::WrapperFunctionResult callWrapper(ExecutorAddr WrapperFnAddr,
ArrayRef<char> ArgBuffer) {
std::promise<shared::WrapperFunctionResult> RP;
auto RF = RP.get_future();
@@ -231,8 +231,7 @@ public:
/// Run a wrapper function using SPS to serialize the arguments and
/// deserialize the results.
template <typename SPSSignature, typename SendResultT, typename... ArgTs>
void callSPSWrapperAsync(SendResultT &&SendResult,
JITTargetAddress WrapperFnAddr,
void callSPSWrapperAsync(SendResultT &&SendResult, ExecutorAddr WrapperFnAddr,
const ArgTs &...Args) {
shared::WrapperFunction<SPSSignature>::callAsync(
[this,
@@ -250,7 +249,7 @@ public:
/// If SPSSignature is a non-void function signature then the second argument
/// (the first in the Args list) should be a reference to a return value.
template <typename SPSSignature, typename... WrapperCallArgTs>
Error callSPSWrapper(JITTargetAddress WrapperFnAddr,
Error callSPSWrapper(ExecutorAddr WrapperFnAddr,
WrapperCallArgTs &&...WrapperCallArgs) {
return shared::WrapperFunction<SPSSignature>::call(
[this, WrapperFnAddr](const char *ArgData, size_t ArgSize) {
@@ -301,13 +300,13 @@ public:
llvm_unreachable("Unsupported");
}
Expected<int32_t> runAsMain(JITTargetAddress MainFnAddr,
Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) override {
llvm_unreachable("Unsupported");
}
void callWrapperAsync(SendResultFunction OnComplete,
JITTargetAddress WrapperFnAddr,
ExecutorAddr WrapperFnAddr,
ArrayRef<char> ArgBuffer) override {
llvm_unreachable("Unsupported");
}
@@ -338,11 +337,11 @@ public:
Expected<std::vector<tpctypes::LookupResult>>
lookupSymbols(ArrayRef<LookupRequest> Request) override;
Expected<int32_t> runAsMain(JITTargetAddress MainFnAddr,
Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) override;
void callWrapperAsync(SendResultFunction OnComplete,
JITTargetAddress WrapperFnAddr,
ExecutorAddr WrapperFnAddr,
ArrayRef<char> ArgBuffer) override;
Error disconnect() override;

View File

@@ -337,7 +337,7 @@ public:
return EP.template callB<orcrpctpc::LookupSymbols>(RR);
}
Expected<int32_t> runAsMain(JITTargetAddress MainFnAddr,
Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) override {
DEBUG_WITH_TYPE("orc", {
dbgs() << "Running as main: " << formatv("{0:x16}", MainFnAddr)
@@ -358,7 +358,7 @@ public:
}
void callWrapperAsync(SendResultFunction OnComplete,
JITTargetAddress WrapperFnAddr,
ExecutorAddr WrapperFnAddr,
ArrayRef<char> ArgBuffer) override {
DEBUG_WITH_TYPE("orc", {
dbgs() << "Running as wrapper function "
@@ -412,7 +412,7 @@ protected:
private:
Error runWrapperInJIT(
std::function<Error(Expected<shared::WrapperFunctionResult>)> SendResult,
JITTargetAddress FunctionTag, std::vector<uint8_t> ArgBuffer) {
ExecutorAddr FunctionTag, std::vector<uint8_t> ArgBuffer) {
getExecutionSession().runJITDispatchHandler(
[this, SendResult = std::move(SendResult)](

View File

@@ -58,11 +58,11 @@ public:
Expected<std::vector<tpctypes::LookupResult>>
lookupSymbols(ArrayRef<LookupRequest> Request) override;
Expected<int32_t> runAsMain(JITTargetAddress MainFnAddr,
Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) override;
void callWrapperAsync(SendResultFunction OnComplete,
JITTargetAddress WrapperFnAddr,
ExecutorAddr WrapperFnAddr,
ArrayRef<char> ArgBuffer) override;
Error disconnect() override;

View File

@@ -474,8 +474,7 @@ Error ELFNixPlatform::bootstrapELFNixRuntime(JITDylib &PlatformJD) {
KV.second->setValue((*RuntimeSymbolAddrs)[Name].getAddress());
}
if (auto Err = ES.callSPSWrapper<void()>(
orc_rt_elfnix_platform_bootstrap.getValue()))
if (auto Err = ES.callSPSWrapper<void()>(orc_rt_elfnix_platform_bootstrap))
return Err;
// FIXME: Ordering is fuzzy here. We're probably best off saying
@@ -543,7 +542,7 @@ Error ELFNixPlatform::registerPerObjectSections(
Error ErrResult = Error::success();
if (auto Err = ES.callSPSWrapper<shared::SPSError(
SPSELFPerObjectSectionsToRegister)>(
orc_rt_elfnix_register_object_sections.getValue(), ErrResult, POSR))
orc_rt_elfnix_register_object_sections, ErrResult, POSR))
return Err;
return ErrResult;
}
@@ -557,7 +556,7 @@ Expected<uint64_t> ELFNixPlatform::createPThreadKey() {
Expected<uint64_t> Result(0);
if (auto Err = ES.callSPSWrapper<SPSExpected<uint64_t>(void)>(
orc_rt_elfnix_create_pthread_key.getValue(), Result))
orc_rt_elfnix_create_pthread_key, Result))
return std::move(Err);
return Result;
}

View File

@@ -39,7 +39,8 @@ createJITLoaderGDBRegistrar(ExecutionSession &ES) {
assert((*Result)[0].size() == 1 &&
"Unexpected number of addresses in result");
return std::make_unique<EPCDebugObjectRegistrar>(ES, (*Result)[0][0]);
return std::make_unique<EPCDebugObjectRegistrar>(
ES, ExecutorAddr((*Result)[0][0]));
}
Error EPCDebugObjectRegistrar::registerDebugObject(sys::MemoryBlock TargetMem) {

View File

@@ -51,8 +51,9 @@ EPCEHFrameRegistrar::Create(ExecutionSession &ES) {
auto RegisterEHFrameWrapperFnAddr = (*Result)[0][0];
auto DeregisterEHFrameWrapperFnAddr = (*Result)[0][1];
return std::make_unique<EPCEHFrameRegistrar>(ES, RegisterEHFrameWrapperFnAddr,
DeregisterEHFrameWrapperFnAddr);
return std::make_unique<EPCEHFrameRegistrar>(
ES, ExecutorAddr(RegisterEHFrameWrapperFnAddr),
ExecutorAddr(DeregisterEHFrameWrapperFnAddr));
}
Error EPCEHFrameRegistrar::registerEHFrames(JITTargetAddress EHFrameSectionAddr,

View File

@@ -76,7 +76,7 @@ Expected<tpctypes::DylibHandle> EPCGenericDylibManager::open(StringRef Path,
Expected<tpctypes::DylibHandle> H(0);
if (auto Err =
EPC.callSPSWrapper<rt::SPSSimpleExecutorDylibManagerOpenSignature>(
SAs.Open.getValue(), H, SAs.Instance, Path, Mode))
SAs.Open, H, SAs.Instance, Path, Mode))
return std::move(Err);
return H;
}
@@ -87,7 +87,7 @@ EPCGenericDylibManager::lookup(tpctypes::DylibHandle H,
Expected<std::vector<ExecutorAddr>> Result((std::vector<ExecutorAddr>()));
if (auto Err =
EPC.callSPSWrapper<rt::SPSSimpleExecutorDylibManagerLookupSignature>(
SAs.Lookup.getValue(), Result, SAs.Instance, H, Lookup))
SAs.Lookup, Result, SAs.Instance, H, Lookup))
return std::move(Err);
return Result;
}
@@ -98,7 +98,7 @@ EPCGenericDylibManager::lookup(tpctypes::DylibHandle H,
Expected<std::vector<ExecutorAddr>> Result((std::vector<ExecutorAddr>()));
if (auto Err =
EPC.callSPSWrapper<rt::SPSSimpleExecutorDylibManagerLookupSignature>(
SAs.Lookup.getValue(), Result, SAs.Instance, H, Lookup))
SAs.Lookup, Result, SAs.Instance, H, Lookup))
return std::move(Err);
return Result;
}

View File

@@ -67,14 +67,14 @@ public:
else
OnFinalize(std::move(FinalizeErr));
},
Parent.SAs.Finalize.getValue(), Parent.SAs.Allocator, std::move(FR));
Parent.SAs.Finalize, Parent.SAs.Allocator, std::move(FR));
}
Error deallocate() override {
Error Err = Error::success();
if (auto E2 = Parent.EPC.callSPSWrapper<
rt::SPSSimpleExecutorMemoryManagerDeallocateSignature>(
Parent.SAs.Deallocate.getValue(), Err, Parent.SAs.Allocator,
Parent.SAs.Deallocate, Err, Parent.SAs.Allocator,
ArrayRef<ExecutorAddr>(TargetAddr)))
return E2;
return Err;
@@ -114,7 +114,7 @@ EPCGenericJITLinkMemoryManager::allocate(const jitlink::JITLinkDylib *JD,
Expected<ExecutorAddr> TargetAllocAddr((ExecutorAddr()));
if (auto Err = EPC.callSPSWrapper<
rt::SPSSimpleExecutorMemoryManagerReserveSignature>(
SAs.Reserve.getValue(), TargetAllocAddr, SAs.Allocator, AllocSize))
SAs.Reserve, TargetAllocAddr, SAs.Allocator, AllocSize))
return std::move(Err);
if (!TargetAllocAddr)
return TargetAllocAddr.takeError();

View File

@@ -49,7 +49,7 @@ EPCGenericRTDyldMemoryManager::~EPCGenericRTDyldMemoryManager() {
Error Err = Error::success();
if (auto Err2 = EPC.callSPSWrapper<
rt::SPSSimpleExecutorMemoryManagerDeallocateSignature>(
SAs.Reserve.getValue(), Err, SAs.Instance, FinalizedAllocs)) {
SAs.Reserve, Err, SAs.Instance, FinalizedAllocs)) {
// FIXME: Report errors through EPC once that functionality is available.
logAllUnhandledErrors(std::move(Err2), errs(), "");
return;
@@ -130,7 +130,7 @@ void EPCGenericRTDyldMemoryManager::reserveAllocationSpace(
Expected<ExecutorAddr> TargetAllocAddr((ExecutorAddr()));
if (auto Err = EPC.callSPSWrapper<
rt::SPSSimpleExecutorMemoryManagerReserveSignature>(
SAs.Reserve.getValue(), TargetAllocAddr, SAs.Instance, TotalSize)) {
SAs.Reserve, TargetAllocAddr, SAs.Instance, TotalSize)) {
std::lock_guard<std::mutex> Lock(M);
ErrMsg = toString(std::move(Err));
return;
@@ -270,8 +270,7 @@ bool EPCGenericRTDyldMemoryManager::finalizeMemory(std::string *ErrMsg) {
Error FinalizeErr = Error::success();
if (auto Err = EPC.callSPSWrapper<
rt::SPSSimpleExecutorMemoryManagerFinalizeSignature>(
SAs.Finalize.getValue(), FinalizeErr, SAs.Instance,
std::move(FR))) {
SAs.Finalize, FinalizeErr, SAs.Instance, std::move(FR))) {
std::lock_guard<std::mutex> Lock(M);
this->ErrMsg = toString(std::move(Err));
dbgs() << "Serialization error: " << this->ErrMsg << "\n";

View File

@@ -103,18 +103,18 @@ SelfExecutorProcessControl::lookupSymbols(ArrayRef<LookupRequest> Request) {
}
Expected<int32_t>
SelfExecutorProcessControl::runAsMain(JITTargetAddress MainFnAddr,
SelfExecutorProcessControl::runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) {
using MainTy = int (*)(int, char *[]);
return orc::runAsMain(jitTargetAddressToFunction<MainTy>(MainFnAddr), Args);
return orc::runAsMain(MainFnAddr.toPtr<MainTy>(), Args);
}
void SelfExecutorProcessControl::callWrapperAsync(
SendResultFunction SendResult, JITTargetAddress WrapperFnAddr,
ArrayRef<char> ArgBuffer) {
void SelfExecutorProcessControl::callWrapperAsync(SendResultFunction SendResult,
ExecutorAddr WrapperFnAddr,
ArrayRef<char> ArgBuffer) {
using WrapperFnTy =
shared::detail::CWrapperFunctionResult (*)(const char *Data, size_t Size);
auto *WrapperFn = jitTargetAddressToFunction<WrapperFnTy>(WrapperFnAddr);
auto *WrapperFn = WrapperFnAddr.toPtr<WrapperFnTy>();
SendResult(WrapperFn(ArgBuffer.data(), ArgBuffer.size()));
}

View File

@@ -508,8 +508,7 @@ Error MachOPlatform::bootstrapMachORuntime(JITDylib &PlatformJD) {
&orc_rt_macho_create_pthread_key}}))
return Err;
if (auto Err =
ES.callSPSWrapper<void()>(orc_rt_macho_platform_bootstrap.getValue()))
if (auto Err = ES.callSPSWrapper<void()>(orc_rt_macho_platform_bootstrap))
return Err;
// FIXME: Ordering is fuzzy here. We're probably best off saying
@@ -580,7 +579,7 @@ Error MachOPlatform::registerPerObjectSections(
Error ErrResult = Error::success();
if (auto Err = ES.callSPSWrapper<shared::SPSError(
SPSMachOPerObjectSectionsToRegister)>(
orc_rt_macho_register_object_sections.getValue(), ErrResult, POSR))
orc_rt_macho_register_object_sections, ErrResult, POSR))
return Err;
return ErrResult;
}
@@ -594,7 +593,7 @@ Expected<uint64_t> MachOPlatform::createPThreadKey() {
Expected<uint64_t> Result(0);
if (auto Err = ES.callSPSWrapper<SPSExpected<uint64_t>(void)>(
orc_rt_macho_create_pthread_key.getValue(), Result))
orc_rt_macho_create_pthread_key, Result))
return std::move(Err);
return Result;
}

View File

@@ -45,17 +45,17 @@ SimpleRemoteEPC::lookupSymbols(ArrayRef<LookupRequest> Request) {
return std::move(Result);
}
Expected<int32_t> SimpleRemoteEPC::runAsMain(JITTargetAddress MainFnAddr,
Expected<int32_t> SimpleRemoteEPC::runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) {
int64_t Result = 0;
if (auto Err = callSPSWrapper<rt::SPSRunAsMainSignature>(
RunAsMainAddr.getValue(), Result, ExecutorAddr(MainFnAddr), Args))
RunAsMainAddr, Result, ExecutorAddr(MainFnAddr), Args))
return std::move(Err);
return Result;
}
void SimpleRemoteEPC::callWrapperAsync(SendResultFunction OnComplete,
JITTargetAddress WrapperFnAddr,
ExecutorAddr WrapperFnAddr,
ArrayRef<char> ArgBuffer) {
uint64_t SeqNo;
{
@@ -66,7 +66,7 @@ void SimpleRemoteEPC::callWrapperAsync(SendResultFunction OnComplete,
}
if (auto Err = sendMessage(SimpleRemoteEPCOpcode::CallWrapper, SeqNo,
ExecutorAddr(WrapperFnAddr), ArgBuffer)) {
WrapperFnAddr, ArgBuffer)) {
getExecutionSession().reportError(std::move(Err));
}
}

View File

@@ -735,10 +735,11 @@ int main(int argc, char **argv, char * const *envp) {
// Grab the target address of the JIT'd main function on the remote and call
// it.
// FIXME: argv and envp handling.
JITTargetAddress Entry = EE->getFunctionAddress(EntryFn->getName().str());
auto Entry =
orc::ExecutorAddr(EE->getFunctionAddress(EntryFn->getName().str()));
EE->finalizeObject();
LLVM_DEBUG(dbgs() << "Executing '" << EntryFn->getName() << "' at 0x"
<< format("%llx", Entry) << "\n");
<< format("%llx", Entry.getValue()) << "\n");
Result = ExitOnErr(EPC->runAsMain(Entry, {}));
// Like static constructors, the remote target MCJIT support doesn't handle
@@ -1060,7 +1061,8 @@ int runOrcJIT(const char *ProgName) {
if (EPC) {
// ExecutorProcessControl-based execution with JITLink.
Result = ExitOnErr(EPC->runAsMain(MainSym.getAddress(), InputArgv));
Result = ExitOnErr(
EPC->runAsMain(orc::ExecutorAddr(MainSym.getAddress()), InputArgv));
} else {
// Manual in-process execution with RuntimeDyld.
using MainFnTy = int(int, char *[]);

View File

@@ -1336,8 +1336,7 @@ static Expected<JITEvaluatedSymbol> getOrcRuntimeEntryPoint(Session &S) {
return S.ES.lookup(S.JDSearchOrder, RuntimeEntryPoint);
}
static Expected<int> runWithRuntime(Session &S,
JITTargetAddress EntryPointAddress) {
static Expected<int> runWithRuntime(Session &S, ExecutorAddr EntryPointAddr) {
StringRef DemangledEntryPoint = EntryPointName;
const auto &TT = S.ES.getExecutorProcessControl().getTargetTriple();
if (TT.getObjectFormat() == Triple::MachO &&
@@ -1347,16 +1346,15 @@ static Expected<int> runWithRuntime(Session &S,
int64_t(SPSString, SPSString, SPSSequence<SPSString>);
int64_t Result;
if (auto Err = S.ES.callSPSWrapper<SPSRunProgramSig>(
EntryPointAddress, Result, S.MainJD->getName(), DemangledEntryPoint,
EntryPointAddr, Result, S.MainJD->getName(), DemangledEntryPoint,
static_cast<std::vector<std::string> &>(InputArgv)))
return std::move(Err);
return Result;
}
static Expected<int> runWithoutRuntime(Session &S,
JITTargetAddress EntryPointAddress) {
return S.ES.getExecutorProcessControl().runAsMain(EntryPointAddress,
InputArgv);
ExecutorAddr EntryPointAddr) {
return S.ES.getExecutorProcessControl().runAsMain(EntryPointAddr, InputArgv);
}
namespace {
@@ -1426,9 +1424,11 @@ int main(int argc, char *argv[]) {
LLVM_DEBUG(dbgs() << "Running \"" << EntryPointName << "\"...\n");
TimeRegion TR(Timers ? &Timers->RunTimer : nullptr);
if (!OrcRuntime.empty())
Result = ExitOnErr(runWithRuntime(*S, EntryPoint.getAddress()));
Result =
ExitOnErr(runWithRuntime(*S, ExecutorAddr(EntryPoint.getAddress())));
else
Result = ExitOnErr(runWithoutRuntime(*S, EntryPoint.getAddress()));
Result = ExitOnErr(
runWithoutRuntime(*S, ExecutorAddr(EntryPoint.getAddress())));
}
// Destroy the session.

View File

@@ -40,7 +40,7 @@ TEST(ExecutionSessionWrapperFunctionCalls, RunWrapperTemplate) {
int32_t Result;
EXPECT_THAT_ERROR(ES.callSPSWrapper<int32_t(int32_t, int32_t)>(
pointerToJITTargetAddress(addWrapper), Result, 2, 3),
ExecutorAddr::fromPtr(addWrapper), Result, 2, 3),
Succeeded());
EXPECT_EQ(Result, 5);
}
@@ -53,7 +53,7 @@ TEST(ExecutionSessionWrapperFunctionCalls, RunVoidWrapperAsyncTemplate) {
[&](Error SerializationErr) {
RP.set_value(std::move(SerializationErr));
},
pointerToJITTargetAddress(voidWrapper));
ExecutorAddr::fromPtr(voidWrapper));
Error Err = RP.get_future().get();
EXPECT_THAT_ERROR(std::move(Err), Succeeded());
}
@@ -68,7 +68,7 @@ TEST(ExecutionSessionWrapperFunctionCalls, RunNonVoidWrapperAsyncTemplate) {
RP.set_value(std::move(SerializationErr));
RP.set_value(std::move(R));
},
pointerToJITTargetAddress(addWrapper), 2, 3);
ExecutorAddr::fromPtr(addWrapper), 2, 3);
Expected<int32_t> Result = RP.get_future().get();
EXPECT_THAT_EXPECTED(Result, HasValue(5));
}