[llvm] [llvm-jitlink] Call __orc_rt_run_program_wrapper through a Proxy (PR #226859)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 27 17:44:46 PDT 2026


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

Replace runWithRuntime's callSPSWrapper call with a Proxy.

>From e952e414aefc0e81612401de0e31cc02392126f2 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Mon, 28 Sep 2026 08:58:32 +1000
Subject: [PATCH] [llvm-jitlink] Call __orc_rt_run_program_wrapper through a
 Proxy

Replace runWithRuntime's callSPSWrapper call with a Proxy.
---
 llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 41 ++++++++++++++++--------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 22382d855b9ae..1a24e49476611 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -39,9 +39,11 @@
 #include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
 #include "llvm/ExecutionEngine/Orc/MapperJITLinkMemoryManager.h"
 #include "llvm/ExecutionEngine/Orc/ObjectFileInterface.h"
+#include "llvm/ExecutionEngine/Orc/SPSProxySpec.h"
 #include "llvm/ExecutionEngine/Orc/SectCreate.h"
 #include "llvm/ExecutionEngine/Orc/SelfExecutorProcessControl.h"
 #include "llvm/ExecutionEngine/Orc/Shared/ConnectionSpec.h"
+#include "llvm/ExecutionEngine/Orc/Shared/Mangler.h"
 #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
 #include "llvm/ExecutionEngine/Orc/SharedMemoryMapSPS.h"
 #include "llvm/ExecutionEngine/Orc/SimpleMemoryMapSPS.h"
@@ -2953,15 +2955,25 @@ static Error addSelfRelocations(LinkGraph &G) {
   return Error::success();
 }
 
+// Controller-interface descriptor for the ORC runtime's run-program wrapper.
+namespace llvm::orc::run_program_sps_ci {
+struct RunProgram {
+  static constexpr SymbolNameSpec Name =
+      SymbolNameSpec::c("__orc_rt_run_program_wrapper");
+  using SPSSig = int64_t(shared::SPSString, shared::SPSString,
+                         shared::SPSSequence<shared::SPSString>);
+};
+} // namespace llvm::orc::run_program_sps_ci
+
 static Expected<ExecutorSymbolDef> getMainEntryPoint(Session &S) {
   return S.ES.lookup(S.JDSearchOrder, S.ES.intern(EntryPointName));
 }
 
 static Expected<ExecutorSymbolDef> getOrcRuntimeEntryPoint(Session &S) {
-  std::string RuntimeEntryPoint = "__orc_rt_run_program_wrapper";
-  if (S.ES.getTargetTriple().getObjectFormat() == Triple::MachO)
-    RuntimeEntryPoint = '_' + RuntimeEntryPoint;
-  return S.ES.lookup(S.JDSearchOrder, S.ES.intern(RuntimeEntryPoint));
+  orc::Mangler Mangle(S.ES.getTargetTriple());
+  return S.ES.lookup(
+      S.JDSearchOrder,
+      S.ES.intern(Mangle.mangledCopy(run_program_sps_ci::RunProgram::Name)));
 }
 
 static Expected<ExecutorSymbolDef> getEntryPoint(Session &S) {
@@ -2999,15 +3011,18 @@ static Expected<int> runWithRuntime(Session &S, ExecutorAddr EntryPointAddr) {
   if (S.ES.getTargetTriple().getObjectFormat() == Triple::MachO &&
       DemangledEntryPoint.front() == '_')
     DemangledEntryPoint = DemangledEntryPoint.drop_front();
-  using llvm::orc::shared::SPSString;
-  using SPSRunProgramSig =
-      int64_t(SPSString, SPSString, shared::SPSSequence<SPSString>);
-  int64_t Result;
-  if (auto Err = S.ES.callSPSWrapper<SPSRunProgramSig>(
-          EntryPointAddr, Result, S.MainJD->getName(), DemangledEntryPoint,
-          static_cast<std::vector<std::string> &>(InputArgv)))
-    return std::move(Err);
-  return Result;
+  using RunProgramProxy =
+      Proxy<int64_t(StringRef, StringRef, ArrayRef<std::string>)>;
+  RunProgramProxy RunProgram(
+      sps::ProxySpec<RunProgramProxy, run_program_sps_ci::RunProgram>::dispatch,
+      EntryPointAddr);
+  auto Result =
+      RunProgram(S.ES, S.MainJD->getName(), DemangledEntryPoint,
+                 ArrayRef<std::string>(
+                     static_cast<std::vector<std::string> &>(InputArgv)));
+  if (!Result)
+    return Result.takeError();
+  return *Result;
 }
 
 static Expected<int> runWithoutRuntime(Session &S,



More information about the llvm-commits mailing list