[llvm] da7f993 - [ORC] Reorder callWrapperAsync and callSPSWrapperAsync parameters.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 10 13:15:36 PDT 2021
Author: Lang Hames
Date: 2021-10-10T13:10:43-07:00
New Revision: da7f993a8d615c7306d3576f9669eb4d0a4b65f4
URL: https://github.com/llvm/llvm-project/commit/da7f993a8d615c7306d3576f9669eb4d0a4b65f4
DIFF: https://github.com/llvm/llvm-project/commit/da7f993a8d615c7306d3576f9669eb4d0a4b65f4.diff
LOG: [ORC] Reorder callWrapperAsync and callSPSWrapperAsync parameters.
The callee address is now the first parameter and the 'SendResult' function
the second. This change improves consistentency with the non-async functions
where the callee is the first address and the return value the second.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/Core.h
llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp
llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.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 7c5cb8235f248..a40c78fafdf5e 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -1481,9 +1481,10 @@ class ExecutionSession {
/// \endcode{.cpp}
///
/// The given OnComplete function will be called to return the result.
- void callWrapperAsync(ExecutorProcessControl::SendResultFunction OnComplete,
- ExecutorAddr WrapperFnAddr, ArrayRef<char> ArgBuffer) {
- EPC->callWrapperAsync(std::move(OnComplete), WrapperFnAddr, ArgBuffer);
+ void callWrapperAsync(ExecutorAddr WrapperFnAddr,
+ ExecutorProcessControl::SendResultFunction OnComplete,
+ ArrayRef<char> ArgBuffer) {
+ EPC->callWrapperAsync(WrapperFnAddr, std::move(OnComplete), ArgBuffer);
}
/// Run a wrapper function in the executor. The wrapper function should be
@@ -1500,10 +1501,10 @@ 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, ExecutorAddr WrapperFnAddr,
+ void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult,
const ArgTs &...Args) {
EPC->callSPSWrapperAsync<SPSSignature, SendResultT, ArgTs...>(
- std::forward<SendResultT>(SendResult), WrapperFnAddr, Args...);
+ WrapperFnAddr, std::forward<SendResultT>(SendResult), Args...);
}
/// Run a wrapper function using SPS to serialize the arguments and
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
index 929d05635782e..8c1d457d06ab3 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, Ws);
+ FAs.WriteUInt8s, std::move(OnWriteComplete), Ws);
}
void writeUInt16sAsync(ArrayRef<tpctypes::UInt16Write> Ws,
WriteResultFn OnWriteComplete) override {
using namespace shared;
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt16Write>)>(
- std::move(OnWriteComplete), FAs.WriteUInt16s, Ws);
+ FAs.WriteUInt16s, std::move(OnWriteComplete), Ws);
}
void writeUInt32sAsync(ArrayRef<tpctypes::UInt32Write> Ws,
WriteResultFn OnWriteComplete) override {
using namespace shared;
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt32Write>)>(
- std::move(OnWriteComplete), FAs.WriteUInt32s, Ws);
+ FAs.WriteUInt32s, std::move(OnWriteComplete), Ws);
}
void writeUInt64sAsync(ArrayRef<tpctypes::UInt64Write> Ws,
WriteResultFn OnWriteComplete) override {
using namespace shared;
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt64Write>)>(
- std::move(OnWriteComplete), FAs.WriteUInt64s, Ws);
+ FAs.WriteUInt64s, std::move(OnWriteComplete), Ws);
}
void writeBuffersAsync(ArrayRef<tpctypes::BufferWrite> Ws,
WriteResultFn OnWriteComplete) override {
using namespace shared;
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessBufferWrite>)>(
- std::move(OnWriteComplete), FAs.WriteBuffers, Ws);
+ FAs.WriteBuffers, std::move(OnWriteComplete), Ws);
}
private:
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
index acd1f03dc26a5..7e05bef6acc8b 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
@@ -207,8 +207,8 @@ class ExecutorProcessControl {
/// \endcode{.cpp}
///
/// The given OnComplete function will be called to return the result.
- virtual void callWrapperAsync(SendResultFunction OnComplete,
- ExecutorAddr WrapperFnAddr,
+ virtual void callWrapperAsync(ExecutorAddr WrapperFnAddr,
+ SendResultFunction OnComplete,
ArrayRef<char> ArgBuffer) = 0;
/// Run a wrapper function in the executor. The wrapper function should be
@@ -222,21 +222,22 @@ class ExecutorProcessControl {
std::promise<shared::WrapperFunctionResult> RP;
auto RF = RP.get_future();
callWrapperAsync(
+ WrapperFnAddr,
[&](shared::WrapperFunctionResult R) { RP.set_value(std::move(R)); },
- WrapperFnAddr, ArgBuffer);
+ ArgBuffer);
return RF.get();
}
/// 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, ExecutorAddr WrapperFnAddr,
+ void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult,
const ArgTs &...Args) {
shared::WrapperFunction<SPSSignature>::callAsync(
[this,
WrapperFnAddr](ExecutorProcessControl::SendResultFunction SendResult,
const char *ArgData, size_t ArgSize) {
- callWrapperAsync(std::move(SendResult), WrapperFnAddr,
+ callWrapperAsync(WrapperFnAddr, std::move(SendResult),
ArrayRef<char>(ArgData, ArgSize));
},
std::move(SendResult), Args...);
@@ -304,8 +305,8 @@ class UnsupportedExecutorProcessControl : public ExecutorProcessControl {
llvm_unreachable("Unsupported");
}
- void callWrapperAsync(SendResultFunction OnComplete,
- ExecutorAddr WrapperFnAddr,
+ void callWrapperAsync(ExecutorAddr WrapperFnAddr,
+ SendResultFunction OnComplete,
ArrayRef<char> ArgBuffer) override {
llvm_unreachable("Unsupported");
}
@@ -339,8 +340,8 @@ class SelfExecutorProcessControl
Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) override;
- void callWrapperAsync(SendResultFunction OnComplete,
- ExecutorAddr WrapperFnAddr,
+ void callWrapperAsync(ExecutorAddr WrapperFnAddr,
+ SendResultFunction OnComplete,
ArrayRef<char> ArgBuffer) override;
Error disconnect() override;
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
index ff5eff212ee66..a4b5ca83febe8 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
@@ -61,8 +61,8 @@ class SimpleRemoteEPC : public ExecutorProcessControl,
Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
ArrayRef<std::string> Args) override;
- void callWrapperAsync(SendResultFunction OnComplete,
- ExecutorAddr WrapperFnAddr,
+ void callWrapperAsync(ExecutorAddr WrapperFnAddr,
+ SendResultFunction OnComplete,
ArrayRef<char> ArgBuffer) override;
Error disconnect() override;
diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
index 01853ee7f066a..e57f910e35cd3 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
@@ -60,6 +60,7 @@ class EPCGenericJITLinkMemoryManager::Alloc
}
Parent.EPC.callSPSWrapperAsync<
rt::SPSSimpleExecutorMemoryManagerFinalizeSignature>(
+ Parent.SAs.Finalize,
[OnFinalize = std::move(OnFinalize)](Error SerializationErr,
Error FinalizeErr) {
if (SerializationErr)
@@ -67,7 +68,7 @@ class EPCGenericJITLinkMemoryManager::Alloc
else
OnFinalize(std::move(FinalizeErr));
},
- Parent.SAs.Finalize, Parent.SAs.Allocator, std::move(FR));
+ Parent.SAs.Allocator, std::move(FR));
}
Error deallocate() override {
diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp
index 2262afe65c3f2..dd57fbd82612d 100644
--- a/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp
@@ -109,8 +109,8 @@ SelfExecutorProcessControl::runAsMain(ExecutorAddr MainFnAddr,
return orc::runAsMain(MainFnAddr.toPtr<MainTy>(), Args);
}
-void SelfExecutorProcessControl::callWrapperAsync(SendResultFunction SendResult,
- ExecutorAddr WrapperFnAddr,
+void SelfExecutorProcessControl::callWrapperAsync(ExecutorAddr WrapperFnAddr,
+ SendResultFunction SendResult,
ArrayRef<char> ArgBuffer) {
using WrapperFnTy =
shared::detail::CWrapperFunctionResult (*)(const char *Data, size_t Size);
diff --git a/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp b/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
index 2bf8bbf949b66..31886294d3ab0 100644
--- a/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
@@ -54,8 +54,8 @@ Expected<int32_t> SimpleRemoteEPC::runAsMain(ExecutorAddr MainFnAddr,
return Result;
}
-void SimpleRemoteEPC::callWrapperAsync(SendResultFunction OnComplete,
- ExecutorAddr WrapperFnAddr,
+void SimpleRemoteEPC::callWrapperAsync(ExecutorAddr WrapperFnAddr,
+ SendResultFunction OnComplete,
ArrayRef<char> ArgBuffer) {
uint64_t SeqNo;
{
diff --git a/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
index c1535bc74b2cc..ab9489d8fc007 100644
--- a/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
@@ -49,11 +49,10 @@ TEST(ExecutionSessionWrapperFunctionCalls, RunVoidWrapperAsyncTemplate) {
ExecutionSession ES(cantFail(SelfExecutorProcessControl::Create()));
std::promise<MSVCPError> RP;
- ES.callSPSWrapperAsync<void()>(
- [&](Error SerializationErr) {
- RP.set_value(std::move(SerializationErr));
- },
- ExecutorAddr::fromPtr(voidWrapper));
+ ES.callSPSWrapperAsync<void()>(ExecutorAddr::fromPtr(voidWrapper),
+ [&](Error SerializationErr) {
+ RP.set_value(std::move(SerializationErr));
+ });
Error Err = RP.get_future().get();
EXPECT_THAT_ERROR(std::move(Err), Succeeded());
}
@@ -63,12 +62,13 @@ TEST(ExecutionSessionWrapperFunctionCalls, RunNonVoidWrapperAsyncTemplate) {
std::promise<MSVCPExpected<int32_t>> RP;
ES.callSPSWrapperAsync<int32_t(int32_t, int32_t)>(
+ ExecutorAddr::fromPtr(addWrapper),
[&](Error SerializationErr, int32_t R) {
if (SerializationErr)
RP.set_value(std::move(SerializationErr));
RP.set_value(std::move(R));
},
- ExecutorAddr::fromPtr(addWrapper), 2, 3);
+ 2, 3);
Expected<int32_t> Result = RP.get_future().get();
EXPECT_THAT_EXPECTED(Result, HasValue(5));
}
More information about the llvm-commits
mailing list