[llvm] [ORC] Describe COFFPlatform symbol names by mangling kind (PR #226097)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 03:04:28 PDT 2026


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

Replace Verbatim with the accurate SymbolNameKind for the names that COFFPlatform and COFFVCRuntimeBootstrapper look up: C for the ORC runtime's extern "C" __orc_rt_coff_* entry points, the C runtime's __scrt_* functions, and __run_after_c_init; Linker for the MSVC C++-decorated ?__scrt_initialize_type_info@@YAXXZ, which is already a linker-level name.

>From 721a4ba0765be864d99b9dfcd154a77dc1244124 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Thu, 24 Sep 2026 15:30:27 +1000
Subject: [PATCH] [ORC] Describe COFFPlatform symbol names by mangling kind

Replace Verbatim with the accurate SymbolNameKind for the names that
COFFPlatform and COFFVCRuntimeBootstrapper look up: C for the ORC
runtime's extern "C" __orc_rt_coff_* entry points, the C runtime's
__scrt_* functions, and __run_after_c_init; Linker for the MSVC
C++-decorated ?__scrt_initialize_type_info@@YAXXZ, which is already a
linker-level name.
---
 llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp | 39 ++++++++-----------
 .../Orc/COFFVCRuntimeSupport.cpp              | 22 +++++------
 2 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
index d3c46063c431a..b88f82f0599f9 100644
--- a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
@@ -52,17 +52,17 @@ using SPSCOFFDeregisterObjectSectionsArgs =
 namespace llvm::orc::coff_sps_ci {
 struct PlatformBootstrap {
   static constexpr SymbolNameSpec Name =
-      SymbolNameSpec::verbatim("__orc_rt_coff_platform_bootstrap");
+      SymbolNameSpec::c("__orc_rt_coff_platform_bootstrap");
   using SPSSig = void();
 };
 struct RegisterJITDylib {
   static constexpr SymbolNameSpec Name =
-      SymbolNameSpec::verbatim("__orc_rt_coff_register_jitdylib");
+      SymbolNameSpec::c("__orc_rt_coff_register_jitdylib");
   using SPSSig = void(SPSString, SPSExecutorAddr);
 };
 struct RegisterObjectSections {
   static constexpr SymbolNameSpec Name =
-      SymbolNameSpec::verbatim("__orc_rt_coff_register_object_sections");
+      SymbolNameSpec::c("__orc_rt_coff_register_object_sections");
   using SPSSig = void(SPSExecutorAddr, SPSCOFFObjectSectionsMap, bool);
 };
 } // namespace llvm::orc::coff_sps_ci
@@ -706,24 +706,20 @@ Error COFFPlatform::bootstrapCOFFRuntime(JITDylib &PlatformJD) {
   // it's static linking setting.
   if (auto Err = lookupAndApply(
           PlatformJD,
-          {recordAddr(
-               SymbolNameSpec::verbatim("__orc_rt_coff_platform_bootstrap"),
-               &orc_rt_coff_platform_bootstrap),
+          {recordAddr(SymbolNameSpec::c("__orc_rt_coff_platform_bootstrap"),
+                      &orc_rt_coff_platform_bootstrap),
+           recordAddr(SymbolNameSpec::c("__orc_rt_coff_platform_shutdown"),
+                      &orc_rt_coff_platform_shutdown),
+           recordAddr(SymbolNameSpec::c("__orc_rt_coff_register_jitdylib"),
+                      &orc_rt_coff_register_jitdylib),
+           recordAddr(SymbolNameSpec::c("__orc_rt_coff_deregister_jitdylib"),
+                      &orc_rt_coff_deregister_jitdylib),
            recordAddr(
-               SymbolNameSpec::verbatim("__orc_rt_coff_platform_shutdown"),
-               &orc_rt_coff_platform_shutdown),
+               SymbolNameSpec::c("__orc_rt_coff_register_object_sections"),
+               &orc_rt_coff_register_object_sections),
            recordAddr(
-               SymbolNameSpec::verbatim("__orc_rt_coff_register_jitdylib"),
-               &orc_rt_coff_register_jitdylib),
-           recordAddr(
-               SymbolNameSpec::verbatim("__orc_rt_coff_deregister_jitdylib"),
-               &orc_rt_coff_deregister_jitdylib),
-           recordAddr(SymbolNameSpec::verbatim(
-                          "__orc_rt_coff_register_object_sections"),
-                      &orc_rt_coff_register_object_sections),
-           recordAddr(SymbolNameSpec::verbatim(
-                          "__orc_rt_coff_deregister_object_sections"),
-                      &orc_rt_coff_deregister_object_sections)}))
+               SymbolNameSpec::c("__orc_rt_coff_deregister_object_sections"),
+               &orc_rt_coff_deregister_object_sections)}))
     return Err;
 
   // These runtime entry points are held as addresses because their primary use
@@ -780,9 +776,8 @@ Error COFFPlatform::runSymbolIfExists(JITDylib &PlatformJD,
                                       StringRef SymbolName) {
   ExecutorAddr TargetFn;
   if (auto Err = lookupAndApply(
-          PlatformJD,
-          {recordAddr(SymbolNameSpec::verbatim(SymbolName), &TargetFn,
-                      SymbolLookupFlags::WeaklyReferencedSymbol)}))
+          PlatformJD, {recordAddr(SymbolNameSpec::c(SymbolName), &TargetFn,
+                                  SymbolLookupFlags::WeaklyReferencedSymbol)}))
     return Err;
   if (!TargetFn)
     return Error::success(); // No target function.
diff --git a/llvm/lib/ExecutionEngine/Orc/COFFVCRuntimeSupport.cpp b/llvm/lib/ExecutionEngine/Orc/COFFVCRuntimeSupport.cpp
index 7dff95643ca9b..70b8058c8a71b 100644
--- a/llvm/lib/ExecutionEngine/Orc/COFFVCRuntimeSupport.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/COFFVCRuntimeSupport.cpp
@@ -115,17 +115,17 @@ Error COFFVCRuntimeBootstrapper::initializeStaticVCRuntime(JITDylib &JD) {
       jit_scrt_initialize_type_info,
       jit_scrt_initialize_default_local_stdio_options;
   if (auto Err = lookupAndApply(
-          JD, {recordAddr(SymbolNameSpec::verbatim("__scrt_initialize_crt"),
-                          &jit_scrt_initialize),
-               recordAddr(SymbolNameSpec::verbatim(
-                              "__scrt_dllmain_before_initialize_c"),
-                          &jit_scrt_dllmain_before_initialize_c),
-               recordAddr(SymbolNameSpec::verbatim(
-                              "?__scrt_initialize_type_info@@YAXXZ"),
-                          &jit_scrt_initialize_type_info),
-               recordAddr(SymbolNameSpec::verbatim(
-                              "__scrt_initialize_default_local_stdio_options"),
-                          &jit_scrt_initialize_default_local_stdio_options)}))
+          JD,
+          {recordAddr(SymbolNameSpec::c("__scrt_initialize_crt"),
+                      &jit_scrt_initialize),
+           recordAddr(SymbolNameSpec::c("__scrt_dllmain_before_initialize_c"),
+                      &jit_scrt_dllmain_before_initialize_c),
+           recordAddr(
+               SymbolNameSpec::linker("?__scrt_initialize_type_info@@YAXXZ"),
+               &jit_scrt_initialize_type_info),
+           recordAddr(SymbolNameSpec::c(
+                          "__scrt_initialize_default_local_stdio_options"),
+                      &jit_scrt_initialize_default_local_stdio_options)}))
     return Err;
 
   CallInt32VoidProxy CallInt32Void;



More information about the llvm-commits mailing list