Skip to content

Commit 666540c

Browse files
committed
[ORC] Swap handleAsync handler and send-result arguments.
Placing the handler argument last improves readability when passing a lambda value (the common case for this API).
1 parent 1dffe8f commit 666540c

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

llvm/include/llvm/ExecutionEngine/Orc/Core.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,11 +1653,11 @@ class ExecutionSession {
16531653
/// (using registerJITDispatchHandler) and called from the executor.
16541654
template <typename SPSSignature, typename HandlerT>
16551655
static JITDispatchHandlerFunction wrapAsyncWithSPS(HandlerT &&H) {
1656-
return [H = std::forward<HandlerT>(H)](
1657-
SendResultFunction SendResult,
1658-
const char *ArgData, size_t ArgSize) mutable {
1659-
shared::WrapperFunction<SPSSignature>::handleAsync(ArgData, ArgSize, H,
1660-
std::move(SendResult));
1656+
return [H = std::forward<HandlerT>(H)](SendResultFunction SendResult,
1657+
const char *ArgData,
1658+
size_t ArgSize) mutable {
1659+
shared::WrapperFunction<SPSSignature>::handleAsync(
1660+
ArgData, ArgSize, std::move(SendResult), H);
16611661
};
16621662
}
16631663

llvm/include/llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ class WrapperFunction<SPSRetTagT(SPSTagTs...)> {
527527
/// Handle a call to an async wrapper function.
528528
template <typename HandlerT, typename SendResultT>
529529
static void handleAsync(const char *ArgData, size_t ArgSize,
530-
HandlerT &&Handler, SendResultT &&SendResult) {
530+
SendResultT &&SendResult, HandlerT &&Handler) {
531531
using WFAHH = detail::WrapperFunctionAsyncHandlerHelper<
532532
std::remove_reference_t<HandlerT>, ResultSerializer, SPSTagTs...>;
533533
WFAHH::applyAsync(std::forward<HandlerT>(Handler),

llvm/unittests/ExecutionEngine/Orc/WrapperFunctionUtilsTest.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ static WrapperFunctionResult voidNoopAsyncWrapper(const char *ArgData,
118118
auto RF = RP.get_future();
119119

120120
WrapperFunction<void()>::handleAsync(
121-
ArgData, ArgSize, voidNoopAsync,
122-
[&](WrapperFunctionResult R) { RP.set_value(std::move(R)); });
121+
ArgData, ArgSize,
122+
[&](WrapperFunctionResult R) { RP.set_value(std::move(R)); },
123+
voidNoopAsync);
123124

124125
return RF.get();
125126
}
@@ -131,10 +132,10 @@ static WrapperFunctionResult addAsyncWrapper(const char *ArgData,
131132

132133
WrapperFunction<int32_t(int32_t, int32_t)>::handleAsync(
133134
ArgData, ArgSize,
135+
[&](WrapperFunctionResult R) { RP.set_value(std::move(R)); },
134136
[](unique_function<void(int32_t)> SendResult, int32_t X, int32_t Y) {
135137
SendResult(X + Y);
136-
},
137-
[&](WrapperFunctionResult R) { RP.set_value(std::move(R)); });
138+
});
138139
return RF.get();
139140
}
140141

0 commit comments

Comments
 (0)