[llvm] [ORC] Route SimpleRemoteEPC::runAsMain through CallMainProxySpec (PR #219770)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 29 23:09:11 PDT 2026


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

Replace runAsMainAddr with a CallMain proxy that is lazily initialized by lookupAndApply on first use. This is another step towards making callWrapperAsync the only call primitive
ExecutionSession/ExecutorProcessControl need to know about.

>From b69a0f0f3a6bf260fd0a8971be081c028574a6a3 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Sun, 30 Aug 2026 16:03:24 +1000
Subject: [PATCH] [ORC] Route SimpleRemoteEPC::runAsMain through
 CallMainProxySpec

Replace runAsMainAddr with a CallMain proxy that is lazily initialized
by lookupAndApply on first use. This is another step towards making
callWrapperAsync the only call primitive
ExecutionSession/ExecutorProcessControl need to know about.
---
 .../ExecutionEngine/Orc/SimpleRemoteEPC.h     |  3 ++-
 .../ExecutionEngine/Orc/SimpleRemoteEPC.cpp   | 21 +++++++++++--------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
index 6e27cc2c65080..4c0f828cbd273 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FunctionExtras.h"
+#include "llvm/ExecutionEngine/Orc/CallProxies.h"
 #include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
 #include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h"
 #include "llvm/Support/Compiler.h"
@@ -127,7 +128,7 @@ class LLVM_ABI SimpleRemoteEPC : public ExecutorProcessControl,
 
   std::unique_ptr<SimpleRemoteEPCTransport> T;
 
-  ExecutorAddr RunAsMainAddr;
+  CallMainProxy CallMain;
 
   uint64_t NextSeqNo = 0;
   PendingCallWrapperResultsMap PendingCallWrapperResults;
diff --git a/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp b/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
index bf3d98f9d0312..80f9a4c5d8beb 100644
--- a/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
@@ -11,6 +11,8 @@
 #include "llvm/ExecutionEngine/Orc/EPCGenericDylibManagerSPS.h"
 #include "llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerSPS.h"
 #include "llvm/ExecutionEngine/Orc/EPCGenericMemoryAccessSPS.h"
+#include "llvm/ExecutionEngine/Orc/LookupAndApply.h"
+#include "llvm/ExecutionEngine/Orc/RecordProxy.h"
 #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
 #include "llvm/Support/FormatVariadic.h"
 
@@ -28,11 +30,16 @@ SimpleRemoteEPC::~SimpleRemoteEPC() {
 
 Expected<int32_t> SimpleRemoteEPC::runAsMain(ExecutorAddr MainFnAddr,
                                              ArrayRef<std::string> Args) {
-  int64_t Result = 0;
-  if (auto Err = callSPSWrapper<rt::sps_ci::CallMain::SPSSig>(
-          RunAsMainAddr, Result, MainFnAddr, Args))
-    return std::move(Err);
-  return Result;
+  if (!CallMain)
+    if (auto Err =
+            lookupAndApply(getExecutionSession().getBootstrapJITDylib(),
+                           recordProxy<sps::CallMainProxySpec>(&CallMain)))
+      return Err;
+
+  auto Result = CallMain(getExecutionSession(), MainFnAddr, Args);
+  if (!Result)
+    return Result.takeError();
+  return *Result;
 }
 
 void SimpleRemoteEPC::callWrapperAsync(ExecutorAddr WrapperFnAddr,
@@ -339,10 +346,6 @@ Error SimpleRemoteEPC::setup() {
   BootstrapSymbols[rt::DispatchCtxName] =
       BootstrapSymbols[ExecutorSessionObjectName];
 
-  if (auto Err =
-          getBootstrapSymbols({{RunAsMainAddr, rt::sps_ci::CallMain::Name}}))
-    return Err;
-
   return Error::success();
 }
 



More information about the llvm-commits mailing list