[PATCH] D132369: [Orc] Use MapperJITLinkMemoryManager with SharedMemoryMapper in llvm-jitlink tool
Anubhab Ghosh via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 22 04:35:33 PDT 2022
argentite created this revision.
Herald added a project: All.
argentite added reviewers: lhames, sgraenitz.
argentite published this revision for review.
Herald added subscribers: llvm-commits, StephenFan.
Herald added a project: LLVM.
MapperJITLinkMemoryManager combined with SharedMemoryMapper can be
used in place of EPCGenericJITLinkMemoryManager. This commit enables
it when using pipes to communicate with executor.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132369
Files:
llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
Index: llvm/tools/llvm-jitlink/llvm-jitlink.cpp
===================================================================
--- llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -26,7 +26,9 @@
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
+#include "llvm/ExecutionEngine/Orc/MapperJITLinkMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/ObjectFileInterface.h"
+#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
#include "llvm/MC/MCAsmInfo.h"
@@ -729,6 +731,30 @@
return ExitOnErr(InProcessMemoryManager::Create());
}
+Expected<std::unique_ptr<jitlink::JITLinkMemoryManager>>
+createSharedMemoryManager(SimpleRemoteEPC &SREPC) {
+ SharedMemoryMapper::SymbolAddrs SAs;
+ if (auto Err = SREPC.getBootstrapSymbols(
+ {{SAs.Instance, rt::ExecutorSharedMemoryMapperServiceInstanceName},
+ {SAs.Reserve,
+ rt::ExecutorSharedMemoryMapperServiceReserveWrapperName},
+ {SAs.Initialize,
+ rt::ExecutorSharedMemoryMapperServiceInitializeWrapperName},
+ {SAs.Deinitialize,
+ rt::ExecutorSharedMemoryMapperServiceDeinitializeWrapperName},
+ {SAs.Release,
+ rt::ExecutorSharedMemoryMapperServiceReleaseWrapperName}}))
+ return std::move(Err);
+
+ size_t SlabSize = 64 * 1024;
+
+ if (!SlabAllocateSizeString.empty())
+ SlabSize = ExitOnErr(getSlabAllocSize(SlabAllocateSizeString));
+
+ return MapperJITLinkMemoryManager::CreateWithMapper<SharedMemoryMapper>(
+ SlabSize, SREPC, SAs);
+}
+
static Expected<MaterializationUnit::Interface>
getTestObjectFileInterface(Session &S, MemoryBufferRef O) {
@@ -885,9 +911,12 @@
close(ToExecutor[ReadEnd]);
close(FromExecutor[WriteEnd]);
+ auto S = SimpleRemoteEPC::Setup();
+ S.CreateMemoryManager = createSharedMemoryManager;
+
return SimpleRemoteEPC::Create<FDSimpleRemoteEPCTransport>(
- std::make_unique<DynamicThreadPoolTaskDispatcher>(),
- SimpleRemoteEPC::Setup(), FromExecutor[ReadEnd], ToExecutor[WriteEnd]);
+ std::make_unique<DynamicThreadPoolTaskDispatcher>(), std::move(S),
+ FromExecutor[ReadEnd], ToExecutor[WriteEnd]);
#endif
}
Index: llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
===================================================================
--- llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
+++ llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h"
@@ -164,6 +165,9 @@
SimpleRemoteEPCServer::defaultBootstrapSymbols();
S.services().push_back(
std::make_unique<rt_bootstrap::SimpleExecutorMemoryManager>());
+ S.services().push_back(
+ std::make_unique<
+ rt_bootstrap::ExecutorSharedMemoryMapperService>());
return Error::success();
},
InFD, OutFD));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132369.454447.patch
Type: text/x-patch
Size: 3589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220822/5cfd888a/attachment.bin>
More information about the llvm-commits
mailing list