Skip to content

[llvm] annotate interfaces in llvm/ExecutionEngine for DLL export #140809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

andrurogerz
Copy link
Contributor

Purpose

This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the llvm/ExecutionEngine library. These annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build.

Background

This effort is tracked in #109483. Additional context is provided in this discourse, and documentation for LLVM_ABI and related annotations is found in the LLVM repo here.

The bulk of these changes were generated automatically using the Interface Definition Scanner (IDS) tool, followed formatting with git clang-format.

The following manual adjustments were also applied after running IDS on Linux:

  • Add LLVM_ABI_FRIEND to friend member functions declared with LLVM_ABI
  • Add LLVM_ABI to a subset of private class methods and fields that require export
  • Add LLVM_ABI to a small number of symbols that require export but are not declared in headers
  • Add LLVM_ABI to a number of extern "C" methods that IDS missed because they're implicitly exported

Validation

Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations:

  • Windows with MSVC
  • Windows with Clang
  • Linux with GCC
  • Linux with Clang
  • Darwin with Clang

@andrurogerz andrurogerz marked this pull request as ready for review May 22, 2025 00:37
@llvmbot
Copy link
Member

llvmbot commented May 22, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Andrew Rogers (andrurogerz)

Changes

Purpose

This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the llvm/ExecutionEngine library. These annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build.

Background

This effort is tracked in #109483. Additional context is provided in this discourse, and documentation for LLVM_ABI and related annotations is found in the LLVM repo here.

The bulk of these changes were generated automatically using the Interface Definition Scanner (IDS) tool, followed formatting with git clang-format.

The following manual adjustments were also applied after running IDS on Linux:

  • Add LLVM_ABI_FRIEND to friend member functions declared with LLVM_ABI
  • Add LLVM_ABI to a subset of private class methods and fields that require export
  • Add LLVM_ABI to a small number of symbols that require export but are not declared in headers
  • Add LLVM_ABI to a number of extern "C" methods that IDS missed because they're implicitly exported

Validation

Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations:

  • Windows with MSVC
  • Windows with Clang
  • Linux with GCC
  • Linux with Clang
  • Darwin with Clang

Patch is 228.30 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/140809.diff

101 Files Affected:

  • (modified) llvm/include/llvm/ExecutionEngine/ExecutionEngine.h (+16-14)
  • (modified) llvm/include/llvm/ExecutionEngine/Interpreter.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITEventListener.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h (+3-2)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h (+29-27)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h (+17-16)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/MachO.h (+5-4)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/MachO_arm64.h (+7-5)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h (+7-5)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h (+21-18)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/aarch64.h (+10-9)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/loongarch.h (+5-4)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h (+7-6)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/riscv.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/x86.h (+5-4)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h (+8-7)
  • (modified) llvm/include/llvm/ExecutionEngine/JITSymbol.h (+8-6)
  • (modified) llvm/include/llvm/ExecutionEngine/MCJIT.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/ObjectCache.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/AbsoluteSymbols.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h (+3-2)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/COFFVCRuntimeSupport.h (+5-4)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/CompileUtils.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Core.h (+116-104)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/DebugUtils.h (+38-25)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebugInfoSupport.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h (+3-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/DylibManager.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h (+3-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/ELFNixPlatform.h (+3-2)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h (+4-2)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/EPCGenericDylibManager.h (+9-6)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h (+3-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.h (+3-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h (+21-20)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h (+8-6)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/GetDylibInterface.h (+7-5)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h (+3-2)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/IRPartitionLayer.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h (+24-21)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h (+3-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/JITLinkReentryTrampolines.h (+7-6)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h (+5-4)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h (+14-12)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Layer.h (+7-5)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/LazyObjectLinkingLayer.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/LazyReexports.h (+16-12)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/LinkGraphLayer.h (+3-2)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/LinkGraphLinkingLayer.h (+4-2)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/LoadLinkableFile.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/LookupAndRecordAddrs.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/MachO.h (+9-8)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h (+6-5)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Mangling.h (+7-5)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/MapperJITLinkMemoryManager.h (+3-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/MaterializationUnit.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/MemoryMapper.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/ObjectFileInterface.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h (+4-2)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h (+83-88)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/ReOptimizeLayer.h (+5-4)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/RedirectionManager.h (+4-2)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/SectCreate.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Shared/AllocationActions.h (+5-4)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h (+36-35)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h (+13-12)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcError.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h (+33-30)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h (+6-5)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Speculation.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h (+8-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/DefaultHostBootstrapValues.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorBootstrapService.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h (+4-4)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorDylibManager.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h (+2-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h (+5-4)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/UnwindInfoManager.h (+11-8)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/TaskDispatch.h (+8-7)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h (+3-4)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/UnwindInfoRegistrationPlugin.h (+3-1)
  • (modified) llvm/include/llvm/ExecutionEngine/RTDyldMemoryManager.h (+4-3)
  • (modified) llvm/include/llvm/ExecutionEngine/RuntimeDyld.h (+25-22)
  • (modified) llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h (+14-14)
  • (modified) llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h (+3-2)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp (+3-2)
  • (modified) llvm/lib/ExecutionEngine/JITLink/aarch32.cpp (+13-12)
  • (modified) llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp (+4-5)
  • (modified) llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp (+1-1)
diff --git a/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h b/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
index ee6084ada1dd4..27399d93fe587 100644
--- a/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -25,6 +25,7 @@
 #include "llvm/Object/Binary.h"
 #include "llvm/Support/CBindingWrapping.h"
 #include "llvm/Support/CodeGen.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Target/TargetMachine.h"
@@ -88,7 +89,7 @@ class ExecutionEngineState {
   /// Erase an entry from the mapping table.
   ///
   /// \returns The address that \p ToUnmap was mapped to.
-  uint64_t RemoveMapping(StringRef Name);
+  LLVM_ABI uint64_t RemoveMapping(StringRef Name);
 };
 
 using FunctionCreator = std::function<void *(const std::string &)>;
@@ -96,7 +97,7 @@ using FunctionCreator = std::function<void *(const std::string &)>;
 /// Abstract interface for implementation execution of LLVM modules,
 /// designed to support both interpreter and just-in-time (JIT) compiler
 /// implementations.
-class ExecutionEngine {
+class LLVM_ABI ExecutionEngine {
   /// The state object holding the global address mapping, which must be
   /// accessed synchronously.
   //
@@ -550,13 +551,13 @@ class EngineBuilder {
 
 public:
   /// Default constructor for EngineBuilder.
-  EngineBuilder();
+  LLVM_ABI EngineBuilder();
 
   /// Constructor for EngineBuilder.
-  EngineBuilder(std::unique_ptr<Module> M);
+  LLVM_ABI EngineBuilder(std::unique_ptr<Module> M);
 
   // Out-of-line since we don't have the def'n of RTDyldMemoryManager here.
-  ~EngineBuilder();
+  LLVM_ABI ~EngineBuilder();
 
   /// setEngineKind - Controls whether the user wants the interpreter, the JIT,
   /// or whichever engine works.  This option defaults to EngineKind::Either.
@@ -571,12 +572,14 @@ class EngineBuilder {
   /// to create anything other than MCJIT will cause a runtime error. If create()
   /// is called and is successful, the created engine takes ownership of the
   /// memory manager. This option defaults to NULL.
-  EngineBuilder &setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm);
+  LLVM_ABI EngineBuilder &
+  setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm);
 
-  EngineBuilder&
+  LLVM_ABI EngineBuilder &
   setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM);
 
-  EngineBuilder &setSymbolResolver(std::unique_ptr<LegacyJITSymbolResolver> SR);
+  LLVM_ABI EngineBuilder &
+  setSymbolResolver(std::unique_ptr<LegacyJITSymbolResolver> SR);
 
   /// setErrorStr - Set the error string to write to on error.  This option
   /// defaults to NULL.
@@ -645,20 +648,19 @@ class EngineBuilder {
     this->EmulatedTLS = EmulatedTLS;
   }
 
-  TargetMachine *selectTarget();
+  LLVM_ABI TargetMachine *selectTarget();
 
   /// selectTarget - Pick a target either via -march or by guessing the native
   /// arch.  Add any CPU features specified via -mcpu or -mattr.
-  TargetMachine *selectTarget(const Triple &TargetTriple,
-                              StringRef MArch,
-                              StringRef MCPU,
-                              const SmallVectorImpl<std::string>& MAttrs);
+  LLVM_ABI TargetMachine *
+  selectTarget(const Triple &TargetTriple, StringRef MArch, StringRef MCPU,
+               const SmallVectorImpl<std::string> &MAttrs);
 
   ExecutionEngine *create() {
     return create(selectTarget());
   }
 
-  ExecutionEngine *create(TargetMachine *TM);
+  LLVM_ABI ExecutionEngine *create(TargetMachine *TM);
 };
 
 // Create wrappers for C Binding types (see CBindingWrapping.h).
diff --git a/llvm/include/llvm/ExecutionEngine/Interpreter.h b/llvm/include/llvm/ExecutionEngine/Interpreter.h
index 0749409766e39..b499cd6e0927c 100644
--- a/llvm/include/llvm/ExecutionEngine/Interpreter.h
+++ b/llvm/include/llvm/ExecutionEngine/Interpreter.h
@@ -15,8 +15,9 @@
 #define LLVM_EXECUTIONENGINE_INTERPRETER_H
 
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/Support/Compiler.h"
 
-extern "C" void LLVMLinkInInterpreter();
+extern "C" LLVM_ABI void LLVMLinkInInterpreter();
 
 namespace {
   struct ForceInterpreterLinking {
diff --git a/llvm/include/llvm/ExecutionEngine/JITEventListener.h b/llvm/include/llvm/ExecutionEngine/JITEventListener.h
index 7ccf8ff0d503d..e13ac1d3e976b 100644
--- a/llvm/include/llvm/ExecutionEngine/JITEventListener.h
+++ b/llvm/include/llvm/ExecutionEngine/JITEventListener.h
@@ -19,6 +19,7 @@
 #include "llvm/ExecutionEngine/RuntimeDyld.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/Support/CBindingWrapping.h"
+#include "llvm/Support/Compiler.h"
 #include <cstdint>
 
 namespace llvm {
@@ -37,7 +38,7 @@ class ObjectFile;
 /// profilers and debuggers that need to know where functions have been emitted.
 ///
 /// The default implementation of each method does nothing.
-class JITEventListener {
+class LLVM_ABI JITEventListener {
 public:
   using ObjectKey = uint64_t;
 
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h b/llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h
index 6bfa5506017df..3c6b7bbd1a87f 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ExecutionEngine/JITLink/JITLink.h"
 #include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include "llvm/TargetParser/Triple.h"
 
@@ -36,7 +37,7 @@ class EHFrameCFIBlockInspector {
   /// second to PC-begin, third (if present) to LSDA.
   ///
   /// It is illegal to call this function on a block with four or more edges.
-  static EHFrameCFIBlockInspector FromEdgeScan(Block &B);
+  LLVM_ABI static EHFrameCFIBlockInspector FromEdgeScan(Block &B);
 
   /// Returns true if this frame is an FDE, false for a CIE.
   bool isFDE() const { return CIEEdge != nullptr; }
@@ -85,7 +86,7 @@ class EHFrameCFIBlockInspector {
 
 /// Returns a pointer to the DWARF eh-frame section if the graph contains a
 /// non-empty one, otherwise returns null.
-Section *getEHFrameSection(LinkGraph &G);
+LLVM_ABI Section *getEHFrameSection(LinkGraph &G);
 
 } // end namespace jitlink
 } // end namespace llvm
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
index 8f0dfea0c97ac..b6b43c38b005f 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
@@ -27,6 +27,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/BinaryStreamReader.h"
 #include "llvm/Support/BinaryStreamWriter.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -49,7 +50,7 @@ class Section;
 
 /// Base class for errors originating in JIT linker, e.g. missing relocation
 /// support.
-class JITLinkError : public ErrorInfo<JITLinkError> {
+class LLVM_ABI JITLinkError : public ErrorInfo<JITLinkError> {
 public:
   static char ID;
 
@@ -105,7 +106,7 @@ class Edge {
 
 /// Returns the string name of the given generic edge kind, or "unknown"
 /// otherwise. Useful for debugging.
-const char *getGenericEdgeKindName(Edge::Kind K);
+LLVM_ABI const char *getGenericEdgeKindName(Edge::Kind K);
 
 /// Base class for Addressable entities (externals, absolutes, blocks).
 class Addressable {
@@ -389,7 +390,7 @@ inline orc::ExecutorAddr alignToBlock(orc::ExecutorAddr Addr, const Block &B) {
 // Returns true if the given blocks contains exactly one valid c-string.
 // Zero-fill blocks of size 1 count as valid empty strings. Content blocks
 // must end with a zero, and contain no zeros before the end.
-bool isCStringBlock(Block &B);
+LLVM_ABI bool isCStringBlock(Block &B);
 
 /// Describes symbol linkage. This can be used to resolve definition clashes.
 enum class Linkage : uint8_t {
@@ -401,7 +402,7 @@ enum class Linkage : uint8_t {
 using TargetFlagsType = uint8_t;
 
 /// For errors and debugging output.
-const char *getLinkageName(Linkage L);
+LLVM_ABI const char *getLinkageName(Linkage L);
 
 /// Defines the scope in which this symbol should be visible:
 ///   Default -- Visible in the public interface of the linkage unit.
@@ -412,9 +413,9 @@ const char *getLinkageName(Linkage L);
 enum class Scope : uint8_t { Default, Hidden, SideEffectsOnly, Local };
 
 /// For debugging output.
-const char *getScopeName(Scope S);
+LLVM_ABI const char *getScopeName(Scope S);
 
-raw_ostream &operator<<(raw_ostream &OS, const Block &B);
+LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const Block &B);
 
 /// Symbol representation.
 ///
@@ -708,10 +709,10 @@ class Symbol {
   size_t Size = 0;
 };
 
-raw_ostream &operator<<(raw_ostream &OS, const Symbol &A);
+LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const Symbol &A);
 
-void printEdge(raw_ostream &OS, const Block &B, const Edge &E,
-               StringRef EdgeKindName);
+LLVM_ABI void printEdge(raw_ostream &OS, const Block &B, const Edge &E,
+                        StringRef EdgeKindName);
 
 /// Represents an object file section.
 class Section {
@@ -731,7 +732,7 @@ class Section {
   using block_iterator = BlockSet::iterator;
   using const_block_iterator = BlockSet::const_iterator;
 
-  ~Section();
+  LLVM_ABI ~Section();
 
   // Sections are not movable or copyable.
   Section(const Section &) = delete;
@@ -1039,7 +1040,7 @@ class LinkGraph {
   LinkGraph &operator=(const LinkGraph &) = delete;
   LinkGraph(LinkGraph &&) = delete;
   LinkGraph &operator=(LinkGraph &&) = delete;
-  ~LinkGraph();
+  LLVM_ABI ~LinkGraph();
 
   /// Returns the name of this graph (usually the name of the original
   /// underlying MemoryBuffer).
@@ -1658,11 +1659,11 @@ class LinkGraph {
   orc::shared::AllocActions &allocActions() { return AAs; }
 
   /// Dump the graph.
-  void dump(raw_ostream &OS);
+  LLVM_ABI void dump(raw_ostream &OS);
 
 private:
-  std::vector<Block *> splitBlockImpl(std::vector<Block *> Blocks,
-                                      SplitBlockCache *Cache);
+  LLVM_ABI std::vector<Block *> splitBlockImpl(std::vector<Block *> Blocks,
+                                               SplitBlockCache *Cache);
 
   // Put the BumpPtrAllocator first so that we don't free any of the underlying
   // memory until the Symbol/Addressable destructors have been run.
@@ -1894,7 +1895,7 @@ struct PassConfiguration {
 ///        the two types once we have an OrcSupport library.
 enum class SymbolLookupFlags { RequiredSymbol, WeaklyReferencedSymbol };
 
-raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupFlags &LF);
+LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupFlags &LF);
 
 /// A map of symbol names to resolved addresses.
 using AsyncLookupResult =
@@ -1902,7 +1903,7 @@ using AsyncLookupResult =
 
 /// A function object to call with a resolved symbol map (See AsyncLookupResult)
 /// or an error if resolution failed.
-class JITLinkAsyncLookupContinuation {
+class LLVM_ABI JITLinkAsyncLookupContinuation {
 public:
   virtual ~JITLinkAsyncLookupContinuation() = default;
   virtual void run(Expected<AsyncLookupResult> LR) = 0;
@@ -1929,7 +1930,7 @@ createLookupContinuation(Continuation Cont) {
 }
 
 /// Holds context for a single jitLink invocation.
-class JITLinkContext {
+class LLVM_ABI JITLinkContext {
 public:
   using LookupMap = DenseMap<orc::SymbolStringPtr, SymbolLookupFlags>;
 
@@ -1995,14 +1996,14 @@ class JITLinkContext {
 
 /// Marks all symbols in a graph live. This can be used as a default,
 /// conservative mark-live implementation.
-Error markAllSymbolsLive(LinkGraph &G);
+LLVM_ABI Error markAllSymbolsLive(LinkGraph &G);
 
 /// Create an out of range error for the given edge in the given block.
-Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B,
-                                const Edge &E);
+LLVM_ABI Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B,
+                                         const Edge &E);
 
-Error makeAlignmentError(llvm::orc::ExecutorAddr Loc, uint64_t Value, int N,
-                         const Edge &E);
+LLVM_ABI Error makeAlignmentError(llvm::orc::ExecutorAddr Loc, uint64_t Value,
+                                  int N, const Edge &E);
 
 /// Creates a new pointer block in the given section and returns an
 /// Anonymous symbol pointing to it.
@@ -2016,7 +2017,7 @@ using AnonymousPointerCreator =
                              Symbol *InitialTarget, uint64_t InitialAddend)>;
 
 /// Get target-specific AnonymousPointerCreator
-AnonymousPointerCreator getAnonymousPointerCreator(const Triple &TT);
+LLVM_ABI AnonymousPointerCreator getAnonymousPointerCreator(const Triple &TT);
 
 /// Create a jump stub that jumps via the pointer at the given symbol and
 /// an anonymous symbol pointing to it. Return the anonymous symbol.
@@ -2026,7 +2027,7 @@ using PointerJumpStubCreator = unique_function<Symbol &(
     LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)>;
 
 /// Get target-specific PointerJumpStubCreator
-PointerJumpStubCreator getPointerJumpStubCreator(const Triple &TT);
+LLVM_ABI PointerJumpStubCreator getPointerJumpStubCreator(const Triple &TT);
 
 /// Base case for edge-visitors where the visitor-list is empty.
 inline void visitEdge(LinkGraph &G, Block *B, Edge &E) {}
@@ -2063,17 +2064,18 @@ void visitExistingEdges(LinkGraph &G, VisitorTs &&...Vs) {
 /// Note: The graph does not take ownership of the underlying buffer, nor copy
 /// its contents. The caller is responsible for ensuring that the object buffer
 /// outlives the graph.
-Expected<std::unique_ptr<LinkGraph>>
+LLVM_ABI Expected<std::unique_ptr<LinkGraph>>
 createLinkGraphFromObject(MemoryBufferRef ObjectBuffer,
                           std::shared_ptr<orc::SymbolStringPool> SSP);
 
 /// Create a \c LinkGraph defining the given absolute symbols.
-std::unique_ptr<LinkGraph>
+LLVM_ABI std::unique_ptr<LinkGraph>
 absoluteSymbolsLinkGraph(Triple TT, std::shared_ptr<orc::SymbolStringPool> SSP,
                          orc::SymbolMap Symbols);
 
 /// Link the given graph.
-void link(std::unique_ptr<LinkGraph> G, std::unique_ptr<JITLinkContext> Ctx);
+LLVM_ABI void link(std::unique_ptr<LinkGraph> G,
+                   std::unique_ptr<JITLinkContext> Ctx);
 
 } // end namespace jitlink
 } // end namespace llvm
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
index 3242055020f7d..c7b1f6e0b2c36 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
@@ -21,6 +21,7 @@
 #include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
 #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MSVCErrorWorkarounds.h"
 #include "llvm/Support/Memory.h"
@@ -43,7 +44,7 @@ class Section;
 ///
 /// Instances of this class may be accessed concurrently from multiple threads
 /// and their implemetations should include any necessary synchronization.
-class JITLinkMemoryManager {
+class LLVM_ABI JITLinkMemoryManager {
 public:
 
   /// Represents a finalized allocation.
@@ -118,7 +119,7 @@ class JITLinkMemoryManager {
   ///
   /// If abandon is called then working memory and executor memory should both
   /// be freed.
-  class InFlightAlloc {
+  class LLVM_ABI InFlightAlloc {
   public:
     using OnFinalizedFunction = unique_function<void(Expected<FinalizedAlloc>)>;
     using OnAbandonedFunction = unique_function<void(Error)>;
@@ -250,7 +251,7 @@ class BasicLayout {
   using SegmentMap = orc::AllocGroupSmallMap<Segment>;
 
 public:
-  BasicLayout(LinkGraph &G);
+  LLVM_ABI BasicLayout(LinkGraph &G);
 
   /// Return a reference to the graph this allocation was created from.
   LinkGraph &getGraph() { return G; }
@@ -264,7 +265,7 @@ class BasicLayout {
   ///
   /// This function will return an error if any segment has an alignment that
   /// is higher than a page.
-  Expected<ContiguousPageBasedLayoutSizes>
+  LLVM_ABI Expected<ContiguousPageBasedLayoutSizes>
   getContiguousPageBasedLayoutSizes(uint64_t PageSize);
 
   /// Returns an iterator over the segments of the layout.
@@ -273,12 +274,12 @@ class BasicLayout {
   }
 
   /// Apply the layout to the graph.
-  Error apply();
+  LLVM_ABI Error apply();
 
   /// Returns a reference to the AllocActions in the graph.
   /// This convenience function saves callers from having to #include
   /// LinkGraph.h if all they need are allocation actions.
-  orc::shared::AllocActions &graphAllocActions();
+  LLVM_ABI orc::shared::AllocActions &graphAllocActions();
 
 private:
   LinkGraph &G;
@@ -320,22 +321,22 @@ class SimpleSegmentAlloc {
   using OnFinalizedFunction =
       JITLinkMemoryManager::InFlightAlloc::OnFinalizedFunction;
 
-  static void Create(JITLinkMemoryManager &MemMgr,
-                     std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT,
-                     const JITLinkDylib *JD, SegmentMap Segments,
-                     OnCreatedFunction OnCreated);
+  LLVM_ABI static void Create(JITLinkMemoryManager &MemMgr,
+                              std::shared_ptr<orc::SymbolStringPool> SSP,
+                              Triple TT, const JITLinkDylib *JD,
+                              SegmentMap Segments, OnCreatedFunction OnCreated);
 
-  static Expected<SimpleSegmentAlloc>
+  LLVM_ABI static Expected<SimpleSegmentAlloc>
   Create(JITLinkMemoryManager &MemMgr,
          std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT,
          const JITLinkDylib *JD, SegmentMap Segments);
 
-  SimpleSegmentAlloc(SimpleSegmentAlloc &&);
-  SimpleSegmentAlloc &operator=(SimpleSegmentAlloc &&);
-  ~SimpleSegmentAlloc();
+  LLVM_ABI SimpleSegmentAlloc(SimpleSegmentAlloc &&);
+  LLVM_ABI SimpleSegmentAlloc &operator=(SimpleSegmentAlloc &&);
+  LLVM_ABI ~SimpleSegmentAlloc();
 
   /// Returns the SegmentInfo for the given group.
-  SegmentInfo getSegInfo(orc::AllocGroup AG);
+  LLVM_ABI SegmentInfo getSegInfo(orc::AllocGroup AG);
 
   /// Finalize all groups (async version).
   void finalize(OnFinalizedFunction OnFinalized) {
@@ -359,7 +360,7 @@ class SimpleSegmentAlloc {
 };
 
 /// A JITLinkMemoryManager that allocates in-process memory.
-class InProcessMemoryManager : public JITLinkMemoryManager {
+class LLVM_ABI InProcessMemoryManager : public JITLinkMemoryManager {
 public:
   class IPInFlightAlloc;
 
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/MachO.h b/llvm/include/llvm/ExecutionEngine/JITLink/MachO.h
index b3bf96b8549f2..6a499b0f62556 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/MachO.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/MachO.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ExecutionEngine/JITLink/JITLink.h"
 #include "llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h"
+#include "llvm/Support/Compiler.h"
 
 namespace llvm {
 namespace jitlink {
@@ -24,7 +25,7 @@ namespace jitlink {
 /// Note: The graph does not take ownership of the underlying buffer, nor copy
 /// its contents. The caller is responsible for ensuring that the object buffer
 /// outlives the graph.
-Expected<std::unique_ptr<LinkGraph>>
+LLVM_ABI Expected<std::unique_ptr<LinkGraph>>
 createLinkGraphFromMachOObject(MemoryBufferRef ObjectBuffer,
                                std::shared_ptr<orc::SymbolStringPool> SSP);
 
@@ -32,8 +33,8 @@ createLinkGraphFromMachOObject(MemoryBufferRef ObjectBuffer,
 ///
 /// Uses conservative defaults for GOT and stub handling based on the target
 /// platform.
-void link_MachO(std::unique_ptr<LinkGraph> G,
-                std::unique_ptr<JITLinkContext> Ctx);
+LLVM_ABI void link_MachO(std::unique_ptr<LinkGraph> G,
+                         std::unique_ptr<JITLinkContext> Ctx);
 
 /// Get a pointer to the standard MachO data section (creates an empty
 /// section with RW- permissions and standard lifetime if one does not
@@ -56,7 +57,7 @@ inline Section &getMachODefaultTextSection(LinkGraph &G) {
 }
 
 /// Gets or creates a MachO header for the current LinkGraph.
-Expected<Symbol &> getOrCreateLocalMachOHeader(LinkGraph &G);
+LLVM_ABI Expected<Symbol &> getOrCreateLocalMachOHeader(LinkGraph &G);
 
 } // end namespace jitlink
 ...
[truncated]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants