[llvm] 8a36750 - [ORC] Handle void and no-argument async wrapper calls.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 18 19:22:11 PDT 2021
Author: Lang Hames
Date: 2021-08-19T12:20:31+10:00
New Revision: 8a3675023693093d9f00157d09dda504c999439a
URL: https://github.com/llvm/llvm-project/commit/8a3675023693093d9f00157d09dda504c999439a
DIFF: https://github.com/llvm/llvm-project/commit/8a3675023693093d9f00157d09dda504c999439a.diff
LOG: [ORC] Handle void and no-argument async wrapper calls.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h
llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h
index e92f580668c6e..d1d7d540b7ce3 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h
@@ -547,6 +547,18 @@ class WrapperFunction<void(SPSTagTs...)>
return WrapperFunction<SPSEmpty(SPSTagTs...)>::call(Caller, BE, Args...);
}
+ template <typename AsyncCallerFn, typename SendDeserializedResultFn,
+ typename... ArgTs>
+ static void callAsync(AsyncCallerFn &&Caller,
+ SendDeserializedResultFn &&SendDeserializedResult,
+ const ArgTs &...Args) {
+ WrapperFunction<SPSEmpty(SPSTagTs...)>::callAsync(
+ Caller,
+ [SDR = std::move(SendDeserializedResult)](
+ Error SerializeErr, SPSEmpty E) { SDR(std::move(SerializeErr)); },
+ Args...);
+ }
+
using WrapperFunction<SPSEmpty(SPSTagTs...)>::handle;
using WrapperFunction<SPSEmpty(SPSTagTs...)>::handleAsync;
};
diff --git a/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
index 9044ead631826..39554e2a82aa7 100644
--- a/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
@@ -30,6 +30,11 @@ static void addAsyncWrapper(unique_function<void(int32_t)> SendResult,
SendResult(X + Y);
}
+static llvm::orc::shared::detail::CWrapperFunctionResult
+voidWrapper(const char *ArgData, size_t ArgSize) {
+ return WrapperFunction<void()>::handle(ArgData, ArgSize, []() {}).release();
+}
+
TEST(ExecutionSessionWrapperFunctionCalls, RunWrapperTemplate) {
ExecutionSession ES(cantFail(SelfExecutorProcessControl::Create()));
@@ -40,12 +45,24 @@ TEST(ExecutionSessionWrapperFunctionCalls, RunWrapperTemplate) {
EXPECT_EQ(Result, 5);
}
-TEST(ExecutionSessionWrapperFunctionCalls, RunWrapperAsyncTemplate) {
+TEST(ExecutionSessionWrapperFunctionCalls, RunVoidWrapperAsyncTemplate) {
+ ExecutionSession ES(cantFail(SelfExecutorProcessControl::Create()));
+
+ std::promise<MSVCPError> RP;
+ ES.callSPSWrapperAsync<void()>(
+ [&](Error SerializationErr) {
+ RP.set_value(std::move(SerializationErr));
+ },
+ pointerToJITTargetAddress(voidWrapper));
+ Error Err = RP.get_future().get();
+ EXPECT_THAT_ERROR(std::move(Err), Succeeded());
+}
+
+TEST(ExecutionSessionWrapperFunctionCalls, RunNonVoidWrapperAsyncTemplate) {
ExecutionSession ES(cantFail(SelfExecutorProcessControl::Create()));
std::promise<MSVCPExpected<int32_t>> RP;
- using Sig = int32_t(int32_t, int32_t);
- ES.callSPSWrapperAsync<Sig>(
+ ES.callSPSWrapperAsync<int32_t(int32_t, int32_t)>(
[&](Error SerializationErr, int32_t R) {
if (SerializationErr)
RP.set_value(std::move(SerializationErr));
More information about the llvm-commits
mailing list