[llvm] 21a0625 - [ORC] Switch from JITTargetAddress to ExecutorAddr for EPC-call APIs.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 27 16:55:44 PDT 2021
Author: Lang Hames
Date: 2021-09-27T16:53:09-07:00
New Revision: 21a06254a3acb162b61a3452bdc939276290723b
URL: https://github.com/llvm/llvm-project/commit/21a06254a3acb162b61a3452bdc939276290723b
DIFF: https://github.com/llvm/llvm-project/commit/21a06254a3acb162b61a3452bdc939276290723b.diff
LOG: [ORC] Switch from JITTargetAddress to ExecutorAddr for EPC-call APIs.
Part of the ongoing move to ExecutorAddr.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/Core.h
llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h
llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
llvm/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h
llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp
llvm/lib/ExecutionEngine/Orc/EPCGenericDylibManager.cpp
llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp
llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp
llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
llvm/tools/lli/lli.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
index 4583f84b51d71..7c5cb8235f248 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -1482,8 +1482,7 @@ class ExecutionSession {
///
/// 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 @@ class ExecutionSession {
/// \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 @@ class ExecutionSession {
/// 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 @@ class ExecutionSession {
/// 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)...);
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
index 410a202b32964..05ecb14dc79ea 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
@@ -40,14 +40,14 @@ class DebugObjectRegistrar {
/// 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
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h
index 8cd6e9319a287..6d113a7bdf1a4 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h
@@ -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 @@ class EPCEHFrameRegistrar : public jitlink::EHFrameRegistrar {
/// 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 @@ class EPCEHFrameRegistrar : public jitlink::EHFrameRegistrar {
private:
ExecutionSession &ES;
- JITTargetAddress RegisterEHFrameWrapperFnAddr;
- JITTargetAddress DeregisterEHFrameWrapperFnAddr;
+ ExecutorAddr RegisterEHFrameWrapperFnAddr;
+ ExecutorAddr DeregisterEHFrameWrapperFnAddr;
};
} // end namespace orc
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
index 98dcadb970c42..929d05635782e 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
@@ -43,35 +43,35 @@ class EPCGenericMemoryAccess : public ExecutorProcessControl::MemoryAccess {
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:
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
index 01d031c6744d5..3b481a07c97fb 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
@@ -196,7 +196,7 @@ class ExecutorProcessControl {
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 @@ class ExecutorProcessControl {
///
/// 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 @@ class ExecutorProcessControl {
/// \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 @@ class ExecutorProcessControl {
/// 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 @@ class ExecutorProcessControl {
/// 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 @@ class UnsupportedExecutorProcessControl : public ExecutorProcessControl {
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 @@ class SelfExecutorProcessControl
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;
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h b/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h
index 1e28c098e7516..f2d72c00a612d 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h
@@ -337,7 +337,7 @@ class OrcRPCExecutorProcessControlBase : public ExecutorProcessControl {
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 @@ class OrcRPCExecutorProcessControlBase : public ExecutorProcessControl {
}
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 @@ class OrcRPCExecutorProcessControlBase : public ExecutorProcessControl {
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)](
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
index 4fc7a58f6350a..ff5eff212ee66 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
@@ -58,11 +58,11 @@ class SimpleRemoteEPC : public ExecutorProcessControl,
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;
diff --git a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
index c18c1635b8d5f..94499de305495 100644
--- a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
@@ -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;
}
diff --git a/llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp b/llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
index d35508b875a07..e1639a82b5d96 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
@@ -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) {
diff --git a/llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp b/llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp
index f893e86196704..4e0323b9ca0d1 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp
@@ -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,
diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericDylibManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericDylibManager.cpp
index 273e805bd864e..6c47c5c5f7bbf 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCGenericDylibManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericDylibManager.cpp
@@ -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;
}
diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
index e12b812d2f0b2..01853ee7f066a 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
@@ -67,14 +67,14 @@ class EPCGenericJITLinkMemoryManager::Alloc
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();
diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp
index cb5e72493a380..944b66422a24f 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp
@@ -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";
diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp
index c138ea378e27d..2262afe65c3f2 100644
--- a/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp
@@ -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()));
}
diff --git a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
index 65fe5b6b543aa..1705010df3462 100644
--- a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
@@ -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;
}
diff --git a/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp b/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
index 9f6ecce1eee23..2bf8bbf949b66 100644
--- a/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
@@ -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));
}
}
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 6f75c75a47dc6..385ba2ab736e8 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -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 *[]);
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 2e4b9cfc0d7f7..37870b3ec42be 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -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.
diff --git a/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
index c30275d87ad38..c1535bc74b2cc 100644
--- a/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
@@ -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));
}
More information about the llvm-commits
mailing list