Skip to content

Commit 8201ae2

Browse files
committed
[ORC] Provide default MemoryAccess in SimpleRemoteEPC, add WritePointers impl.
Make EPCGenericMemoryAccess the default implementation for the MemoryAccess object in SimpleRemoteEPC, and add support for the WritePointers operation to OrcTargetProcess (previously this operation was unimplemented and would have triggered an error if accessed in a remote-JIT setup). No testcase yet: This functionality requires cross-process JITing to test (or a much more elaborate unit-test setup). It can be tested once the new top-level ORC runtime project lands.
1 parent 9ccde12 commit 8201ae2

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ extern const char *MemoryWriteUInt16sWrapperName;
4242
extern const char *MemoryWriteUInt32sWrapperName;
4343
extern const char *MemoryWriteUInt64sWrapperName;
4444
extern const char *MemoryWriteBuffersWrapperName;
45+
extern const char *MemoryWritePointersWrapperName;
4546

4647
extern const char *RegisterEHFrameSectionWrapperName;
4748
extern const char *DeregisterEHFrameSectionWrapperName;

llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const char *MemoryWriteUInt64sWrapperName =
4949
"__llvm_orc_bootstrap_mem_write_uint64s_wrapper";
5050
const char *MemoryWriteBuffersWrapperName =
5151
"__llvm_orc_bootstrap_mem_write_buffers_wrapper";
52+
const char *MemoryWritePointersWrapperName =
53+
"__llvm_orc_bootstrap_mem_write_pointers_wrapper";
5254

5355
const char *RegisterEHFrameSectionWrapperName =
5456
"llvm_orc_registerEHFrameSectionWrapper";

llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,17 @@ SimpleRemoteEPC::createDefaultMemoryManager(SimpleRemoteEPC &SREPC) {
227227

228228
Expected<std::unique_ptr<ExecutorProcessControl::MemoryAccess>>
229229
SimpleRemoteEPC::createDefaultMemoryAccess(SimpleRemoteEPC &SREPC) {
230-
return nullptr;
230+
EPCGenericMemoryAccess::FuncAddrs FAs;
231+
if (auto Err = SREPC.getBootstrapSymbols(
232+
{{FAs.WriteUInt8s, rt::MemoryWriteUInt8sWrapperName},
233+
{FAs.WriteUInt16s, rt::MemoryWriteUInt16sWrapperName},
234+
{FAs.WriteUInt32s, rt::MemoryWriteUInt32sWrapperName},
235+
{FAs.WriteUInt64s, rt::MemoryWriteUInt64sWrapperName},
236+
{FAs.WriteBuffers, rt::MemoryWriteBuffersWrapperName},
237+
{FAs.WritePointers, rt::MemoryWritePointersWrapperName}}))
238+
return std::move(Err);
239+
240+
return std::make_unique<EPCGenericMemoryAccess>(SREPC, FAs);
231241
}
232242

233243
Error SimpleRemoteEPC::sendMessage(SimpleRemoteEPCOpcode OpC, uint64_t SeqNo,

llvm/lib/ExecutionEngine/Orc/TargetProcess/OrcRTBootstrap.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ writeBuffersWrapper(const char *ArgData, size_t ArgSize) {
4545
.release();
4646
}
4747

48+
static llvm::orc::shared::CWrapperFunctionResult
49+
writePointersWrapper(const char *ArgData, size_t ArgSize) {
50+
return WrapperFunction<void(SPSSequence<SPSMemoryAccessPointerWrite>)>::
51+
handle(ArgData, ArgSize,
52+
[](std::vector<tpctypes::PointerWrite> Ws) {
53+
for (auto &W : Ws)
54+
*W.Addr.template toPtr<void **>() =
55+
W.Value.template toPtr<void *>();
56+
})
57+
.release();
58+
}
59+
4860
static llvm::orc::shared::CWrapperFunctionResult
4961
runAsMainWrapper(const char *ArgData, size_t ArgSize) {
5062
return WrapperFunction<rt::SPSRunAsMainSignature>::handle(
@@ -92,6 +104,8 @@ void addTo(StringMap<ExecutorAddr> &M) {
92104
shared::SPSMemoryAccessUInt64Write>);
93105
M[rt::MemoryWriteBuffersWrapperName] =
94106
ExecutorAddr::fromPtr(&writeBuffersWrapper);
107+
M[rt::MemoryWritePointersWrapperName] =
108+
ExecutorAddr::fromPtr(&writePointersWrapper);
95109
M[rt::RegisterEHFrameSectionWrapperName] =
96110
ExecutorAddr::fromPtr(&llvm_orc_registerEHFrameSectionWrapper);
97111
M[rt::DeregisterEHFrameSectionWrapperName] =

0 commit comments

Comments
 (0)