[llvm] [orc-rt] Enable SPS transparent conversion for reference arguments. (PR #162563)
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 15:54:00 PDT 2025
https://github.com/lhames updated https://github.com/llvm/llvm-project/pull/162563
>From 2c0288728032bc53a3d935553e4b7f840cb3fedc Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Thu, 9 Oct 2025 09:48:12 +1100
Subject: [PATCH] [orc-rt] Enable SPS transparent conversion for reference
arguments.
Ensures that SPS transparent conversion will apply to arguments passed by
reference.
---
orc-rt/include/orc-rt/SPSWrapperFunction.h | 3 ++-
orc-rt/unittests/SPSWrapperFunctionTest.cpp | 11 +++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/orc-rt/include/orc-rt/SPSWrapperFunction.h b/orc-rt/include/orc-rt/SPSWrapperFunction.h
index 5cf387345e6ba..c48694c6d2bfc 100644
--- a/orc-rt/include/orc-rt/SPSWrapperFunction.h
+++ b/orc-rt/include/orc-rt/SPSWrapperFunction.h
@@ -102,7 +102,8 @@ template <typename... SPSArgTs> struct WFSPSHelper {
public:
template <typename... ArgTs>
std::optional<WrapperFunctionBuffer> serialize(ArgTs &&...Args) {
- return serializeImpl(Serializable<ArgTs>::to(std::forward<ArgTs>(Args))...);
+ return serializeImpl(
+ Serializable<std::decay_t<ArgTs>>::to(std::forward<ArgTs>(Args))...);
}
template <typename ArgTuple>
diff --git a/orc-rt/unittests/SPSWrapperFunctionTest.cpp b/orc-rt/unittests/SPSWrapperFunctionTest.cpp
index 654d86ef26081..d0f06e8d31451 100644
--- a/orc-rt/unittests/SPSWrapperFunctionTest.cpp
+++ b/orc-rt/unittests/SPSWrapperFunctionTest.cpp
@@ -190,6 +190,17 @@ TEST(SPSWrapperFunctionUtilsTest, TransparentConversionPointers) {
EXPECT_EQ(P, &X);
}
+TEST(SPSWrapperFunctionUtilsTest, TransparentConversionReferenceArguments) {
+ int X = 42;
+ int *P = nullptr;
+ SPSWrapperFunction<SPSExecutorAddr(SPSExecutorAddr)>::call(
+ DirectCaller(nullptr, round_trip_int_pointer_sps_wrapper),
+ [&](Expected<int32_t *> R) { P = cantFail(std::move(R)); },
+ static_cast<int *const &>(&X));
+
+ EXPECT_EQ(P, &X);
+}
+
static void
expected_int_pointer_sps_wrapper(orc_rt_SessionRef Session, void *CallCtx,
orc_rt_WrapperFunctionReturn Return,
More information about the llvm-commits
mailing list