[llvm] 1610d41 - [llvm] annotate interfaces in llvm/DWARFLinker and llvm/DWP for DLL export (#140782)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 28 09:32:10 PDT 2025
Author: Andrew Rogers
Date: 2025-05-28T09:32:07-07:00
New Revision: 1610d41d8397301c3c39486b7ed1d329f43aad5d
URL: https://github.com/llvm/llvm-project/commit/1610d41d8397301c3c39486b7ed1d329f43aad5d
DIFF: https://github.com/llvm/llvm-project/commit/1610d41d8397301c3c39486b7ed1d329f43aad5d.diff
LOG: [llvm] annotate interfaces in llvm/DWARFLinker and llvm/DWP for DLL export (#140782)
## Purpose
This patch is one in a series of code-mods that annotate LLVM’s public
interface for export. This patch annotates the `llvm/DWARFLinker` and
`llvm/DWP` libraries. 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](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).
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
Added:
Modified:
llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h
llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h
llvm/include/llvm/DWP/DWP.h
llvm/include/llvm/DWP/DWPError.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
index 3608e7821bbc4..b12d96812108e 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
@@ -21,6 +21,7 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
+#include "llvm/Support/Compiler.h"
#include <map>
namespace llvm {
@@ -211,7 +212,7 @@ using UnitListTy = std::vector<std::unique_ptr<CompileUnit>>;
/// a variable). These relocations are called ValidRelocs in the
/// AddressesInfo and are gathered as a very first step when we start
/// processing a object file.
-class DWARFLinker : public DWARFLinkerBase {
+class LLVM_ABI DWARFLinker : public DWARFLinkerBase {
public:
DWARFLinker(MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler,
std::function<StringRef(StringRef)> StringsTranslator)
@@ -586,19 +587,21 @@ class DWARFLinker : public DWARFLinkerBase {
/// applied to the entry point of the function to get the linked address.
/// \param Die the output DIE to use, pass NULL to create one.
/// \returns the root of the cloned tree or null if nothing was selected.
- DIE *cloneDIE(const DWARFDie &InputDIE, const DWARFFile &File,
- CompileUnit &U, int64_t PCOffset, uint32_t OutOffset,
- unsigned Flags, bool IsLittleEndian, DIE *Die = nullptr);
+ LLVM_ABI DIE *cloneDIE(const DWARFDie &InputDIE, const DWARFFile &File,
+ CompileUnit &U, int64_t PCOffset, uint32_t OutOffset,
+ unsigned Flags, bool IsLittleEndian,
+ DIE *Die = nullptr);
/// Construct the output DIE tree by cloning the DIEs we
/// chose to keep above. If there are no valid relocs, then there's
/// nothing to clone/emit.
- uint64_t cloneAllCompileUnits(DWARFContext &DwarfContext,
- const DWARFFile &File, bool IsLittleEndian);
+ LLVM_ABI uint64_t cloneAllCompileUnits(DWARFContext &DwarfContext,
+ const DWARFFile &File,
+ bool IsLittleEndian);
/// Emit the .debug_addr section for the \p Unit.
- void emitDebugAddrSection(CompileUnit &Unit,
- const uint16_t DwarfVersion) const;
+ LLVM_ABI void emitDebugAddrSection(CompileUnit &Unit,
+ const uint16_t DwarfVersion) const;
using ExpressionHandlerRef = function_ref<void(
SmallVectorImpl<uint8_t> &, SmallVectorImpl<uint8_t> &,
@@ -606,8 +609,9 @@ class DWARFLinker : public DWARFLinkerBase {
/// Compute and emit debug locations (.debug_loc, .debug_loclists)
/// for \p Unit, patch the attributes referencing it.
- void generateUnitLocations(CompileUnit &Unit, const DWARFFile &File,
- ExpressionHandlerRef ExprHandler);
+ LLVM_ABI void generateUnitLocations(CompileUnit &Unit,
+ const DWARFFile &File,
+ ExpressionHandlerRef ExprHandler);
private:
using AttributeSpec = DWARFAbbreviationDeclaration::AttributeSpec;
diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h
index 7106889d8ec76..714badfabf89c 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h
@@ -13,6 +13,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
+#include "llvm/Support/Compiler.h"
#include <optional>
namespace llvm {
@@ -142,9 +143,9 @@ class CompileUnit {
bool hasODR() const { return HasODR; }
bool isClangModule() const { return !ClangModuleName.empty(); }
- uint16_t getLanguage();
+ LLVM_ABI uint16_t getLanguage();
/// Return the DW_AT_LLVM_sysroot of the compile unit or an empty StringRef.
- StringRef getSysRoot();
+ LLVM_ABI StringRef getSysRoot();
const std::string &getClangModuleName() const { return ClangModuleName; }
@@ -185,60 +186,62 @@ class CompileUnit {
/// Mark every DIE in this unit as kept. This function also
/// marks variables as InDebugMap so that they appear in the
/// reconstructed accelerator tables.
- void markEverythingAsKept();
+ LLVM_ABI void markEverythingAsKept();
/// Compute the end offset for this unit. Must be called after the CU's DIEs
/// have been cloned. \returns the next unit offset (which is also the
/// current debug_info section size).
- uint64_t computeNextUnitOffset(uint16_t DwarfVersion);
+ LLVM_ABI uint64_t computeNextUnitOffset(uint16_t DwarfVersion);
/// Keep track of a forward reference to DIE \p Die in \p RefUnit by \p
/// Attr. The attribute should be fixed up later to point to the absolute
/// offset of \p Die in the debug_info section or to the canonical offset of
/// \p Ctxt if it is non-null.
- void noteForwardReference(DIE *Die, const CompileUnit *RefUnit,
- DeclContext *Ctxt, PatchLocation Attr);
+ LLVM_ABI void noteForwardReference(DIE *Die, const CompileUnit *RefUnit,
+ DeclContext *Ctxt, PatchLocation Attr);
/// Apply all fixups recorded by noteForwardReference().
- void fixupForwardReferences();
+ LLVM_ABI void fixupForwardReferences();
/// Add the low_pc of a label that is relocated by applying
/// offset \p PCOffset.
- void addLabelLowPc(uint64_t LabelLowPc, int64_t PcOffset);
+ LLVM_ABI void addLabelLowPc(uint64_t LabelLowPc, int64_t PcOffset);
/// Add a function range [\p LowPC, \p HighPC) that is relocated by applying
/// offset \p PCOffset.
- void addFunctionRange(uint64_t LowPC, uint64_t HighPC, int64_t PCOffset);
+ LLVM_ABI void addFunctionRange(uint64_t LowPC, uint64_t HighPC,
+ int64_t PCOffset);
/// Keep track of a DW_AT_range attribute that we will need to patch up later.
- void noteRangeAttribute(const DIE &Die, PatchLocation Attr);
+ LLVM_ABI void noteRangeAttribute(const DIE &Die, PatchLocation Attr);
/// Keep track of a location attribute pointing to a location list in the
/// debug_loc section.
- void noteLocationAttribute(PatchLocation Attr);
+ LLVM_ABI void noteLocationAttribute(PatchLocation Attr);
// Record that the given DW_AT_LLVM_stmt_sequence attribute may need to be
// patched later.
- void noteStmtSeqListAttribute(PatchLocation Attr);
+ LLVM_ABI void noteStmtSeqListAttribute(PatchLocation Attr);
/// Add a name accelerator entry for \a Die with \a Name.
- void addNamespaceAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name);
+ LLVM_ABI void addNamespaceAccelerator(const DIE *Die,
+ DwarfStringPoolEntryRef Name);
/// Add a name accelerator entry for \a Die with \a Name.
- void addNameAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
- bool SkipPubnamesSection = false);
+ LLVM_ABI void addNameAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
+ bool SkipPubnamesSection = false);
/// Add various accelerator entries for \p Die with \p Name which is stored
/// in the string table at \p Offset. \p Name must be an Objective-C
/// selector.
- void addObjCAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
- bool SkipPubnamesSection = false);
+ LLVM_ABI void addObjCAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
+ bool SkipPubnamesSection = false);
/// Add a type accelerator entry for \p Die with \p Name which is stored in
/// the string table at \p Offset.
- void addTypeAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
- bool ObjcClassImplementation,
- uint32_t QualifiedNameHash);
+ LLVM_ABI void addTypeAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
+ bool ObjcClassImplementation,
+ uint32_t QualifiedNameHash);
struct AccelInfo {
/// Name of the entry.
diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
index f0d658ffbef94..03fc7290aacca 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
@@ -18,6 +18,7 @@
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetMachine.h"
namespace llvm {
@@ -41,7 +42,7 @@ namespace classic {
///
/// All interactions with the MC layer that is used to build the debug
/// information binary representation are handled in this class.
-class DwarfStreamer : public DwarfEmitter {
+class LLVM_ABI DwarfStreamer : public DwarfEmitter {
public:
DwarfStreamer(DWARFLinkerBase::OutputFileType OutFileType,
raw_pwrite_stream &OutFile,
diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h b/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
index 70b25cf02df7f..17a18c4b029f4 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
@@ -17,6 +17,7 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
+#include "llvm/Support/Compiler.h"
#include <map>
namespace llvm {
class DWARFUnit;
@@ -68,7 +69,7 @@ getSectionName(DebugSectionKind SectionKind) {
}
/// Recognise the table name and match it with the DebugSectionKind.
-std::optional<DebugSectionKind> parseDebugTableName(StringRef Name);
+LLVM_ABI std::optional<DebugSectionKind> parseDebugTableName(StringRef Name);
/// The base interface for DWARFLinker implementations.
class DWARFLinkerBase {
diff --git a/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h
index 8acc046d07249..80465136dd286 100644
--- a/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h
@@ -15,6 +15,7 @@
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/MC/MCDwarf.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/TargetParser/Triple.h"
/// ------------------------------------------------------------------
@@ -122,7 +123,7 @@ class DWARFLinker : public DWARFLinkerBase {
virtual ~DWARFLinker() = default;
/// Creates dwarf linker instance.
- static std::unique_ptr<DWARFLinker>
+ LLVM_ABI static std::unique_ptr<DWARFLinker>
createLinker(MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler);
/// Set output DWARF handler. Result of linking DWARF is set of sections
diff --git a/llvm/include/llvm/DWP/DWP.h b/llvm/include/llvm/DWP/DWP.h
index 9925deaa636b3..37d2d27af5b6b 100644
--- a/llvm/include/llvm/DWP/DWP.h
+++ b/llvm/include/llvm/DWP/DWP.h
@@ -10,6 +10,7 @@
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include <deque>
#include <vector>
@@ -66,12 +67,13 @@ struct CompileUnitIdentifiers {
const char *DWOName = "";
};
-Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
- OnCuIndexOverflow OverflowOptValue);
+LLVM_ABI Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
+ OnCuIndexOverflow OverflowOptValue);
-unsigned getContributionIndex(DWARFSectionKind Kind, uint32_t IndexVersion);
+LLVM_ABI unsigned getContributionIndex(DWARFSectionKind Kind,
+ uint32_t IndexVersion);
-Error handleSection(
+LLVM_ABI Error handleSection(
const StringMap<std::pair<MCSection *, DWARFSectionKind>> &KnownSections,
const MCSection *StrSection, const MCSection *StrOffsetSection,
const MCSection *TypesSection, const MCSection *CUIndexSection,
@@ -85,20 +87,24 @@ Error handleSection(
StringRef &CurCUIndexSection, StringRef &CurTUIndexSection,
std::vector<std::pair<DWARFSectionKind, uint32_t>> &SectionLength);
-Expected<InfoSectionUnitHeader> parseInfoSectionUnitHeader(StringRef Info);
+LLVM_ABI Expected<InfoSectionUnitHeader>
+parseInfoSectionUnitHeader(StringRef Info);
-void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
- MCSection *StrOffsetSection,
- StringRef CurStrSection,
- StringRef CurStrOffsetSection, uint16_t Version);
+LLVM_ABI void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
+ MCSection *StrOffsetSection,
+ StringRef CurStrSection,
+ StringRef CurStrOffsetSection,
+ uint16_t Version);
-Error buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
- const CompileUnitIdentifiers &ID, StringRef DWPName);
+LLVM_ABI Error
+buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
+ const CompileUnitIdentifiers &ID, StringRef DWPName);
-void writeIndex(MCStreamer &Out, MCSection *Section,
- ArrayRef<unsigned> ContributionOffsets,
- const MapVector<uint64_t, UnitIndexEntry> &IndexEntries,
- uint32_t IndexVersion);
+LLVM_ABI void
+writeIndex(MCStreamer &Out, MCSection *Section,
+ ArrayRef<unsigned> ContributionOffsets,
+ const MapVector<uint64_t, UnitIndexEntry> &IndexEntries,
+ uint32_t IndexVersion);
} // namespace llvm
#endif // LLVM_DWP_DWP_H
diff --git a/llvm/include/llvm/DWP/DWPError.h b/llvm/include/llvm/DWP/DWPError.h
index a690ef3109bbf..e226e3d7b4054 100644
--- a/llvm/include/llvm/DWP/DWPError.h
+++ b/llvm/include/llvm/DWP/DWPError.h
@@ -1,6 +1,7 @@
#ifndef LLVM_DWP_DWPERROR_H
#define LLVM_DWP_DWPERROR_H
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include <string>
@@ -13,7 +14,7 @@ class DWPError : public ErrorInfo<DWPError> {
std::error_code convertToErrorCode() const override {
llvm_unreachable("Not implemented");
}
- static char ID;
+ LLVM_ABI static char ID;
private:
std::string Info;
More information about the llvm-commits
mailing list