https://github.com/lhames created 
https://github.com/llvm/llvm-project/pull/224786

Add a SharedMemoryMapBindings handle (SharedMemoryMap.h) and its SPS proxy 
specs (SharedMemoryMapSPS.h), mirroring SimpleMemoryMap, and bind 
SharedMemoryMapper to it in place of its four callSPSWrapperAsync sites. 
Dispatch and callee errors now share one channel, dropping the per-call 
SerializationErr handling. Updates the llvm-jitlink and clang-repl factories 
and the unit test.

>From 2f8b6df1fb6407e05eeaa3f77eafcc6fdfa43e1b Mon Sep 17 00:00:00 2001
From: Lang Hames <[email protected]>
Date: Sat, 19 Sep 2026 10:41:15 +1000
Subject: [PATCH] [ORC] Drive SharedMemoryMapper via proxies

Add a SharedMemoryMapBindings handle (SharedMemoryMap.h) and its SPS
proxy specs (SharedMemoryMapSPS.h), mirroring SimpleMemoryMap, and bind
SharedMemoryMapper to it in place of its four callSPSWrapperAsync sites.
Dispatch and callee errors now share one channel, dropping the per-call
SerializationErr handling. Updates the llvm-jitlink and clang-repl
factories and the unit test.
---
 clang/lib/Interpreter/IncrementalExecutor.cpp | 28 ++------
 .../llvm/ExecutionEngine/Orc/MemoryMapper.h   | 17 ++---
 .../ExecutionEngine/Orc/SharedMemoryMap.h     | 68 +++++++++++++++++++
 .../ExecutionEngine/Orc/SharedMemoryMapSPS.h  | 53 +++++++++++++++
 llvm/lib/ExecutionEngine/Orc/CMakeLists.txt   |  1 +
 llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp | 64 ++++-------------
 .../Orc/SharedMemoryMapSPS.cpp                | 36 ++++++++++
 llvm/tools/llvm-jitlink/llvm-jitlink.cpp      | 23 ++-----
 .../Orc/SharedMemoryMapperTest.cpp            | 34 ++++++----
 9 files changed, 210 insertions(+), 114 deletions(-)
 create mode 100644 llvm/include/llvm/ExecutionEngine/Orc/SharedMemoryMap.h
 create mode 100644 llvm/include/llvm/ExecutionEngine/Orc/SharedMemoryMapSPS.h
 create mode 100644 llvm/lib/ExecutionEngine/Orc/SharedMemoryMapSPS.cpp

diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 6966e898bb583..2ea83ff7813e3 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -34,10 +34,9 @@
 #include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
 #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
-#include "llvm/ExecutionEngine/Orc/LookupAndApply.h"
 #include "llvm/ExecutionEngine/Orc/MapperJITLinkMemoryManager.h"
-#include "llvm/ExecutionEngine/Orc/Shared/SPSCI/SharedMemoryMapperSPSCI.h"
 #include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h"
+#include "llvm/ExecutionEngine/Orc/SharedMemoryMapSPS.h"
 #include "llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h"
 
 #include "llvm/Support/Error.h"
@@ -115,25 +114,10 @@ 
createDefaultJITBuilder(llvm::orc::JITTargetMachineBuilder JTMB) {
 Expected<std::unique_ptr<llvm::jitlink::JITLinkMemoryManager>>
 createSharedMemoryManager(llvm::orc::ExecutorProcessControl &EPC,
                           unsigned SlabAllocateSize) {
-  llvm::orc::SharedMemoryMapper::SymbolAddrs SAs;
-  if (auto Err = llvm::orc::lookupAndApply(
-          EPC.getExecutionSession().getBootstrapJITDylib(),
-          {llvm::orc::recordAddr(
-               llvm::orc::rt::sps_ci::SharedMemoryMapperInstanceName,
-               &SAs.Instance),
-           llvm::orc::recordAddr(
-               llvm::orc::rt::sps_ci::SharedMemoryMapperReserve::Name,
-               &SAs.Reserve),
-           llvm::orc::recordAddr(
-               llvm::orc::rt::sps_ci::SharedMemoryMapperInitialize::Name,
-               &SAs.Initialize),
-           llvm::orc::recordAddr(
-               llvm::orc::rt::sps_ci::SharedMemoryMapperDeinitialize::Name,
-               &SAs.Deinitialize),
-           llvm::orc::recordAddr(
-               llvm::orc::rt::sps_ci::SharedMemoryMapperRelease::Name,
-               &SAs.Release)}))
-    return std::move(Err);
+  auto &ES = EPC.getExecutionSession();
+  auto B = llvm::orc::sps::createSharedMemoryMapBindings(ES);
+  if (!B)
+    return B.takeError();
 
   size_t SlabSize;
   if (llvm::Triple(llvm::sys::getProcessTriple()).isOSWindows())
@@ -145,7 +129,7 @@ createSharedMemoryManager(llvm::orc::ExecutorProcessControl 
&EPC,
     SlabSize = SlabAllocateSize;
 
   return llvm::orc::MapperJITLinkMemoryManager::CreateWithMapper<
-      llvm::orc::SharedMemoryMapper>(SlabSize, EPC, SAs);
+      llvm::orc::SharedMemoryMapper>(SlabSize, ES, std::move(*B));
 }
 
 static llvm::Expected<
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/MemoryMapper.h 
b/llvm/include/llvm/ExecutionEngine/Orc/MemoryMapper.h
index 3768d1c22fcfe..dc15c22667e04 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/MemoryMapper.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/MemoryMapper.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ExecutionEngine/Orc/Core.h"
 #include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
+#include "llvm/ExecutionEngine/Orc/SharedMemoryMap.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Process.h"
 
@@ -133,19 +134,11 @@ class LLVM_ABI InProcessMemoryMapper : public 
MemoryMapper {
 
 class LLVM_ABI SharedMemoryMapper final : public MemoryMapper {
 public:
-  struct SymbolAddrs {
-    ExecutorAddr Instance;
-    ExecutorAddr Reserve;
-    ExecutorAddr Initialize;
-    ExecutorAddr Deinitialize;
-    ExecutorAddr Release;
-  };
-
-  SharedMemoryMapper(ExecutorProcessControl &EPC, SymbolAddrs SAs,
+  SharedMemoryMapper(ExecutionSession &ES, SharedMemoryMapBindings B,
                      size_t PageSize);
 
   static Expected<std::unique_ptr<SharedMemoryMapper>>
-  Create(ExecutorProcessControl &EPC, SymbolAddrs SAs);
+  Create(ExecutionSession &ES, SharedMemoryMapBindings B);
 
   unsigned int getPageSize() override { return PageSize; }
 
@@ -171,8 +164,8 @@ class LLVM_ABI SharedMemoryMapper final : public 
MemoryMapper {
     int SharedMemoryId;
   };
 
-  ExecutorProcessControl &EPC;
-  SymbolAddrs SAs;
+  ExecutionSession &ES;
+  SharedMemoryMapBindings B;
 
   std::mutex Mutex;
 
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/SharedMemoryMap.h 
b/llvm/include/llvm/ExecutionEngine/Orc/SharedMemoryMap.h
new file mode 100644
index 0000000000000..5d19b6e646a6f
--- /dev/null
+++ b/llvm/include/llvm/ExecutionEngine/Orc/SharedMemoryMap.h
@@ -0,0 +1,68 @@
+//===- SharedMemoryMap.h - Shared-memory map bindings -----------*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// A controller-side handle to an executor-side shared-memory mapper.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_EXECUTIONENGINE_ORC_SHAREDMEMORYMAP_H
+#define LLVM_EXECUTIONENGINE_ORC_SHAREDMEMORYMAP_H
+
+#include "llvm/ExecutionEngine/Orc/Proxy.h"
+#include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
+
+#include <cstdint>
+#include <string>
+#include <utility>
+
+namespace llvm::orc {
+
+/// The resolved controller-side handle to an executor-side shared-memory
+/// mapper: the address of the mapper instance, which is passed as the first
+/// argument to each call, plus the proxies for its operations.
+///
+/// This is the shared-memory analogue of SimpleMemoryMapBindings: reserve
+/// additionally returns the name of the shared-memory object backing the range
+/// (which the controller maps into its own address space), and initialize
+/// describes its segments by address and size, since their content is written
+/// directly into that shared region rather than shipped inline.
+///
+/// These are protocol-agnostic: sps::createSharedMemoryMapBindings populates
+/// them over the runtime's SPS controller interface, but a client targeting a
+/// different protocol -- or a different executor-side implementation of these
+/// operations -- can build its own and pass them to the utility that will use
+/// them.
+struct SharedMemoryMapBindings {
+  /// Reserve an address range of the given size; returns its base together 
with
+  /// the name of the shared-memory object backing it, which the controller 
maps
+  /// into its own address space.
+  using ReserveProxy = Proxy<Expected<std::pair<ExecutorAddr, std::string>>(
+      ExecutorAddr, uint64_t)>;
+
+  /// Apply a finalize request to the reservation with the given base; returns 
a
+  /// key for the initialized allocation.
+  using InitializeProxy = Proxy<Expected<ExecutorAddr>(
+      ExecutorAddr, ExecutorAddr, tpctypes::SharedMemoryFinalizeRequest)>;
+
+  /// Deinitialize the allocations with the given keys (running their
+  /// deallocation actions) without releasing their memory.
+  using DeinitializeProxy = Proxy<Error(ExecutorAddr, ArrayRef<ExecutorAddr>)>;
+
+  /// Release the reservations with the given base addresses.
+  using ReleaseProxy = Proxy<Error(ExecutorAddr, ArrayRef<ExecutorAddr>)>;
+
+  ExecutorAddr Instance;
+  ReserveProxy Reserve;
+  InitializeProxy Initialize;
+  DeinitializeProxy Deinitialize;
+  ReleaseProxy Release;
+};
+
+} // namespace llvm::orc
+
+#endif // LLVM_EXECUTIONENGINE_ORC_SHAREDMEMORYMAP_H
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/SharedMemoryMapSPS.h 
b/llvm/include/llvm/ExecutionEngine/Orc/SharedMemoryMapSPS.h
new file mode 100644
index 0000000000000..2269f71b25406
--- /dev/null
+++ b/llvm/include/llvm/ExecutionEngine/Orc/SharedMemoryMapSPS.h
@@ -0,0 +1,53 @@
+//===- SharedMemoryMapSPS.h - SPS shared-memory map bindings ----*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Binds SharedMemoryMapBindings to the ORC runtime's SPS controller interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_EXECUTIONENGINE_ORC_SHAREDMEMORYMAPSPS_H
+#define LLVM_EXECUTIONENGINE_ORC_SHAREDMEMORYMAPSPS_H
+
+#include "llvm/ExecutionEngine/Orc/LookupAndApply.h"
+#include "llvm/ExecutionEngine/Orc/SPSProxySpec.h"
+#include "llvm/ExecutionEngine/Orc/Shared/SPSCI/SharedMemoryMapperSPSCI.h"
+#include "llvm/ExecutionEngine/Orc/SharedMemoryMap.h"
+#include "llvm/Support/Compiler.h"
+
+namespace llvm::orc::sps {
+
+/// A ProxySpec per operation, pairing one of the bindings' proxies with its
+/// controller-interface descriptor in Shared/SPSCI/SharedMemoryMapperSPSCI.h,
+/// which supplies the wrapper name and wire signature. The specs are public so
+/// that clients can resolve the operations under non-default names, using
+/// recordProxy<Spec>(&P, Name) with lookupAndApply.
+using SharedMemoryMapReserveProxySpec =
+    ProxySpec<SharedMemoryMapBindings::ReserveProxy,
+              rt::sps_ci::SharedMemoryMapperReserve>;
+using SharedMemoryMapInitializeProxySpec =
+    ProxySpec<SharedMemoryMapBindings::InitializeProxy,
+              rt::sps_ci::SharedMemoryMapperInitialize>;
+using SharedMemoryMapDeinitializeProxySpec =
+    ProxySpec<SharedMemoryMapBindings::DeinitializeProxy,
+              rt::sps_ci::SharedMemoryMapperDeinitialize>;
+using SharedMemoryMapReleaseProxySpec =
+    ProxySpec<SharedMemoryMapBindings::ReleaseProxy,
+              rt::sps_ci::SharedMemoryMapperRelease>;
+
+/// Build bindings over the SPS controller interface, resolving the operations
+/// in the given JITDylib under the specs' default names.
+LLVM_ABI Expected<SharedMemoryMapBindings>
+createSharedMemoryMapBindings(JITDylib &JD);
+
+/// As above, resolving the operations in ES's bootstrap JITDylib.
+LLVM_ABI Expected<SharedMemoryMapBindings>
+createSharedMemoryMapBindings(ExecutionSession &ES);
+
+} // namespace llvm::orc::sps
+
+#endif // LLVM_EXECUTIONENGINE_ORC_SHAREDMEMORYMAPSPS_H
diff --git a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt 
b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
index 11604d94fba34..d22fcd234978b 100644
--- a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
@@ -58,6 +58,7 @@ add_llvm_component_library(LLVMOrcJIT
   RTDyldObjectLinkingLayer.cpp
   SectCreate.cpp
   SelfExecutorProcessControl.cpp
+  SharedMemoryMapSPS.cpp
   SimpleMemoryMapSPS.cpp
   SimpleRemoteEPC.cpp
   SimpleRemoteMemoryMapper.cpp
diff --git a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp 
b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
index bda14c17d81d6..8fd0de8054c1f 100644
--- a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
@@ -9,8 +9,6 @@
 #include "llvm/ExecutionEngine/Orc/MemoryMapper.h"
 
 #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
-#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
-#include "llvm/ExecutionEngine/Orc/Shared/SPSCI/SharedMemoryMapperSPSCI.h"
 #include "llvm/Support/MSVCErrorWorkarounds.h"
 #include "llvm/Support/WindowsError.h"
 
@@ -196,22 +194,23 @@ InProcessMemoryMapper::~InProcessMemoryMapper() {
 
 // SharedMemoryMapper
 
-SharedMemoryMapper::SharedMemoryMapper(ExecutorProcessControl &EPC,
-                                       SymbolAddrs SAs, size_t PageSize)
-    : EPC(EPC), SAs(SAs), PageSize(PageSize) {
+SharedMemoryMapper::SharedMemoryMapper(ExecutionSession &ES,
+                                       SharedMemoryMapBindings B,
+                                       size_t PageSize)
+    : ES(ES), B(std::move(B)), PageSize(PageSize) {
 #if (!defined(LLVM_ON_UNIX) || defined(__ANDROID__)) && !defined(_WIN32)
   llvm_unreachable("SharedMemoryMapper is not supported on this platform yet");
 #endif
 }
 
 Expected<std::unique_ptr<SharedMemoryMapper>>
-SharedMemoryMapper::Create(ExecutorProcessControl &EPC, SymbolAddrs SAs) {
+SharedMemoryMapper::Create(ExecutionSession &ES, SharedMemoryMapBindings B) {
 #if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
   auto PageSize = sys::Process::getPageSize();
   if (!PageSize)
     return PageSize.takeError();
 
-  return std::make_unique<SharedMemoryMapper>(EPC, SAs, *PageSize);
+  return std::make_unique<SharedMemoryMapper>(ES, std::move(B), *PageSize);
 #else
   return make_error<StringError>(
       "SharedMemoryMapper is not supported on this platform yet",
@@ -224,16 +223,9 @@ void SharedMemoryMapper::reserve(size_t NumBytes,
 #if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
 
   int SharedMemoryId = -1;
-  EPC.callSPSWrapperAsync<rt::sps_ci::SharedMemoryMapperReserve::SPSSig>(
-      SAs.Reserve,
+  B.Reserve(
       [this, NumBytes, OnReserved = std::move(OnReserved), SharedMemoryId](
-          Error SerializationErr,
           Expected<std::pair<ExecutorAddr, std::string>> Result) mutable {
-        if (SerializationErr) {
-          cantFail(Result.takeError());
-          return OnReserved(std::move(SerializationErr));
-        }
-
         if (!Result)
           return OnReserved(Result.takeError());
 
@@ -307,7 +299,7 @@ void SharedMemoryMapper::reserve(size_t NumBytes,
 
         OnReserved(ExecutorAddrRange(RemoteAddr, NumBytes));
       },
-      SAs.Instance, static_cast<uint64_t>(NumBytes));
+      ES, B.Instance, static_cast<uint64_t>(NumBytes));
 
 #else
   OnReserved(make_error<StringError>(
@@ -355,35 +347,14 @@ void 
SharedMemoryMapper::initialize(MemoryMapper::AllocInfo &AI,
     FR.Segments.push_back(SegReq);
   }
 
-  EPC.callSPSWrapperAsync<rt::sps_ci::SharedMemoryMapperInitialize::SPSSig>(
-      SAs.Initialize,
-      [OnInitialized = std::move(OnInitialized)](
-          Error SerializationErr, Expected<ExecutorAddr> Result) mutable {
-        if (SerializationErr) {
-          cantFail(Result.takeError());
-          return OnInitialized(std::move(SerializationErr));
-        }
-
-        OnInitialized(std::move(Result));
-      },
-      SAs.Instance, Reservation->first, std::move(FR));
+  B.Initialize(std::move(OnInitialized), ES, B.Instance, Reservation->first,
+               std::move(FR));
 }
 
 void SharedMemoryMapper::deinitialize(
     ArrayRef<ExecutorAddr> Allocations,
     MemoryMapper::OnDeinitializedFunction OnDeinitialized) {
-  EPC.callSPSWrapperAsync<rt::sps_ci::SharedMemoryMapperDeinitialize::SPSSig>(
-      SAs.Deinitialize,
-      [OnDeinitialized = std::move(OnDeinitialized)](Error SerializationErr,
-                                                     Error Result) mutable {
-        if (SerializationErr) {
-          cantFail(std::move(Result));
-          return OnDeinitialized(std::move(SerializationErr));
-        }
-
-        OnDeinitialized(std::move(Result));
-      },
-      SAs.Instance, Allocations);
+  B.Deinitialize(std::move(OnDeinitialized), ES, B.Instance, Allocations);
 }
 
 void SharedMemoryMapper::release(ArrayRef<ExecutorAddr> Bases,
@@ -419,19 +390,12 @@ void SharedMemoryMapper::release(ArrayRef<ExecutorAddr> 
Bases,
     }
   }
 
-  EPC.callSPSWrapperAsync<rt::sps_ci::SharedMemoryMapperRelease::SPSSig>(
-      SAs.Release,
+  B.Release(
       [OnReleased = std::move(OnReleased),
-       Err = std::move(Err)](Error SerializationErr, Error Result) mutable {
-        if (SerializationErr) {
-          cantFail(std::move(Result));
-          return OnReleased(
-              joinErrors(std::move(Err), std::move(SerializationErr)));
-        }
-
+       Err = std::move(Err)](Error Result) mutable {
         return OnReleased(joinErrors(std::move(Err), std::move(Result)));
       },
-      SAs.Instance, Bases);
+      ES, B.Instance, Bases);
 #else
   OnReleased(make_error<StringError>(
       "SharedMemoryMapper is not supported on this platform yet",
diff --git a/llvm/lib/ExecutionEngine/Orc/SharedMemoryMapSPS.cpp 
b/llvm/lib/ExecutionEngine/Orc/SharedMemoryMapSPS.cpp
new file mode 100644
index 0000000000000..83196c51a7ca1
--- /dev/null
+++ b/llvm/lib/ExecutionEngine/Orc/SharedMemoryMapSPS.cpp
@@ -0,0 +1,36 @@
+//===- SharedMemoryMapSPS.cpp - SPS shared-memory map bindings 
------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ExecutionEngine/Orc/SharedMemoryMapSPS.h"
+
+#include "llvm/ExecutionEngine/Orc/Core.h"
+#include "llvm/ExecutionEngine/Orc/RecordProxy.h"
+
+namespace llvm::orc::sps {
+
+Expected<SharedMemoryMapBindings> createSharedMemoryMapBindings(JITDylib &JD) {
+  SharedMemoryMapBindings B;
+  // Instance is the executor-side mapper object -- a data symbol passed as the
+  // first argument to each call, not a wrapper to proxy.
+  if (auto Err = lookupAndApply(
+          JD,
+          {recordAddr(rt::sps_ci::SharedMemoryMapperInstanceName, &B.Instance),
+           recordProxy<SharedMemoryMapReserveProxySpec>(&B.Reserve),
+           recordProxy<SharedMemoryMapInitializeProxySpec>(&B.Initialize),
+           recordProxy<SharedMemoryMapDeinitializeProxySpec>(&B.Deinitialize),
+           recordProxy<SharedMemoryMapReleaseProxySpec>(&B.Release)}))
+    return std::move(Err);
+  return std::move(B);
+}
+
+Expected<SharedMemoryMapBindings>
+createSharedMemoryMapBindings(ExecutionSession &ES) {
+  return createSharedMemoryMapBindings(ES.getBootstrapJITDylib());
+}
+
+} // namespace llvm::orc::sps
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp 
b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 05606849797ab..93abae9d920cf 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -33,7 +33,6 @@
 #include "llvm/ExecutionEngine/Orc/JITLinkReentryTrampolines.h"
 #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
 #include "llvm/ExecutionEngine/Orc/LoadLinkableFile.h"
-#include "llvm/ExecutionEngine/Orc/LookupAndApply.h"
 #include "llvm/ExecutionEngine/Orc/MachO.h"
 #include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
 #include "llvm/ExecutionEngine/Orc/MapperJITLinkMemoryManager.h"
@@ -41,7 +40,7 @@
 #include "llvm/ExecutionEngine/Orc/SectCreate.h"
 #include "llvm/ExecutionEngine/Orc/SelfExecutorProcessControl.h"
 #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
-#include "llvm/ExecutionEngine/Orc/Shared/SPSCI/SharedMemoryMapperSPSCI.h"
+#include "llvm/ExecutionEngine/Orc/SharedMemoryMapSPS.h"
 #include "llvm/ExecutionEngine/Orc/SimpleMemoryMapSPS.h"
 #include "llvm/ExecutionEngine/Orc/SimpleRemoteMemoryMapper.h"
 #include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
@@ -779,20 +778,10 @@ createSimpleRemoteMemoryManager(ExecutorProcessControl 
&EPC) {
 
 Expected<std::unique_ptr<jitlink::JITLinkMemoryManager>>
 createSharedMemoryManager(ExecutorProcessControl &EPC) {
-  SharedMemoryMapper::SymbolAddrs SAs;
-  if (auto Err = lookupAndApply(
-          EPC.getExecutionSession().getBootstrapJITDylib(),
-          {recordAddr(rt::sps_ci::SharedMemoryMapperInstanceName,
-                      &SAs.Instance),
-           recordAddr(rt::sps_ci::SharedMemoryMapperReserve::Name,
-                      &SAs.Reserve),
-           recordAddr(rt::sps_ci::SharedMemoryMapperInitialize::Name,
-                      &SAs.Initialize),
-           recordAddr(rt::sps_ci::SharedMemoryMapperDeinitialize::Name,
-                      &SAs.Deinitialize),
-           recordAddr(rt::sps_ci::SharedMemoryMapperRelease::Name,
-                      &SAs.Release)}))
-    return std::move(Err);
+  auto &ES = EPC.getExecutionSession();
+  auto B = sps::createSharedMemoryMapBindings(ES);
+  if (!B)
+    return B.takeError();
 
 #ifdef _WIN32
   size_t SlabSize = 1024 * 1024;
@@ -804,7 +793,7 @@ createSharedMemoryManager(ExecutorProcessControl &EPC) {
     SlabSize = ExitOnErr(getSlabAllocSize(SlabAllocateSizeString));
 
   return MapperJITLinkMemoryManager::CreateWithMapper<SharedMemoryMapper>(
-      SlabSize, EPC, SAs);
+      SlabSize, ES, std::move(*B));
 }
 
 static Expected<std::unique_ptr<jitlink::JITLinkMemoryManager>>
diff --git a/llvm/unittests/ExecutionEngine/Orc/SharedMemoryMapperTest.cpp 
b/llvm/unittests/ExecutionEngine/Orc/SharedMemoryMapperTest.cpp
index de6c4cdb53fef..753f8836acbd6 100644
--- a/llvm/unittests/ExecutionEngine/Orc/SharedMemoryMapperTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/SharedMemoryMapperTest.cpp
@@ -12,8 +12,8 @@
 #include "llvm/ExecutionEngine/Orc/MemoryMapper.h"
 #include "llvm/ExecutionEngine/Orc/SelfExecutorProcessControl.h"
 #include "llvm/ExecutionEngine/Orc/Shared/Mangler.h"
-#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
 #include "llvm/ExecutionEngine/Orc/Shared/SPSCI/SharedMemoryMapperSPSCI.h"
+#include "llvm/ExecutionEngine/Orc/SharedMemoryMapSPS.h"
 #include 
"llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h"
 #include "llvm/TargetParser/Host.h"
 #include "llvm/TargetParser/Triple.h"
@@ -47,21 +47,29 @@ TEST(SharedMemoryMapperTest, 
MemReserveInitializeDeinitializeRelease) {
 
   ExecutorSharedMemoryMapperService MapperService;
 
-  SharedMemoryMapper::SymbolAddrs SAs;
+  ExecutionSession ES(std::move(SelfEPC));
+
+  // Bind directly to the mapper service's wrapper functions, dispatching each
+  // through the SPS controller interface.
+  SharedMemoryMapBindings B;
   {
     StringMap<ExecutorAddr> Map;
     MapperService.addBootstrapSymbols(Map);
     Mangler Mangle{Triple(sys::getProcessTriple())};
-    SAs.Instance =
+    B.Instance =
         Map[Mangle.mangledCopy(rt::sps_ci::SharedMemoryMapperInstanceName)];
-    SAs.Reserve =
-        Map[Mangle.mangledCopy(rt::sps_ci::SharedMemoryMapperReserve::Name)];
-    SAs.Initialize =
-        
Map[Mangle.mangledCopy(rt::sps_ci::SharedMemoryMapperInitialize::Name)];
-    SAs.Deinitialize = Map[Mangle.mangledCopy(
-        rt::sps_ci::SharedMemoryMapperDeinitialize::Name)];
-    SAs.Release =
-        Map[Mangle.mangledCopy(rt::sps_ci::SharedMemoryMapperRelease::Name)];
+    B.Reserve = {
+        sps::SharedMemoryMapReserveProxySpec::dispatch,
+        Map[Mangle.mangledCopy(rt::sps_ci::SharedMemoryMapperReserve::Name)]};
+    B.Initialize = {sps::SharedMemoryMapInitializeProxySpec::dispatch,
+                    Map[Mangle.mangledCopy(
+                        rt::sps_ci::SharedMemoryMapperInitialize::Name)]};
+    B.Deinitialize = {sps::SharedMemoryMapDeinitializeProxySpec::dispatch,
+                      Map[Mangle.mangledCopy(
+                          rt::sps_ci::SharedMemoryMapperDeinitialize::Name)]};
+    B.Release = {
+        sps::SharedMemoryMapReleaseProxySpec::dispatch,
+        Map[Mangle.mangledCopy(rt::sps_ci::SharedMemoryMapperRelease::Name)]};
   }
 
   std::string TestString = "Hello, World!";
@@ -72,7 +80,7 @@ TEST(SharedMemoryMapperTest, 
MemReserveInitializeDeinitializeRelease) {
 
   {
     std::unique_ptr<MemoryMapper> Mapper =
-        cantFail(SharedMemoryMapper::Create(*SelfEPC, SAs));
+        cantFail(SharedMemoryMapper::Create(ES, std::move(B)));
 
     auto PageSize = Mapper->getPageSize();
     size_t ReqSize = PageSize;
@@ -140,7 +148,7 @@ TEST(SharedMemoryMapperTest, 
MemReserveInitializeDeinitializeRelease) {
   }
 
   EXPECT_THAT_ERROR(MapperService.shutdown(), Succeeded());
-  cantFail(SelfEPC->disconnect());
+  cantFail(ES.endSession());
 }
 
 #endif

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to