[llvm] [ORC] Use a weak recordAddr in runSymbolIfExists (PR #218591)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 00:01:05 PDT 2026


https://github.com/lhames updated https://github.com/llvm/llvm-project/pull/218591

>From e09ce119a6efa43027189e20a96b7decfb409e21 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Tue, 25 Aug 2026 16:14:50 +1000
Subject: [PATCH] [ORC] Use a weak recordAddr in runSymbolIfExists

COFFPlatform::runSymbolIfExists resolved the symbol as required, then
swallowed the resulting SymbolsNotFound error. Use a weakly-referenced
recordAddr and test the address instead. This was the last non-test
caller of lookupAndRecordAddrs.
---
 llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp | 34 ++++++++-----------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
index a59f72cb43525..b35f08821d671 100644
--- a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
@@ -731,25 +731,21 @@ Error COFFPlatform::bootstrapCOFFRuntime(JITDylib &PlatformJD) {
 
 Error COFFPlatform::runSymbolIfExists(JITDylib &PlatformJD,
                                       StringRef SymbolName) {
-  ExecutorAddr jit_function;
-  auto AfterCLookupErr = lookupAndRecordAddrs(
-      ES, LookupKind::Static, makeJITDylibSearchOrder(&PlatformJD),
-      {{ES.intern(SymbolName), &jit_function}});
-  if (!AfterCLookupErr) {
-    CallInt32VoidProxy CallFn;
-    if (auto Err =
-            lookupAndApply(ES.getBootstrapJITDylib(),
-                           {recordProxy<sps::CallInt32VoidProxySpec>(&CallFn)}))
-      return Err;
-    auto Res = CallFn(ES, jit_function);
-    if (!Res)
-      return Res.takeError();
-    return Error::success();
-  }
-  if (!AfterCLookupErr.isA<SymbolsNotFound>())
-    return AfterCLookupErr;
-  consumeError(std::move(AfterCLookupErr));
-  return Error::success();
+  ExecutorAddr TargetFn;
+  if (auto Err = lookupAndApply(
+          PlatformJD, {recordAddr(SymbolName, &TargetFn,
+                                  SymbolLookupFlags::WeaklyReferencedSymbol)}))
+    return Err;
+  if (!TargetFunction)
+    return Error::success(); // No target function.
+
+  CallInt32VoidProxy CallFn;
+  if (auto Err =
+          lookupAndApply(ES.getBootstrapJITDylib(),
+                         {recordProxy<sps::CallInt32VoidProxySpec>(&CallFn)}))
+    return Err;
+
+  return CallFn(ES, TargetFn);
 }
 
 void COFFPlatform::COFFPlatformPlugin::modifyPassConfig(



More information about the llvm-commits mailing list