Skip to content

[llvm] annotate remaining BinaryFormat and DebugInfo library interfaces for DLL export #145364

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

Merged
merged 3 commits into from
Jun 24, 2025

Conversation

andrurogerz
Copy link
Contributor

@andrurogerz andrurogerz commented Jun 23, 2025

Purpose

This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the remaining LLVM BinaryFormat and DebugInfo interfaces that were missed in, or modified since, previous patches. The 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.

Overview

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

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 June 23, 2025 18:38
@llvmbot
Copy link
Member

llvmbot commented Jun 23, 2025

@llvm/pr-subscribers-backend-directx
@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-debuginfo

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 remaining LLVM DebugInfo interface that was missed in, or modified since, previous patches. The 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.

Overview

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

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

Full diff: https://github.com/llvm/llvm-project/pull/145364.diff

4 Files Affected:

  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h (+5-3)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h (+11-8)
  • (modified) llvm/include/llvm/DebugInfo/LogicalView/Core/LVSourceLanguage.h (+2-1)
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h
index 32e8247ac4c22..4723f00a4d241 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h
@@ -10,6 +10,7 @@
 #define LLVM_DEBUGINFO_DWARF_DWARFCFIPRINTER_H
 
 #include "llvm/DebugInfo/DWARF/DWARFCFIProgram.h"
+#include "llvm/Support/Compiler.h"
 
 namespace llvm {
 
@@ -17,9 +18,10 @@ struct DIDumpOptions;
 
 namespace dwarf {
 
-void printCFIProgram(const CFIProgram &P, raw_ostream &OS,
-                     const DIDumpOptions &DumpOpts, unsigned IndentLevel,
-                     std::optional<uint64_t> Address);
+LLVM_ABI void printCFIProgram(const CFIProgram &P, raw_ostream &OS,
+                              const DIDumpOptions &DumpOpts,
+                              unsigned IndentLevel,
+                              std::optional<uint64_t> Address);
 
 } // end namespace dwarf
 
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h
index ad7358c28f16b..1d89ac3578c10 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h
@@ -106,11 +106,11 @@ class CFIProgram {
   };
 
   /// Get the OperandType as a "const char *".
-  static const char *operandTypeString(OperandType OT);
+  LLVM_ABI static const char *operandTypeString(OperandType OT);
 
   /// Retrieve the array describing the types of operands according to the enum
   /// above. This is indexed by opcode.
-  static ArrayRef<OperandType[MaxOperands]> getOperandTypes();
+  LLVM_ABI static ArrayRef<OperandType[MaxOperands]> getOperandTypes();
 
 private:
   std::vector<Instruction> Instructions;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
index 44432d3219111..ea414278c35d6 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
@@ -186,8 +186,9 @@ class DWARFExpressionPrinter {
   /// \param E to be printed
   /// \param OS to this stream
   /// \param GetNameForDWARFReg callback to return dwarf register name
-  static void print(const DWARFExpression *E, raw_ostream &OS,
-                    DIDumpOptions DumpOpts, DWARFUnit *U, bool IsEH = false);
+  LLVM_ABI static void print(const DWARFExpression *E, raw_ostream &OS,
+                             DIDumpOptions DumpOpts, DWARFUnit *U,
+                             bool IsEH = false);
 
   /// Print the expression in a format intended to be compact and useful to a
   /// user, but not perfectly unambiguous, or capable of representing every
@@ -199,9 +200,10 @@ class DWARFExpressionPrinter {
   /// \param GetNameForDWARFReg callback to return dwarf register name
   ///
   /// \returns true if the expression was successfully printed
-  static bool printCompact(const DWARFExpression *E, raw_ostream &OS,
-                           std::function<StringRef(uint64_t RegNum, bool IsEH)>
-                               GetNameForDWARFReg = nullptr);
+  LLVM_ABI static bool printCompact(
+      const DWARFExpression *E, raw_ostream &OS,
+      std::function<StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg =
+          nullptr);
 
   /// Pretty print a register opcode and operands.
   /// \param U within the context of this Dwarf unit, if any.
@@ -211,9 +213,10 @@ class DWARFExpressionPrinter {
   /// \param Operands to the opcode
   ///
   /// returns true if the Op was successfully printed
-  static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS,
-                                    DIDumpOptions DumpOpts, uint8_t Opcode,
-                                    ArrayRef<uint64_t> Operands);
+  LLVM_ABI static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS,
+                                             DIDumpOptions DumpOpts,
+                                             uint8_t Opcode,
+                                             ArrayRef<uint64_t> Operands);
 
 private:
   static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS,
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVSourceLanguage.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVSourceLanguage.h
index 52e4aa9701e44..f4ebfc914ad05 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVSourceLanguage.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVSourceLanguage.h
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/Support/Compiler.h"
 
 namespace llvm {
 namespace logicalview {
@@ -52,7 +53,7 @@ struct LVSourceLanguage {
 
   bool isValid() const { return Language != Invalid; }
   TaggedLanguage get() const { return Language; }
-  StringRef getName() const;
+  LLVM_ABI StringRef getName() const;
 
 private:
   TaggedLanguage Language = Invalid;

@andrurogerz andrurogerz force-pushed the llvmdll-misc-4 branch 2 times, most recently from aac30bd to 6609f11 Compare June 23, 2025 19:11
@andrurogerz andrurogerz changed the title [llvm] annotate remaining DebugInfo library interfaces for DLL export [llvm] annotate remaining BinaryFormat and DebugInfo library interfaces for DLL export Jun 23, 2025
@andrurogerz
Copy link
Contributor Author

@compnerd, @vgvassilev here's another one if you don't mind having a look, thanks

@compnerd compnerd merged commit 87ce754 into llvm:main Jun 24, 2025
7 checks passed
anthonyhatran pushed a commit to anthonyhatran/llvm-project that referenced this pull request Jun 26, 2025
…ces for DLL export (llvm#145364)

## Purpose

This patch is one in a series of code-mods that annotate LLVM’s public
interface for export. This patch annotates the remaining LLVM
BinaryFormat and DebugInfo interfaces that were missed in, or modified
since, previous patches. The 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 llvm#109483. Additional context is provided in
[this
discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307),
and documentation for `LLVM_ABI` and related annotations is found in the
LLVM repo
[here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst).

## Overview

These changes were generated automatically using the [Interface
Definition Scanner (IDS)](https://github.com/compnerd/ids) tool,
followed formatting with `git clang-format`.

## 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
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.

3 participants