diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp --- a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp +++ b/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()); + S.services().push_back( + std::make_unique< + rt_bootstrap::ExecutorSharedMemoryMapperService>()); return Error::success(); }, InFD, OutFD)); diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/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> +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( + SlabSize, SREPC, SAs); +} + static Expected 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( - std::make_unique(), - SimpleRemoteEPC::Setup(), FromExecutor[ReadEnd], ToExecutor[WriteEnd]); + std::make_unique(), std::move(S), + FromExecutor[ReadEnd], ToExecutor[WriteEnd]); #endif }