From 9d62b78ea163d1c16307619442a728f8ca1c74d9 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Wed, 16 Jun 2021 21:58:26 +1000 Subject: [PATCH] [ORC] Switch from uint8_t to char buffers for TargetProcessControl::runWrapper. This matches WrapperFunctionResult's char buffer, cutting down on the number of pointer casts needed. --- .../ExecutionEngine/Orc/OrcRPCTargetProcessControl.h | 2 +- .../llvm/ExecutionEngine/Orc/Shared/Serialization.h | 5 +++++ .../Orc/TargetProcess/OrcRPCTPCServer.h | 10 ++++------ .../llvm/ExecutionEngine/Orc/TargetProcessControl.h | 9 +++------ lib/ExecutionEngine/Orc/TargetProcessControl.cpp | 5 ++--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h b/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h index 6ccc90e60b8..708612e838c 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h +++ b/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h @@ -356,7 +356,7 @@ public: Expected runWrapper(JITTargetAddress WrapperFnAddr, - ArrayRef ArgBuffer) override { + ArrayRef ArgBuffer) override { DEBUG_WITH_TYPE("orc", { dbgs() << "Running as wrapper function " << formatv("{0:x16}", WrapperFnAddr) << " with " diff --git a/include/llvm/ExecutionEngine/Orc/Shared/Serialization.h b/include/llvm/ExecutionEngine/Orc/Shared/Serialization.h index 0ea483ba2ab..849c947c18c 100644 --- a/include/llvm/ExecutionEngine/Orc/Shared/Serialization.h +++ b/include/llvm/ExecutionEngine/Orc/Shared/Serialization.h @@ -58,6 +58,11 @@ public: static const char *getName() { return "void"; } }; +template <> class SerializationTypeName { +public: + static const char *getName() { return "char"; } +}; + template <> class SerializationTypeName { public: static const char *getName() { return "int8_t"; } diff --git a/include/llvm/ExecutionEngine/Orc/TargetProcess/OrcRPCTPCServer.h b/include/llvm/ExecutionEngine/Orc/TargetProcess/OrcRPCTPCServer.h index 458947cc4d4..9be6093bcc4 100644 --- a/include/llvm/ExecutionEngine/Orc/TargetProcess/OrcRPCTPCServer.h +++ b/include/llvm/ExecutionEngine/Orc/TargetProcess/OrcRPCTPCServer.h @@ -358,7 +358,7 @@ public: class RunWrapper : public shared::RPCFunction)> { + JITTargetAddress, std::vector)> { public: static const char *getName() { return "RunWrapper"; } }; @@ -580,14 +580,12 @@ private: ProgramNameOverride); } - shared::WrapperFunctionResult - runWrapper(JITTargetAddress WrapperFnAddr, - const std::vector &ArgBuffer) { + shared::WrapperFunctionResult runWrapper(JITTargetAddress WrapperFnAddr, + const std::vector &ArgBuffer) { using WrapperFnTy = shared::detail::CWrapperFunctionResult (*)( const char *Data, uint64_t Size); auto *WrapperFn = jitTargetAddressToFunction(WrapperFnAddr); - return WrapperFn(reinterpret_cast(ArgBuffer.data()), - ArgBuffer.size()); + return WrapperFn(ArgBuffer.data(), ArgBuffer.size()); } void closeConnection() { Finished = true; } diff --git a/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h b/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h index edc7952519e..a39495f5382 100644 --- a/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h +++ b/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h @@ -145,7 +145,7 @@ public: /// \endcode{.cpp} /// virtual Expected - runWrapper(JITTargetAddress WrapperFnAddr, ArrayRef ArgBuffer) = 0; + runWrapper(JITTargetAddress WrapperFnAddr, ArrayRef ArgBuffer) = 0; /// Disconnect from the target process. /// @@ -170,9 +170,7 @@ public: : TPC(TPC), WrapperFnAddr(WrapperFnAddr) {} Expected operator()(const char *ArgData, size_t ArgSize) const { - return TPC.runWrapper( - WrapperFnAddr, - ArrayRef(reinterpret_cast(ArgData), ArgSize)); + return TPC.runWrapper(WrapperFnAddr, ArrayRef(ArgData, ArgSize)); } private: @@ -204,8 +202,7 @@ public: ArrayRef Args) override; Expected - runWrapper(JITTargetAddress WrapperFnAddr, - ArrayRef ArgBuffer) override; + runWrapper(JITTargetAddress WrapperFnAddr, ArrayRef ArgBuffer) override; Error disconnect() override; diff --git a/lib/ExecutionEngine/Orc/TargetProcessControl.cpp b/lib/ExecutionEngine/Orc/TargetProcessControl.cpp index 240adb41d62..bc5cff43bd9 100644 --- a/lib/ExecutionEngine/Orc/TargetProcessControl.cpp +++ b/lib/ExecutionEngine/Orc/TargetProcessControl.cpp @@ -104,12 +104,11 @@ SelfTargetProcessControl::runAsMain(JITTargetAddress MainFnAddr, Expected SelfTargetProcessControl::runWrapper(JITTargetAddress WrapperFnAddr, - ArrayRef ArgBuffer) { + ArrayRef ArgBuffer) { using WrapperFnTy = shared::detail::CWrapperFunctionResult (*)( const char *Data, uint64_t Size); auto *WrapperFn = jitTargetAddressToFunction(WrapperFnAddr); - return WrapperFn(reinterpret_cast(ArgBuffer.data()), - ArgBuffer.size()); + return WrapperFn(ArgBuffer.data(), ArgBuffer.size()); } Error SelfTargetProcessControl::disconnect() { return Error::success(); }