From: Lang Hames Date: Sun, 10 Oct 2021 19:56:37 +0000 (-0700) Subject: [ORC] Reorder callWrapperAsync and callSPSWrapperAsync parameters. X-Git-Tag: upstream/15.0.7~29042 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da7f993a8d615c7306d3576f9669eb4d0a4b65f4;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h index 7c5cb82..a40c78f 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -1481,9 +1481,10 @@ public: /// \endcode{.cpp} /// /// The given OnComplete function will be called to return the result. - void callWrapperAsync(ExecutorProcessControl::SendResultFunction OnComplete, - ExecutorAddr WrapperFnAddr, ArrayRef ArgBuffer) { - EPC->callWrapperAsync(std::move(OnComplete), WrapperFnAddr, ArgBuffer); + void callWrapperAsync(ExecutorAddr WrapperFnAddr, + ExecutorProcessControl::SendResultFunction OnComplete, + ArrayRef ArgBuffer) { + EPC->callWrapperAsync(WrapperFnAddr, std::move(OnComplete), ArgBuffer); } /// Run a wrapper function in the executor. The wrapper function should be @@ -1500,10 +1501,10 @@ public: /// Run a wrapper function using SPS to serialize the arguments and /// deserialize the results. template - void callSPSWrapperAsync(SendResultT &&SendResult, ExecutorAddr WrapperFnAddr, + void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args) { EPC->callSPSWrapperAsync( - std::forward(SendResult), WrapperFnAddr, Args...); + WrapperFnAddr, std::forward(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 929d056..8c1d457 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h @@ -43,35 +43,35 @@ public: WriteResultFn OnWriteComplete) override { using namespace shared; EPC.callSPSWrapperAsync)>( - std::move(OnWriteComplete), FAs.WriteUInt8s, Ws); + FAs.WriteUInt8s, std::move(OnWriteComplete), Ws); } void writeUInt16sAsync(ArrayRef Ws, WriteResultFn OnWriteComplete) override { using namespace shared; EPC.callSPSWrapperAsync)>( - std::move(OnWriteComplete), FAs.WriteUInt16s, Ws); + FAs.WriteUInt16s, std::move(OnWriteComplete), Ws); } void writeUInt32sAsync(ArrayRef Ws, WriteResultFn OnWriteComplete) override { using namespace shared; EPC.callSPSWrapperAsync)>( - std::move(OnWriteComplete), FAs.WriteUInt32s, Ws); + FAs.WriteUInt32s, std::move(OnWriteComplete), Ws); } void writeUInt64sAsync(ArrayRef Ws, WriteResultFn OnWriteComplete) override { using namespace shared; EPC.callSPSWrapperAsync)>( - std::move(OnWriteComplete), FAs.WriteUInt64s, Ws); + FAs.WriteUInt64s, std::move(OnWriteComplete), Ws); } void writeBuffersAsync(ArrayRef Ws, WriteResultFn OnWriteComplete) override { using namespace shared; EPC.callSPSWrapperAsync)>( - 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 acd1f03..7e05bef 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h @@ -207,8 +207,8 @@ public: /// \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 ArgBuffer) = 0; /// Run a wrapper function in the executor. The wrapper function should be @@ -222,21 +222,22 @@ public: std::promise 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 - void callSPSWrapperAsync(SendResultT &&SendResult, ExecutorAddr WrapperFnAddr, + void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args) { shared::WrapperFunction::callAsync( [this, WrapperFnAddr](ExecutorProcessControl::SendResultFunction SendResult, const char *ArgData, size_t ArgSize) { - callWrapperAsync(std::move(SendResult), WrapperFnAddr, + callWrapperAsync(WrapperFnAddr, std::move(SendResult), ArrayRef(ArgData, ArgSize)); }, std::move(SendResult), Args...); @@ -304,8 +305,8 @@ public: llvm_unreachable("Unsupported"); } - void callWrapperAsync(SendResultFunction OnComplete, - ExecutorAddr WrapperFnAddr, + void callWrapperAsync(ExecutorAddr WrapperFnAddr, + SendResultFunction OnComplete, ArrayRef ArgBuffer) override { llvm_unreachable("Unsupported"); } @@ -339,8 +340,8 @@ public: Expected runAsMain(ExecutorAddr MainFnAddr, ArrayRef Args) override; - void callWrapperAsync(SendResultFunction OnComplete, - ExecutorAddr WrapperFnAddr, + void callWrapperAsync(ExecutorAddr WrapperFnAddr, + SendResultFunction OnComplete, ArrayRef ArgBuffer) override; Error disconnect() override; diff --git a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h index ff5eff2..a4b5ca8 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h @@ -61,8 +61,8 @@ public: Expected runAsMain(ExecutorAddr MainFnAddr, ArrayRef Args) override; - void callWrapperAsync(SendResultFunction OnComplete, - ExecutorAddr WrapperFnAddr, + void callWrapperAsync(ExecutorAddr WrapperFnAddr, + SendResultFunction OnComplete, ArrayRef ArgBuffer) override; Error disconnect() override; diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp index 01853ee..e57f910 100644 --- a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp @@ -60,6 +60,7 @@ public: } Parent.EPC.callSPSWrapperAsync< rt::SPSSimpleExecutorMemoryManagerFinalizeSignature>( + Parent.SAs.Finalize, [OnFinalize = std::move(OnFinalize)](Error SerializationErr, Error FinalizeErr) { if (SerializationErr) @@ -67,7 +68,7 @@ public: 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 2262afe..dd57fbd 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(), Args); } -void SelfExecutorProcessControl::callWrapperAsync(SendResultFunction SendResult, - ExecutorAddr WrapperFnAddr, +void SelfExecutorProcessControl::callWrapperAsync(ExecutorAddr WrapperFnAddr, + SendResultFunction SendResult, ArrayRef 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 2bf8bbf..3188629 100644 --- a/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp +++ b/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp @@ -54,8 +54,8 @@ Expected SimpleRemoteEPC::runAsMain(ExecutorAddr MainFnAddr, return Result; } -void SimpleRemoteEPC::callWrapperAsync(SendResultFunction OnComplete, - ExecutorAddr WrapperFnAddr, +void SimpleRemoteEPC::callWrapperAsync(ExecutorAddr WrapperFnAddr, + SendResultFunction OnComplete, ArrayRef ArgBuffer) { uint64_t SeqNo; { diff --git a/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp index c1535bc..ab9489d 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 RP; - ES.callSPSWrapperAsync( - [&](Error SerializationErr) { - RP.set_value(std::move(SerializationErr)); - }, - ExecutorAddr::fromPtr(voidWrapper)); + ES.callSPSWrapperAsync(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> RP; ES.callSPSWrapperAsync( + 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 Result = RP.get_future().get(); EXPECT_THAT_EXPECTED(Result, HasValue(5)); }