Skip to content

[llvm] annotate interfaces in llvm/Support for DLL export #136014

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 4 commits into
base: main
Choose a base branch
from

Conversation

andrurogerz
Copy link
Contributor

@andrurogerz andrurogerz commented Apr 16, 2025

Purpose

This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the llvm/Support 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:

  • LLVM_TEMPLATE_ABI and LLVM_EXPORT_TEMPLATE were added to exported instantiated templates
  • LLVM_ABI was added to a subset of private class methods that required export
  • LLVM_ABI was added to a small number of symbols that required export but were not declared in headers
  • LLVM_ABI_FRIEND was added to a small number of friend function declarations
  • LLVM_ABI annotations were elevated from method-level to class-level to support correct vtable export when necessary

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

@llvmbot
Copy link
Member

llvmbot commented Apr 16, 2025

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

@llvm/pr-subscribers-backend-hexagon

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/Support 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

Additional context on this effort 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:

  • LLVM_TEMPLATE_ABI and LLVM_EXPORT_TEMPLATE were added to exported instantiated templates
  • LLVM_ABI was added to a subset of private class methods that required export
  • LLVM_ABI was added to a small number of symbols that required export but were not declared in headers
  • LLVM_ABI annotations were elevated from method-level to class-level to support correct vtable export when necessary

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 415.71 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/136014.diff

126 Files Affected:

  • (modified) llvm/include/llvm/Support/AArch64AttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/AMDGPUMetadata.h (+3-2)
  • (modified) llvm/include/llvm/Support/ARMAttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/ARMBuildAttributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/ARMWinEH.h (+3-2)
  • (modified) llvm/include/llvm/Support/Allocator.h (+3-2)
  • (modified) llvm/include/llvm/Support/BalancedPartitioning.h (+7-6)
  • (modified) llvm/include/llvm/Support/Base64.h (+3-1)
  • (modified) llvm/include/llvm/Support/BinaryStreamError.h (+2-1)
  • (modified) llvm/include/llvm/Support/BinaryStreamReader.h (+2-1)
  • (modified) llvm/include/llvm/Support/BinaryStreamRef.h (+20-17)
  • (modified) llvm/include/llvm/Support/BinaryStreamWriter.h (+15-13)
  • (modified) llvm/include/llvm/Support/BlockFrequency.h (+8-7)
  • (modified) llvm/include/llvm/Support/BranchProbability.h (+8-7)
  • (modified) llvm/include/llvm/Support/BuryPointer.h (+2-1)
  • (modified) llvm/include/llvm/Support/COM.h (+3-1)
  • (modified) llvm/include/llvm/Support/CRC.h (+4-3)
  • (modified) llvm/include/llvm/Support/CSKYAttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/CSKYAttributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/CachePruning.h (+6-3)
  • (modified) llvm/include/llvm/Support/Caching.h (+2-1)
  • (modified) llvm/include/llvm/Support/Chrono.h (+24-12)
  • (modified) llvm/include/llvm/Support/CommandLine.h (+104-89)
  • (modified) llvm/include/llvm/Support/Compression.h (+30-25)
  • (modified) llvm/include/llvm/Support/ConvertEBCDIC.h (+4-3)
  • (modified) llvm/include/llvm/Support/ConvertUTF.h (+66-45)
  • (modified) llvm/include/llvm/Support/CrashRecoveryContext.h (+16-14)
  • (modified) llvm/include/llvm/Support/DJB.h (+2-1)
  • (modified) llvm/include/llvm/Support/DataExtractor.h (+29-21)
  • (modified) llvm/include/llvm/Support/Debug.h (+8-6)
  • (modified) llvm/include/llvm/Support/DebugCounter.h (+9-8)
  • (modified) llvm/include/llvm/Support/DivisionByConstantInfo.h (+3-2)
  • (modified) llvm/include/llvm/Support/DynamicLibrary.h (+13-12)
  • (modified) llvm/include/llvm/Support/ELFAttrParserCompact.h (+2-1)
  • (modified) llvm/include/llvm/Support/ELFAttrParserExtended.h (+2-1)
  • (modified) llvm/include/llvm/Support/ELFAttributes.h (+5-3)
  • (modified) llvm/include/llvm/Support/Errno.h (+3-2)
  • (modified) llvm/include/llvm/Support/Error.h (+23-17)
  • (modified) llvm/include/llvm/Support/ErrorHandling.h (+61-61)
  • (modified) llvm/include/llvm/Support/ExponentialBackoff.h (+2-1)
  • (modified) llvm/include/llvm/Support/ExtensibleRTTI.h (+3-1)
  • (modified) llvm/include/llvm/Support/FileCollector.h (+7-6)
  • (modified) llvm/include/llvm/Support/FileOutputBuffer.h (+2-1)
  • (modified) llvm/include/llvm/Support/FileSystem.h (+149-133)
  • (modified) llvm/include/llvm/Support/FileUtilities.h (+51-50)
  • (modified) llvm/include/llvm/Support/Format.h (+2-1)
  • (modified) llvm/include/llvm/Support/FormatVariadic.h (+2-1)
  • (modified) llvm/include/llvm/Support/FormatVariadicDetails.h (+3-2)
  • (modified) llvm/include/llvm/Support/FormattedStream.h (+5-4)
  • (modified) llvm/include/llvm/Support/GlobPattern.h (+5-4)
  • (modified) llvm/include/llvm/Support/GraphWriter.h (+6-5)
  • (modified) llvm/include/llvm/Support/HexagonAttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/HexagonAttributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/InitLLVM.h (+2-1)
  • (modified) llvm/include/llvm/Support/InstructionCost.h (+2-1)
  • (modified) llvm/include/llvm/Support/JSON.h (+47-45)
  • (modified) llvm/include/llvm/Support/KnownBits.h (+79-57)
  • (modified) llvm/include/llvm/Support/LEB128.h (+3-2)
  • (modified) llvm/include/llvm/Support/LineIterator.h (+2-1)
  • (modified) llvm/include/llvm/Support/Locale.h (+4-3)
  • (modified) llvm/include/llvm/Support/LockFileManager.h (+6-5)
  • (modified) llvm/include/llvm/Support/MD5.h (+12-10)
  • (modified) llvm/include/llvm/Support/MSP430AttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/MSP430Attributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/ManagedStatic.h (+5-3)
  • (modified) llvm/include/llvm/Support/MathExtras.h (+1-1)
  • (modified) llvm/include/llvm/Support/MemAlloc.h (+2-2)
  • (modified) llvm/include/llvm/Support/Memory.h (+12-10)
  • (modified) llvm/include/llvm/Support/MemoryBuffer.h (+21-20)
  • (modified) llvm/include/llvm/Support/MemoryBufferRef.h (+2-1)
  • (modified) llvm/include/llvm/Support/ModRef.h (+5-4)
  • (modified) llvm/include/llvm/Support/Mustache.h (+10-9)
  • (modified) llvm/include/llvm/Support/NativeFormatting.h (+23-20)
  • (modified) llvm/include/llvm/Support/OptimizedStructLayout.h (+4-3)
  • (modified) llvm/include/llvm/Support/PGOOptions.h (+14-11)
  • (modified) llvm/include/llvm/Support/Parallel.h (+10-8)
  • (modified) llvm/include/llvm/Support/Path.h (+78-70)
  • (modified) llvm/include/llvm/Support/PluginLoader.h (+5-3)
  • (modified) llvm/include/llvm/Support/PrettyStackTrace.h (+13-11)
  • (modified) llvm/include/llvm/Support/Process.h (+31-30)
  • (modified) llvm/include/llvm/Support/Program.h (+38-36)
  • (modified) llvm/include/llvm/Support/RISCVAttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/RISCVAttributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/RISCVISAUtils.h (+2-1)
  • (modified) llvm/include/llvm/Support/RandomNumberGenerator.h (+2-2)
  • (modified) llvm/include/llvm/Support/Recycler.h (+3-1)
  • (modified) llvm/include/llvm/Support/Regex.h (+15-13)
  • (modified) llvm/include/llvm/Support/SHA1.h (+7-6)
  • (modified) llvm/include/llvm/Support/SHA256.h (+7-6)
  • (modified) llvm/include/llvm/Support/SMTAPI.h (+6-5)
  • (modified) llvm/include/llvm/Support/ScaledNumber.h (+12-9)
  • (modified) llvm/include/llvm/Support/ScopedPrinter.h (+6-5)
  • (modified) llvm/include/llvm/Support/Signals.h (+87-85)
  • (modified) llvm/include/llvm/Support/Signposts.h (+6-5)
  • (modified) llvm/include/llvm/Support/SipHash.h (+6-5)
  • (modified) llvm/include/llvm/Support/SmallVectorMemoryBuffer.h (+2-1)
  • (modified) llvm/include/llvm/Support/SourceMgr.h (+31-30)
  • (modified) llvm/include/llvm/Support/SpecialCaseList.h (+23-19)
  • (modified) llvm/include/llvm/Support/StringSaver.h (+4-3)
  • (modified) llvm/include/llvm/Support/SuffixTree.h (+4-3)
  • (modified) llvm/include/llvm/Support/SuffixTreeNode.h (+16-15)
  • (modified) llvm/include/llvm/Support/SystemUtils.h (+3-1)
  • (modified) llvm/include/llvm/Support/TarWriter.h (+4-3)
  • (modified) llvm/include/llvm/Support/TargetSelect.h (+15-8)
  • (modified) llvm/include/llvm/Support/ThreadPool.h (+15-14)
  • (modified) llvm/include/llvm/Support/Threading.h (+13-12)
  • (modified) llvm/include/llvm/Support/TimeProfiler.h (+22-20)
  • (modified) llvm/include/llvm/Support/Timer.h (+22-19)
  • (modified) llvm/include/llvm/Support/ToolOutputFile.h (+3-2)
  • (modified) llvm/include/llvm/Support/TypeSize.h (+3-2)
  • (modified) llvm/include/llvm/Support/Unicode.h (+9-7)
  • (modified) llvm/include/llvm/Support/Valgrind.h (+5-4)
  • (modified) llvm/include/llvm/Support/VersionTuple.h (+4-3)
  • (modified) llvm/include/llvm/Support/VirtualFileSystem.h (+128-111)
  • (modified) llvm/include/llvm/Support/Windows/WindowsSupport.h (+10-8)
  • (modified) llvm/include/llvm/Support/WindowsError.h (+3-2)
  • (modified) llvm/include/llvm/Support/WithColor.h (+2-2)
  • (modified) llvm/include/llvm/Support/YAMLParser.h (+35-34)
  • (modified) llvm/include/llvm/Support/YAMLTraits.h (+124-122)
  • (modified) llvm/include/llvm/Support/raw_os_ostream.h (+2-1)
  • (modified) llvm/include/llvm/Support/raw_ostream.h (+74-70)
  • (modified) llvm/include/llvm/Support/raw_socket_stream.h (+12-11)
  • (modified) llvm/include/llvm/Support/thread.h (+7-6)
  • (modified) llvm/include/llvm/Support/xxhash.h (+5-4)
  • (modified) llvm/lib/Support/Chrono.cpp (+7-6)
  • (modified) llvm/lib/Support/CommandLine.cpp (+13-12)
diff --git a/llvm/include/llvm/Support/AArch64AttributeParser.h b/llvm/include/llvm/Support/AArch64AttributeParser.h
index 823ae180a5c5a..aa82ca13668d5 100644
--- a/llvm/include/llvm/Support/AArch64AttributeParser.h
+++ b/llvm/include/llvm/Support/AArch64AttributeParser.h
@@ -9,13 +9,14 @@
 #ifndef LLVM_SUPPORT_AARCH64ATTRIBUTEPARSER_H
 #define LLVM_SUPPORT_AARCH64ATTRIBUTEPARSER_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ELFAttrParserExtended.h"
 #include "llvm/Support/ELFAttributes.h"
 
 namespace llvm {
 
 class AArch64AttributeParser : public ELFExtendedAttrParser {
-  static std::vector<SubsectionAndTagToTagName> &returnTagsNamesMap();
+  LLVM_ABI static std::vector<SubsectionAndTagToTagName> &returnTagsNamesMap();
 
 public:
   AArch64AttributeParser(ScopedPrinter *Sw)
diff --git a/llvm/include/llvm/Support/AMDGPUMetadata.h b/llvm/include/llvm/Support/AMDGPUMetadata.h
index 76ac7ab74a32e..990c825ae6875 100644
--- a/llvm/include/llvm/Support/AMDGPUMetadata.h
+++ b/llvm/include/llvm/Support/AMDGPUMetadata.h
@@ -16,6 +16,7 @@
 #define LLVM_SUPPORT_AMDGPUMETADATA_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include <cstdint>
 #include <string>
 #include <system_error>
@@ -447,10 +448,10 @@ struct Metadata final {
 };
 
 /// Converts \p String to \p HSAMetadata.
-std::error_code fromString(StringRef String, Metadata &HSAMetadata);
+LLVM_ABI std::error_code fromString(StringRef String, Metadata &HSAMetadata);
 
 /// Converts \p HSAMetadata to \p String.
-std::error_code toString(Metadata HSAMetadata, std::string &String);
+LLVM_ABI std::error_code toString(Metadata HSAMetadata, std::string &String);
 
 //===----------------------------------------------------------------------===//
 // HSA metadata for v3 code object.
diff --git a/llvm/include/llvm/Support/ARMAttributeParser.h b/llvm/include/llvm/Support/ARMAttributeParser.h
index 749f9cd2213d7..0fd8a1ed57204 100644
--- a/llvm/include/llvm/Support/ARMAttributeParser.h
+++ b/llvm/include/llvm/Support/ARMAttributeParser.h
@@ -11,6 +11,7 @@
 
 #include "ARMBuildAttributes.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ELFAttrParserCompact.h"
 #include "llvm/Support/Error.h"
 
@@ -18,7 +19,7 @@ namespace llvm {
 
 class ScopedPrinter;
 
-class ARMAttributeParser : public ELFCompactAttrParser {
+class LLVM_ABI ARMAttributeParser : public ELFCompactAttrParser {
   struct DisplayHandler {
     ARMBuildAttrs::AttrType attribute;
     Error (ARMAttributeParser::*routine)(ARMBuildAttrs::AttrType);
diff --git a/llvm/include/llvm/Support/ARMBuildAttributes.h b/llvm/include/llvm/Support/ARMBuildAttributes.h
index 35f8992ca9329..68acf30e52f3e 100644
--- a/llvm/include/llvm/Support/ARMBuildAttributes.h
+++ b/llvm/include/llvm/Support/ARMBuildAttributes.h
@@ -18,12 +18,13 @@
 #ifndef LLVM_SUPPORT_ARMBUILDATTRIBUTES_H
 #define LLVM_SUPPORT_ARMBUILDATTRIBUTES_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ELFAttributes.h"
 
 namespace llvm {
 namespace ARMBuildAttrs {
 
-const TagNameMap &getARMAttributeTags();
+LLVM_ABI const TagNameMap &getARMAttributeTags();
 
 enum SpecialAttr {
   // This is for the .cpu asm attr. It translates into one or more
diff --git a/llvm/include/llvm/Support/ARMWinEH.h b/llvm/include/llvm/Support/ARMWinEH.h
index b6710cca95650..083bbf405a6b6 100644
--- a/llvm/include/llvm/Support/ARMWinEH.h
+++ b/llvm/include/llvm/Support/ARMWinEH.h
@@ -10,6 +10,7 @@
 #define LLVM_SUPPORT_ARMWINEH_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Endian.h"
 
 namespace llvm {
@@ -205,8 +206,8 @@ inline uint16_t StackAdjustment(const RuntimeFunction &RF) {
 
 /// SavedRegisterMask - Utility function to calculate the set of saved general
 /// purpose (r0-r15) and VFP (d0-d31) registers.
-std::pair<uint16_t, uint32_t> SavedRegisterMask(const RuntimeFunction &RF,
-                                                bool Prologue = true);
+LLVM_ABI std::pair<uint16_t, uint32_t>
+SavedRegisterMask(const RuntimeFunction &RF, bool Prologue = true);
 
 /// RuntimeFunctionARM64 - An entry in the table of procedure data (.pdata)
 ///
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index 568f0d34032fa..59934190a5206 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -36,8 +36,9 @@ namespace detail {
 
 // We call out to an external function to actually print the message as the
 // printing code uses Allocator.h in its implementation.
-void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
-                                size_t TotalMemory);
+LLVM_ABI void printBumpPtrAllocatorStats(unsigned NumSlabs,
+                                         size_t BytesAllocated,
+                                         size_t TotalMemory);
 
 } // end namespace detail
 
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h b/llvm/include/llvm/Support/BalancedPartitioning.h
index 539d157343fbe..05307d74c209c 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -41,6 +41,7 @@
 
 #include "raw_ostream.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Compiler.h"
 
 #include <atomic>
 #include <condition_variable>
@@ -67,7 +68,7 @@ class BPFunctionNode {
   /// The ID of this node
   IDT Id;
 
-  void dump(raw_ostream &OS) const;
+  LLVM_ABI void dump(raw_ostream &OS) const;
 
 protected:
   /// The list of utility nodes associated with this node
@@ -99,10 +100,10 @@ struct BalancedPartitioningConfig {
 
 class BalancedPartitioning {
 public:
-  BalancedPartitioning(const BalancedPartitioningConfig &Config);
+  LLVM_ABI BalancedPartitioning(const BalancedPartitioningConfig &Config);
 
   /// Run recursive graph partitioning that optimizes a given objective.
-  void run(std::vector<BPFunctionNode> &Nodes) const;
+  LLVM_ABI void run(std::vector<BPFunctionNode> &Nodes) const;
 
 private:
   struct UtilitySignature;
@@ -127,7 +128,7 @@ class BalancedPartitioning {
     /// Blocking wait for all threads to complete. Unlike ThreadPool, it is
     /// acceptable for other threads to add more tasks while blocking on this
     /// call.
-    void wait();
+    LLVM_ABI void wait();
     BPThreadPool(ThreadPoolInterface &TheThreadPool)
         : TheThreadPool(TheThreadPool) {}
   };
@@ -192,8 +193,8 @@ class BalancedPartitioning {
 
 protected:
   /// Compute the move gain for uniform log-gap cost
-  static float moveGain(const BPFunctionNode &N, bool FromLeftToRight,
-                        const SignaturesT &Signatures);
+  LLVM_ABI static float moveGain(const BPFunctionNode &N, bool FromLeftToRight,
+                                 const SignaturesT &Signatures);
   friend class BalancedPartitioningTest_MoveGain_Test;
 };
 
diff --git a/llvm/include/llvm/Support/Base64.h b/llvm/include/llvm/Support/Base64.h
index 3d96884749b32..0dbd87b37868d 100644
--- a/llvm/include/llvm/Support/Base64.h
+++ b/llvm/include/llvm/Support/Base64.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_SUPPORT_BASE64_H
 #define LLVM_SUPPORT_BASE64_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
 #include <string>
@@ -54,7 +55,8 @@ template <class InputBytes> std::string encodeBase64(InputBytes const &Bytes) {
   return Buffer;
 }
 
-llvm::Error decodeBase64(llvm::StringRef Input, std::vector<char> &Output);
+LLVM_ABI llvm::Error decodeBase64(llvm::StringRef Input,
+                                  std::vector<char> &Output);
 
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Support/BinaryStreamError.h b/llvm/include/llvm/Support/BinaryStreamError.h
index cf6e034ffd2ce..8a45f7bbd52cc 100644
--- a/llvm/include/llvm/Support/BinaryStreamError.h
+++ b/llvm/include/llvm/Support/BinaryStreamError.h
@@ -10,6 +10,7 @@
 #define LLVM_SUPPORT_BINARYSTREAMERROR_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 
 #include <string>
@@ -24,7 +25,7 @@ enum class stream_error_code {
 };
 
 /// Base class for errors originating when parsing raw PDB files
-class BinaryStreamError : public ErrorInfo<BinaryStreamError> {
+class LLVM_ABI BinaryStreamError : public ErrorInfo<BinaryStreamError> {
 public:
   static char ID;
   explicit BinaryStreamError(stream_error_code C);
diff --git a/llvm/include/llvm/Support/BinaryStreamReader.h b/llvm/include/llvm/Support/BinaryStreamReader.h
index ca99388c5d03a..e61349d841cdb 100644
--- a/llvm/include/llvm/Support/BinaryStreamReader.h
+++ b/llvm/include/llvm/Support/BinaryStreamReader.h
@@ -14,6 +14,7 @@
 #include "llvm/Support/Alignment.h"
 #include "llvm/Support/BinaryStreamArray.h"
 #include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
@@ -26,7 +27,7 @@ namespace llvm {
 /// null-terminated strings, integers in various flavors of endianness, etc.
 /// Can be subclassed to provide reading of custom datatypes, although no
 /// are overridable.
-class BinaryStreamReader {
+class LLVM_ABI BinaryStreamReader {
 public:
   BinaryStreamReader() = default;
   explicit BinaryStreamReader(BinaryStreamRef Ref);
diff --git a/llvm/include/llvm/Support/BinaryStreamRef.h b/llvm/include/llvm/Support/BinaryStreamRef.h
index fdc46f5fd5605..47009ff0b96fc 100644
--- a/llvm/include/llvm/Support/BinaryStreamRef.h
+++ b/llvm/include/llvm/Support/BinaryStreamRef.h
@@ -12,6 +12,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/BinaryStream.h"
 #include "llvm/Support/BinaryStreamError.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
 #include <memory>
@@ -160,11 +161,12 @@ class BinaryStreamRef
 
 public:
   BinaryStreamRef() = default;
-  BinaryStreamRef(BinaryStream &Stream);
-  BinaryStreamRef(BinaryStream &Stream, uint64_t Offset,
-                  std::optional<uint64_t> Length);
-  explicit BinaryStreamRef(ArrayRef<uint8_t> Data, llvm::endianness Endian);
-  explicit BinaryStreamRef(StringRef Data, llvm::endianness Endian);
+  LLVM_ABI BinaryStreamRef(BinaryStream &Stream);
+  LLVM_ABI BinaryStreamRef(BinaryStream &Stream, uint64_t Offset,
+                           std::optional<uint64_t> Length);
+  LLVM_ABI explicit BinaryStreamRef(ArrayRef<uint8_t> Data,
+                                    llvm::endianness Endian);
+  LLVM_ABI explicit BinaryStreamRef(StringRef Data, llvm::endianness Endian);
 
   BinaryStreamRef(const BinaryStreamRef &Other) = default;
   BinaryStreamRef &operator=(const BinaryStreamRef &Other) = default;
@@ -181,16 +183,16 @@ class BinaryStreamRef
   /// \returns a success error code if the entire range of data is within the
   /// bounds of this BinaryStreamRef's view and the implementation could read
   /// the data, and an appropriate error code otherwise.
-  Error readBytes(uint64_t Offset, uint64_t Size,
-                  ArrayRef<uint8_t> &Buffer) const;
+  LLVM_ABI Error readBytes(uint64_t Offset, uint64_t Size,
+                           ArrayRef<uint8_t> &Buffer) const;
 
   /// Given an Offset into this BinaryStreamRef, return a reference to the
   /// largest buffer the stream could support without necessitating a copy.
   ///
   /// \returns a success error code if implementation could read the data,
   /// and an appropriate error code otherwise.
-  Error readLongestContiguousChunk(uint64_t Offset,
-                                   ArrayRef<uint8_t> &Buffer) const;
+  LLVM_ABI Error readLongestContiguousChunk(uint64_t Offset,
+                                            ArrayRef<uint8_t> &Buffer) const;
 };
 
 struct BinarySubstreamRef {
@@ -233,11 +235,12 @@ class WritableBinaryStreamRef
 
 public:
   WritableBinaryStreamRef() = default;
-  WritableBinaryStreamRef(WritableBinaryStream &Stream);
-  WritableBinaryStreamRef(WritableBinaryStream &Stream, uint64_t Offset,
-                          std::optional<uint64_t> Length);
-  explicit WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
-                                   llvm::endianness Endian);
+  LLVM_ABI WritableBinaryStreamRef(WritableBinaryStream &Stream);
+  LLVM_ABI WritableBinaryStreamRef(WritableBinaryStream &Stream,
+                                   uint64_t Offset,
+                                   std::optional<uint64_t> Length);
+  LLVM_ABI explicit WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
+                                            llvm::endianness Endian);
   WritableBinaryStreamRef(const WritableBinaryStreamRef &Other) = default;
   WritableBinaryStreamRef &
   operator=(const WritableBinaryStreamRef &Other) = default;
@@ -255,13 +258,13 @@ class WritableBinaryStreamRef
   /// \returns a success error code if the data could fit within the underlying
   /// stream at the specified location and the implementation could write the
   /// data, and an appropriate error code otherwise.
-  Error writeBytes(uint64_t Offset, ArrayRef<uint8_t> Data) const;
+  LLVM_ABI Error writeBytes(uint64_t Offset, ArrayRef<uint8_t> Data) const;
 
   /// Conver this WritableBinaryStreamRef to a read-only BinaryStreamRef.
-  operator BinaryStreamRef() const;
+  LLVM_ABI operator BinaryStreamRef() const;
 
   /// For buffered streams, commits changes to the backing store.
-  Error commit();
+  LLVM_ABI Error commit();
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Support/BinaryStreamWriter.h b/llvm/include/llvm/Support/BinaryStreamWriter.h
index bc1d7949841d6..dddf53bd5483c 100644
--- a/llvm/include/llvm/Support/BinaryStreamWriter.h
+++ b/llvm/include/llvm/Support/BinaryStreamWriter.h
@@ -14,6 +14,7 @@
 #include "llvm/Support/BinaryStreamArray.h"
 #include "llvm/Support/BinaryStreamError.h"
 #include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
@@ -30,10 +31,10 @@ namespace llvm {
 class BinaryStreamWriter {
 public:
   BinaryStreamWriter() = default;
-  explicit BinaryStreamWriter(WritableBinaryStreamRef Ref);
-  explicit BinaryStreamWriter(WritableBinaryStream &Stream);
-  explicit BinaryStreamWriter(MutableArrayRef<uint8_t> Data,
-                              llvm::endianness Endian);
+  LLVM_ABI explicit BinaryStreamWriter(WritableBinaryStreamRef Ref);
+  LLVM_ABI explicit BinaryStreamWriter(WritableBinaryStream &Stream);
+  LLVM_ABI explicit BinaryStreamWriter(MutableArrayRef<uint8_t> Data,
+                                       llvm::endianness Endian);
 
   BinaryStreamWriter(const BinaryStreamWriter &Other) = default;
 
@@ -47,7 +48,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeBytes(ArrayRef<uint8_t> Buffer);
+  LLVM_ABI Error writeBytes(ArrayRef<uint8_t> Buffer);
 
   /// Write the integer \p Value to the underlying stream in the
   /// specified endianness.  On success, updates the offset so that
@@ -77,14 +78,14 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeULEB128(uint64_t Value);
+  LLVM_ABI Error writeULEB128(uint64_t Value);
 
   /// Write the unsigned integer Value to the underlying stream using ULEB128
   /// encoding.
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeSLEB128(int64_t Value);
+  LLVM_ABI Error writeSLEB128(int64_t Value);
 
   /// Write the string \p Str to the underlying stream followed by a null
   /// terminator.  On success, updates the offset so that subsequent writes
@@ -93,7 +94,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeCString(StringRef Str);
+  LLVM_ABI Error writeCString(StringRef Str);
 
   /// Write the string \p Str to the underlying stream without a null
   /// terminator.  On success, updates the offset so that subsequent writes
@@ -101,7 +102,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeFixedString(StringRef Str);
+  LLVM_ABI Error writeFixedString(StringRef Str);
 
   /// Efficiently reads all data from \p Ref, and writes it to this stream.
   /// This operation will not invoke any copies of the source data, regardless
@@ -109,7 +110,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeStreamRef(BinaryStreamRef Ref);
+  LLVM_ABI Error writeStreamRef(BinaryStreamRef Ref);
 
   /// Efficiently reads \p Size bytes from \p Ref, and writes it to this stream.
   /// This operation will not invoke any copies of the source data, regardless
@@ -117,7 +118,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeStreamRef(BinaryStreamRef Ref, uint64_t Size);
+  LLVM_ABI Error writeStreamRef(BinaryStreamRef Ref, uint64_t Size);
 
   /// Writes the object \p Obj to the underlying stream, as if by using memcpy.
   /// It is up to the caller to ensure that type of \p Obj can be safely copied
@@ -171,13 +172,14 @@ class BinaryStreamWriter {
   }
 
   /// Splits the Writer into two Writers at a given offset.
-  std::pair<BinaryStreamWriter, BinaryStreamWriter> split(uint64_t Off) const;
+  LLVM_ABI std::pair<BinaryStreamWriter, BinaryStreamWriter>
+  split(uint64_t Off) const;
 
   void setOffset(uint64_t Off) { Offset = Off; }
   uint64_t getOffset() const { return Offset; }
   uint64_t getLength() const { return Stream.getLength(); }
   uint64_t bytesRemaining() const { return getLength() - getOffset(); }
-  Error padToAlignment(uint32_t Align);
+  LLVM_ABI Error padToAlignment(uint32_t Align);
 
 protected:
   WritableBinaryStreamRef Stream;
diff --git a/llvm/include/llvm/Support/BlockFrequency.h b/llvm/include/llvm/Support/BlockFrequency.h
index aeab99615a951..eb979af8aa376 100644
--- a/llvm/include/llvm/Support/BlockFrequency.h
+++ b/llvm/include/llvm/Support/BlockFrequency.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_SUPPORT_BLOCKFREQUENCY_H
 #define LLVM_SUPPORT_BLOCKFREQUENCY_H
 
+#include "llvm/Support/Compiler.h"
 #include <cassert>
 #include <cstdint>
 #include <optional>
@@ -39,13 +40,13 @@ class BlockFrequency {
 
   /// Multiplies with a branch probability. The computation will never
   /// overflow.
-  BlockFrequency &operator*=(BranchProbability Prob);
-  BlockFrequency operator*(BranchProbability Prob) const;
+  LLVM_ABI BlockFrequency &operator*=(BranchProbability Prob);
+  LLVM_ABI BlockFrequency operator*(BranchProbability Prob) const;
 
   /// Divide by a non-zero branch probability using saturating
   /// arithmetic.
-  BlockFrequency &operator/=(BranchProbability Prob);
-  BlockFrequency operator/(BranchProbability Prob) const;
+  LLVM_ABI BlockFrequency &operator/=(BranchProbability Prob);
+  LLVM_ABI BlockFrequency operator/(BranchProbability Prob) const;
 
   /// Adds another block frequency using saturating arithmetic.
   BlockFrequency &operator+=(BlockFrequency Freq) {
@@ -80,7 +81,7 @@ class BlockFrequency {
   }
 
   /// Multiplies frequency with `Factor`. Returns `nullopt` in case of overflow.
-  std::optional<BlockFrequency> mul(uint64_t Factor) const;
+  LLVM_ABI std::optional<BlockFrequency> mul(uint64_t Factor) const;
 
   /// Shift block frequency to the right by count digits saturating to 1.
   BlockFrequency &operator>>=(const unsigned count) {
@@ -120,8 +121,8 @@ class BlockFrequency {
   }
 };
 
-void printRelativeBlockFreq(raw_ostream &OS, BlockFrequency EntryFreq,
-                            BlockFrequency Freq);
+LLVM_ABI void printRelativeBlockFreq(raw_ostream &OS, BlockFrequency EntryFreq,
+                                     BlockFrequency Freq);
 
 } // namespace llvm
 
diff --git a/llvm/include/llvm/Support/BranchProbability.h b/llvm/include/llvm/Support/BranchProbability.h
index 79d70cf611d41..90448...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Apr 16, 2025

@llvm/pr-subscribers-backend-amdgpu

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/Support 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

Additional context on this effort 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:

  • LLVM_TEMPLATE_ABI and LLVM_EXPORT_TEMPLATE were added to exported instantiated templates
  • LLVM_ABI was added to a subset of private class methods that required export
  • LLVM_ABI was added to a small number of symbols that required export but were not declared in headers
  • LLVM_ABI annotations were elevated from method-level to class-level to support correct vtable export when necessary

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 415.71 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/136014.diff

126 Files Affected:

  • (modified) llvm/include/llvm/Support/AArch64AttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/AMDGPUMetadata.h (+3-2)
  • (modified) llvm/include/llvm/Support/ARMAttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/ARMBuildAttributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/ARMWinEH.h (+3-2)
  • (modified) llvm/include/llvm/Support/Allocator.h (+3-2)
  • (modified) llvm/include/llvm/Support/BalancedPartitioning.h (+7-6)
  • (modified) llvm/include/llvm/Support/Base64.h (+3-1)
  • (modified) llvm/include/llvm/Support/BinaryStreamError.h (+2-1)
  • (modified) llvm/include/llvm/Support/BinaryStreamReader.h (+2-1)
  • (modified) llvm/include/llvm/Support/BinaryStreamRef.h (+20-17)
  • (modified) llvm/include/llvm/Support/BinaryStreamWriter.h (+15-13)
  • (modified) llvm/include/llvm/Support/BlockFrequency.h (+8-7)
  • (modified) llvm/include/llvm/Support/BranchProbability.h (+8-7)
  • (modified) llvm/include/llvm/Support/BuryPointer.h (+2-1)
  • (modified) llvm/include/llvm/Support/COM.h (+3-1)
  • (modified) llvm/include/llvm/Support/CRC.h (+4-3)
  • (modified) llvm/include/llvm/Support/CSKYAttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/CSKYAttributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/CachePruning.h (+6-3)
  • (modified) llvm/include/llvm/Support/Caching.h (+2-1)
  • (modified) llvm/include/llvm/Support/Chrono.h (+24-12)
  • (modified) llvm/include/llvm/Support/CommandLine.h (+104-89)
  • (modified) llvm/include/llvm/Support/Compression.h (+30-25)
  • (modified) llvm/include/llvm/Support/ConvertEBCDIC.h (+4-3)
  • (modified) llvm/include/llvm/Support/ConvertUTF.h (+66-45)
  • (modified) llvm/include/llvm/Support/CrashRecoveryContext.h (+16-14)
  • (modified) llvm/include/llvm/Support/DJB.h (+2-1)
  • (modified) llvm/include/llvm/Support/DataExtractor.h (+29-21)
  • (modified) llvm/include/llvm/Support/Debug.h (+8-6)
  • (modified) llvm/include/llvm/Support/DebugCounter.h (+9-8)
  • (modified) llvm/include/llvm/Support/DivisionByConstantInfo.h (+3-2)
  • (modified) llvm/include/llvm/Support/DynamicLibrary.h (+13-12)
  • (modified) llvm/include/llvm/Support/ELFAttrParserCompact.h (+2-1)
  • (modified) llvm/include/llvm/Support/ELFAttrParserExtended.h (+2-1)
  • (modified) llvm/include/llvm/Support/ELFAttributes.h (+5-3)
  • (modified) llvm/include/llvm/Support/Errno.h (+3-2)
  • (modified) llvm/include/llvm/Support/Error.h (+23-17)
  • (modified) llvm/include/llvm/Support/ErrorHandling.h (+61-61)
  • (modified) llvm/include/llvm/Support/ExponentialBackoff.h (+2-1)
  • (modified) llvm/include/llvm/Support/ExtensibleRTTI.h (+3-1)
  • (modified) llvm/include/llvm/Support/FileCollector.h (+7-6)
  • (modified) llvm/include/llvm/Support/FileOutputBuffer.h (+2-1)
  • (modified) llvm/include/llvm/Support/FileSystem.h (+149-133)
  • (modified) llvm/include/llvm/Support/FileUtilities.h (+51-50)
  • (modified) llvm/include/llvm/Support/Format.h (+2-1)
  • (modified) llvm/include/llvm/Support/FormatVariadic.h (+2-1)
  • (modified) llvm/include/llvm/Support/FormatVariadicDetails.h (+3-2)
  • (modified) llvm/include/llvm/Support/FormattedStream.h (+5-4)
  • (modified) llvm/include/llvm/Support/GlobPattern.h (+5-4)
  • (modified) llvm/include/llvm/Support/GraphWriter.h (+6-5)
  • (modified) llvm/include/llvm/Support/HexagonAttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/HexagonAttributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/InitLLVM.h (+2-1)
  • (modified) llvm/include/llvm/Support/InstructionCost.h (+2-1)
  • (modified) llvm/include/llvm/Support/JSON.h (+47-45)
  • (modified) llvm/include/llvm/Support/KnownBits.h (+79-57)
  • (modified) llvm/include/llvm/Support/LEB128.h (+3-2)
  • (modified) llvm/include/llvm/Support/LineIterator.h (+2-1)
  • (modified) llvm/include/llvm/Support/Locale.h (+4-3)
  • (modified) llvm/include/llvm/Support/LockFileManager.h (+6-5)
  • (modified) llvm/include/llvm/Support/MD5.h (+12-10)
  • (modified) llvm/include/llvm/Support/MSP430AttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/MSP430Attributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/ManagedStatic.h (+5-3)
  • (modified) llvm/include/llvm/Support/MathExtras.h (+1-1)
  • (modified) llvm/include/llvm/Support/MemAlloc.h (+2-2)
  • (modified) llvm/include/llvm/Support/Memory.h (+12-10)
  • (modified) llvm/include/llvm/Support/MemoryBuffer.h (+21-20)
  • (modified) llvm/include/llvm/Support/MemoryBufferRef.h (+2-1)
  • (modified) llvm/include/llvm/Support/ModRef.h (+5-4)
  • (modified) llvm/include/llvm/Support/Mustache.h (+10-9)
  • (modified) llvm/include/llvm/Support/NativeFormatting.h (+23-20)
  • (modified) llvm/include/llvm/Support/OptimizedStructLayout.h (+4-3)
  • (modified) llvm/include/llvm/Support/PGOOptions.h (+14-11)
  • (modified) llvm/include/llvm/Support/Parallel.h (+10-8)
  • (modified) llvm/include/llvm/Support/Path.h (+78-70)
  • (modified) llvm/include/llvm/Support/PluginLoader.h (+5-3)
  • (modified) llvm/include/llvm/Support/PrettyStackTrace.h (+13-11)
  • (modified) llvm/include/llvm/Support/Process.h (+31-30)
  • (modified) llvm/include/llvm/Support/Program.h (+38-36)
  • (modified) llvm/include/llvm/Support/RISCVAttributeParser.h (+2-1)
  • (modified) llvm/include/llvm/Support/RISCVAttributes.h (+2-1)
  • (modified) llvm/include/llvm/Support/RISCVISAUtils.h (+2-1)
  • (modified) llvm/include/llvm/Support/RandomNumberGenerator.h (+2-2)
  • (modified) llvm/include/llvm/Support/Recycler.h (+3-1)
  • (modified) llvm/include/llvm/Support/Regex.h (+15-13)
  • (modified) llvm/include/llvm/Support/SHA1.h (+7-6)
  • (modified) llvm/include/llvm/Support/SHA256.h (+7-6)
  • (modified) llvm/include/llvm/Support/SMTAPI.h (+6-5)
  • (modified) llvm/include/llvm/Support/ScaledNumber.h (+12-9)
  • (modified) llvm/include/llvm/Support/ScopedPrinter.h (+6-5)
  • (modified) llvm/include/llvm/Support/Signals.h (+87-85)
  • (modified) llvm/include/llvm/Support/Signposts.h (+6-5)
  • (modified) llvm/include/llvm/Support/SipHash.h (+6-5)
  • (modified) llvm/include/llvm/Support/SmallVectorMemoryBuffer.h (+2-1)
  • (modified) llvm/include/llvm/Support/SourceMgr.h (+31-30)
  • (modified) llvm/include/llvm/Support/SpecialCaseList.h (+23-19)
  • (modified) llvm/include/llvm/Support/StringSaver.h (+4-3)
  • (modified) llvm/include/llvm/Support/SuffixTree.h (+4-3)
  • (modified) llvm/include/llvm/Support/SuffixTreeNode.h (+16-15)
  • (modified) llvm/include/llvm/Support/SystemUtils.h (+3-1)
  • (modified) llvm/include/llvm/Support/TarWriter.h (+4-3)
  • (modified) llvm/include/llvm/Support/TargetSelect.h (+15-8)
  • (modified) llvm/include/llvm/Support/ThreadPool.h (+15-14)
  • (modified) llvm/include/llvm/Support/Threading.h (+13-12)
  • (modified) llvm/include/llvm/Support/TimeProfiler.h (+22-20)
  • (modified) llvm/include/llvm/Support/Timer.h (+22-19)
  • (modified) llvm/include/llvm/Support/ToolOutputFile.h (+3-2)
  • (modified) llvm/include/llvm/Support/TypeSize.h (+3-2)
  • (modified) llvm/include/llvm/Support/Unicode.h (+9-7)
  • (modified) llvm/include/llvm/Support/Valgrind.h (+5-4)
  • (modified) llvm/include/llvm/Support/VersionTuple.h (+4-3)
  • (modified) llvm/include/llvm/Support/VirtualFileSystem.h (+128-111)
  • (modified) llvm/include/llvm/Support/Windows/WindowsSupport.h (+10-8)
  • (modified) llvm/include/llvm/Support/WindowsError.h (+3-2)
  • (modified) llvm/include/llvm/Support/WithColor.h (+2-2)
  • (modified) llvm/include/llvm/Support/YAMLParser.h (+35-34)
  • (modified) llvm/include/llvm/Support/YAMLTraits.h (+124-122)
  • (modified) llvm/include/llvm/Support/raw_os_ostream.h (+2-1)
  • (modified) llvm/include/llvm/Support/raw_ostream.h (+74-70)
  • (modified) llvm/include/llvm/Support/raw_socket_stream.h (+12-11)
  • (modified) llvm/include/llvm/Support/thread.h (+7-6)
  • (modified) llvm/include/llvm/Support/xxhash.h (+5-4)
  • (modified) llvm/lib/Support/Chrono.cpp (+7-6)
  • (modified) llvm/lib/Support/CommandLine.cpp (+13-12)
diff --git a/llvm/include/llvm/Support/AArch64AttributeParser.h b/llvm/include/llvm/Support/AArch64AttributeParser.h
index 823ae180a5c5a..aa82ca13668d5 100644
--- a/llvm/include/llvm/Support/AArch64AttributeParser.h
+++ b/llvm/include/llvm/Support/AArch64AttributeParser.h
@@ -9,13 +9,14 @@
 #ifndef LLVM_SUPPORT_AARCH64ATTRIBUTEPARSER_H
 #define LLVM_SUPPORT_AARCH64ATTRIBUTEPARSER_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ELFAttrParserExtended.h"
 #include "llvm/Support/ELFAttributes.h"
 
 namespace llvm {
 
 class AArch64AttributeParser : public ELFExtendedAttrParser {
-  static std::vector<SubsectionAndTagToTagName> &returnTagsNamesMap();
+  LLVM_ABI static std::vector<SubsectionAndTagToTagName> &returnTagsNamesMap();
 
 public:
   AArch64AttributeParser(ScopedPrinter *Sw)
diff --git a/llvm/include/llvm/Support/AMDGPUMetadata.h b/llvm/include/llvm/Support/AMDGPUMetadata.h
index 76ac7ab74a32e..990c825ae6875 100644
--- a/llvm/include/llvm/Support/AMDGPUMetadata.h
+++ b/llvm/include/llvm/Support/AMDGPUMetadata.h
@@ -16,6 +16,7 @@
 #define LLVM_SUPPORT_AMDGPUMETADATA_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include <cstdint>
 #include <string>
 #include <system_error>
@@ -447,10 +448,10 @@ struct Metadata final {
 };
 
 /// Converts \p String to \p HSAMetadata.
-std::error_code fromString(StringRef String, Metadata &HSAMetadata);
+LLVM_ABI std::error_code fromString(StringRef String, Metadata &HSAMetadata);
 
 /// Converts \p HSAMetadata to \p String.
-std::error_code toString(Metadata HSAMetadata, std::string &String);
+LLVM_ABI std::error_code toString(Metadata HSAMetadata, std::string &String);
 
 //===----------------------------------------------------------------------===//
 // HSA metadata for v3 code object.
diff --git a/llvm/include/llvm/Support/ARMAttributeParser.h b/llvm/include/llvm/Support/ARMAttributeParser.h
index 749f9cd2213d7..0fd8a1ed57204 100644
--- a/llvm/include/llvm/Support/ARMAttributeParser.h
+++ b/llvm/include/llvm/Support/ARMAttributeParser.h
@@ -11,6 +11,7 @@
 
 #include "ARMBuildAttributes.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ELFAttrParserCompact.h"
 #include "llvm/Support/Error.h"
 
@@ -18,7 +19,7 @@ namespace llvm {
 
 class ScopedPrinter;
 
-class ARMAttributeParser : public ELFCompactAttrParser {
+class LLVM_ABI ARMAttributeParser : public ELFCompactAttrParser {
   struct DisplayHandler {
     ARMBuildAttrs::AttrType attribute;
     Error (ARMAttributeParser::*routine)(ARMBuildAttrs::AttrType);
diff --git a/llvm/include/llvm/Support/ARMBuildAttributes.h b/llvm/include/llvm/Support/ARMBuildAttributes.h
index 35f8992ca9329..68acf30e52f3e 100644
--- a/llvm/include/llvm/Support/ARMBuildAttributes.h
+++ b/llvm/include/llvm/Support/ARMBuildAttributes.h
@@ -18,12 +18,13 @@
 #ifndef LLVM_SUPPORT_ARMBUILDATTRIBUTES_H
 #define LLVM_SUPPORT_ARMBUILDATTRIBUTES_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ELFAttributes.h"
 
 namespace llvm {
 namespace ARMBuildAttrs {
 
-const TagNameMap &getARMAttributeTags();
+LLVM_ABI const TagNameMap &getARMAttributeTags();
 
 enum SpecialAttr {
   // This is for the .cpu asm attr. It translates into one or more
diff --git a/llvm/include/llvm/Support/ARMWinEH.h b/llvm/include/llvm/Support/ARMWinEH.h
index b6710cca95650..083bbf405a6b6 100644
--- a/llvm/include/llvm/Support/ARMWinEH.h
+++ b/llvm/include/llvm/Support/ARMWinEH.h
@@ -10,6 +10,7 @@
 #define LLVM_SUPPORT_ARMWINEH_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Endian.h"
 
 namespace llvm {
@@ -205,8 +206,8 @@ inline uint16_t StackAdjustment(const RuntimeFunction &RF) {
 
 /// SavedRegisterMask - Utility function to calculate the set of saved general
 /// purpose (r0-r15) and VFP (d0-d31) registers.
-std::pair<uint16_t, uint32_t> SavedRegisterMask(const RuntimeFunction &RF,
-                                                bool Prologue = true);
+LLVM_ABI std::pair<uint16_t, uint32_t>
+SavedRegisterMask(const RuntimeFunction &RF, bool Prologue = true);
 
 /// RuntimeFunctionARM64 - An entry in the table of procedure data (.pdata)
 ///
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index 568f0d34032fa..59934190a5206 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -36,8 +36,9 @@ namespace detail {
 
 // We call out to an external function to actually print the message as the
 // printing code uses Allocator.h in its implementation.
-void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
-                                size_t TotalMemory);
+LLVM_ABI void printBumpPtrAllocatorStats(unsigned NumSlabs,
+                                         size_t BytesAllocated,
+                                         size_t TotalMemory);
 
 } // end namespace detail
 
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h b/llvm/include/llvm/Support/BalancedPartitioning.h
index 539d157343fbe..05307d74c209c 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -41,6 +41,7 @@
 
 #include "raw_ostream.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Compiler.h"
 
 #include <atomic>
 #include <condition_variable>
@@ -67,7 +68,7 @@ class BPFunctionNode {
   /// The ID of this node
   IDT Id;
 
-  void dump(raw_ostream &OS) const;
+  LLVM_ABI void dump(raw_ostream &OS) const;
 
 protected:
   /// The list of utility nodes associated with this node
@@ -99,10 +100,10 @@ struct BalancedPartitioningConfig {
 
 class BalancedPartitioning {
 public:
-  BalancedPartitioning(const BalancedPartitioningConfig &Config);
+  LLVM_ABI BalancedPartitioning(const BalancedPartitioningConfig &Config);
 
   /// Run recursive graph partitioning that optimizes a given objective.
-  void run(std::vector<BPFunctionNode> &Nodes) const;
+  LLVM_ABI void run(std::vector<BPFunctionNode> &Nodes) const;
 
 private:
   struct UtilitySignature;
@@ -127,7 +128,7 @@ class BalancedPartitioning {
     /// Blocking wait for all threads to complete. Unlike ThreadPool, it is
     /// acceptable for other threads to add more tasks while blocking on this
     /// call.
-    void wait();
+    LLVM_ABI void wait();
     BPThreadPool(ThreadPoolInterface &TheThreadPool)
         : TheThreadPool(TheThreadPool) {}
   };
@@ -192,8 +193,8 @@ class BalancedPartitioning {
 
 protected:
   /// Compute the move gain for uniform log-gap cost
-  static float moveGain(const BPFunctionNode &N, bool FromLeftToRight,
-                        const SignaturesT &Signatures);
+  LLVM_ABI static float moveGain(const BPFunctionNode &N, bool FromLeftToRight,
+                                 const SignaturesT &Signatures);
   friend class BalancedPartitioningTest_MoveGain_Test;
 };
 
diff --git a/llvm/include/llvm/Support/Base64.h b/llvm/include/llvm/Support/Base64.h
index 3d96884749b32..0dbd87b37868d 100644
--- a/llvm/include/llvm/Support/Base64.h
+++ b/llvm/include/llvm/Support/Base64.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_SUPPORT_BASE64_H
 #define LLVM_SUPPORT_BASE64_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
 #include <string>
@@ -54,7 +55,8 @@ template <class InputBytes> std::string encodeBase64(InputBytes const &Bytes) {
   return Buffer;
 }
 
-llvm::Error decodeBase64(llvm::StringRef Input, std::vector<char> &Output);
+LLVM_ABI llvm::Error decodeBase64(llvm::StringRef Input,
+                                  std::vector<char> &Output);
 
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Support/BinaryStreamError.h b/llvm/include/llvm/Support/BinaryStreamError.h
index cf6e034ffd2ce..8a45f7bbd52cc 100644
--- a/llvm/include/llvm/Support/BinaryStreamError.h
+++ b/llvm/include/llvm/Support/BinaryStreamError.h
@@ -10,6 +10,7 @@
 #define LLVM_SUPPORT_BINARYSTREAMERROR_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 
 #include <string>
@@ -24,7 +25,7 @@ enum class stream_error_code {
 };
 
 /// Base class for errors originating when parsing raw PDB files
-class BinaryStreamError : public ErrorInfo<BinaryStreamError> {
+class LLVM_ABI BinaryStreamError : public ErrorInfo<BinaryStreamError> {
 public:
   static char ID;
   explicit BinaryStreamError(stream_error_code C);
diff --git a/llvm/include/llvm/Support/BinaryStreamReader.h b/llvm/include/llvm/Support/BinaryStreamReader.h
index ca99388c5d03a..e61349d841cdb 100644
--- a/llvm/include/llvm/Support/BinaryStreamReader.h
+++ b/llvm/include/llvm/Support/BinaryStreamReader.h
@@ -14,6 +14,7 @@
 #include "llvm/Support/Alignment.h"
 #include "llvm/Support/BinaryStreamArray.h"
 #include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
@@ -26,7 +27,7 @@ namespace llvm {
 /// null-terminated strings, integers in various flavors of endianness, etc.
 /// Can be subclassed to provide reading of custom datatypes, although no
 /// are overridable.
-class BinaryStreamReader {
+class LLVM_ABI BinaryStreamReader {
 public:
   BinaryStreamReader() = default;
   explicit BinaryStreamReader(BinaryStreamRef Ref);
diff --git a/llvm/include/llvm/Support/BinaryStreamRef.h b/llvm/include/llvm/Support/BinaryStreamRef.h
index fdc46f5fd5605..47009ff0b96fc 100644
--- a/llvm/include/llvm/Support/BinaryStreamRef.h
+++ b/llvm/include/llvm/Support/BinaryStreamRef.h
@@ -12,6 +12,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/BinaryStream.h"
 #include "llvm/Support/BinaryStreamError.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
 #include <memory>
@@ -160,11 +161,12 @@ class BinaryStreamRef
 
 public:
   BinaryStreamRef() = default;
-  BinaryStreamRef(BinaryStream &Stream);
-  BinaryStreamRef(BinaryStream &Stream, uint64_t Offset,
-                  std::optional<uint64_t> Length);
-  explicit BinaryStreamRef(ArrayRef<uint8_t> Data, llvm::endianness Endian);
-  explicit BinaryStreamRef(StringRef Data, llvm::endianness Endian);
+  LLVM_ABI BinaryStreamRef(BinaryStream &Stream);
+  LLVM_ABI BinaryStreamRef(BinaryStream &Stream, uint64_t Offset,
+                           std::optional<uint64_t> Length);
+  LLVM_ABI explicit BinaryStreamRef(ArrayRef<uint8_t> Data,
+                                    llvm::endianness Endian);
+  LLVM_ABI explicit BinaryStreamRef(StringRef Data, llvm::endianness Endian);
 
   BinaryStreamRef(const BinaryStreamRef &Other) = default;
   BinaryStreamRef &operator=(const BinaryStreamRef &Other) = default;
@@ -181,16 +183,16 @@ class BinaryStreamRef
   /// \returns a success error code if the entire range of data is within the
   /// bounds of this BinaryStreamRef's view and the implementation could read
   /// the data, and an appropriate error code otherwise.
-  Error readBytes(uint64_t Offset, uint64_t Size,
-                  ArrayRef<uint8_t> &Buffer) const;
+  LLVM_ABI Error readBytes(uint64_t Offset, uint64_t Size,
+                           ArrayRef<uint8_t> &Buffer) const;
 
   /// Given an Offset into this BinaryStreamRef, return a reference to the
   /// largest buffer the stream could support without necessitating a copy.
   ///
   /// \returns a success error code if implementation could read the data,
   /// and an appropriate error code otherwise.
-  Error readLongestContiguousChunk(uint64_t Offset,
-                                   ArrayRef<uint8_t> &Buffer) const;
+  LLVM_ABI Error readLongestContiguousChunk(uint64_t Offset,
+                                            ArrayRef<uint8_t> &Buffer) const;
 };
 
 struct BinarySubstreamRef {
@@ -233,11 +235,12 @@ class WritableBinaryStreamRef
 
 public:
   WritableBinaryStreamRef() = default;
-  WritableBinaryStreamRef(WritableBinaryStream &Stream);
-  WritableBinaryStreamRef(WritableBinaryStream &Stream, uint64_t Offset,
-                          std::optional<uint64_t> Length);
-  explicit WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
-                                   llvm::endianness Endian);
+  LLVM_ABI WritableBinaryStreamRef(WritableBinaryStream &Stream);
+  LLVM_ABI WritableBinaryStreamRef(WritableBinaryStream &Stream,
+                                   uint64_t Offset,
+                                   std::optional<uint64_t> Length);
+  LLVM_ABI explicit WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
+                                            llvm::endianness Endian);
   WritableBinaryStreamRef(const WritableBinaryStreamRef &Other) = default;
   WritableBinaryStreamRef &
   operator=(const WritableBinaryStreamRef &Other) = default;
@@ -255,13 +258,13 @@ class WritableBinaryStreamRef
   /// \returns a success error code if the data could fit within the underlying
   /// stream at the specified location and the implementation could write the
   /// data, and an appropriate error code otherwise.
-  Error writeBytes(uint64_t Offset, ArrayRef<uint8_t> Data) const;
+  LLVM_ABI Error writeBytes(uint64_t Offset, ArrayRef<uint8_t> Data) const;
 
   /// Conver this WritableBinaryStreamRef to a read-only BinaryStreamRef.
-  operator BinaryStreamRef() const;
+  LLVM_ABI operator BinaryStreamRef() const;
 
   /// For buffered streams, commits changes to the backing store.
-  Error commit();
+  LLVM_ABI Error commit();
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Support/BinaryStreamWriter.h b/llvm/include/llvm/Support/BinaryStreamWriter.h
index bc1d7949841d6..dddf53bd5483c 100644
--- a/llvm/include/llvm/Support/BinaryStreamWriter.h
+++ b/llvm/include/llvm/Support/BinaryStreamWriter.h
@@ -14,6 +14,7 @@
 #include "llvm/Support/BinaryStreamArray.h"
 #include "llvm/Support/BinaryStreamError.h"
 #include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
@@ -30,10 +31,10 @@ namespace llvm {
 class BinaryStreamWriter {
 public:
   BinaryStreamWriter() = default;
-  explicit BinaryStreamWriter(WritableBinaryStreamRef Ref);
-  explicit BinaryStreamWriter(WritableBinaryStream &Stream);
-  explicit BinaryStreamWriter(MutableArrayRef<uint8_t> Data,
-                              llvm::endianness Endian);
+  LLVM_ABI explicit BinaryStreamWriter(WritableBinaryStreamRef Ref);
+  LLVM_ABI explicit BinaryStreamWriter(WritableBinaryStream &Stream);
+  LLVM_ABI explicit BinaryStreamWriter(MutableArrayRef<uint8_t> Data,
+                                       llvm::endianness Endian);
 
   BinaryStreamWriter(const BinaryStreamWriter &Other) = default;
 
@@ -47,7 +48,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeBytes(ArrayRef<uint8_t> Buffer);
+  LLVM_ABI Error writeBytes(ArrayRef<uint8_t> Buffer);
 
   /// Write the integer \p Value to the underlying stream in the
   /// specified endianness.  On success, updates the offset so that
@@ -77,14 +78,14 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeULEB128(uint64_t Value);
+  LLVM_ABI Error writeULEB128(uint64_t Value);
 
   /// Write the unsigned integer Value to the underlying stream using ULEB128
   /// encoding.
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeSLEB128(int64_t Value);
+  LLVM_ABI Error writeSLEB128(int64_t Value);
 
   /// Write the string \p Str to the underlying stream followed by a null
   /// terminator.  On success, updates the offset so that subsequent writes
@@ -93,7 +94,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeCString(StringRef Str);
+  LLVM_ABI Error writeCString(StringRef Str);
 
   /// Write the string \p Str to the underlying stream without a null
   /// terminator.  On success, updates the offset so that subsequent writes
@@ -101,7 +102,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeFixedString(StringRef Str);
+  LLVM_ABI Error writeFixedString(StringRef Str);
 
   /// Efficiently reads all data from \p Ref, and writes it to this stream.
   /// This operation will not invoke any copies of the source data, regardless
@@ -109,7 +110,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeStreamRef(BinaryStreamRef Ref);
+  LLVM_ABI Error writeStreamRef(BinaryStreamRef Ref);
 
   /// Efficiently reads \p Size bytes from \p Ref, and writes it to this stream.
   /// This operation will not invoke any copies of the source data, regardless
@@ -117,7 +118,7 @@ class BinaryStreamWriter {
   ///
   /// \returns a success error code if the data was successfully written,
   /// otherwise returns an appropriate error code.
-  Error writeStreamRef(BinaryStreamRef Ref, uint64_t Size);
+  LLVM_ABI Error writeStreamRef(BinaryStreamRef Ref, uint64_t Size);
 
   /// Writes the object \p Obj to the underlying stream, as if by using memcpy.
   /// It is up to the caller to ensure that type of \p Obj can be safely copied
@@ -171,13 +172,14 @@ class BinaryStreamWriter {
   }
 
   /// Splits the Writer into two Writers at a given offset.
-  std::pair<BinaryStreamWriter, BinaryStreamWriter> split(uint64_t Off) const;
+  LLVM_ABI std::pair<BinaryStreamWriter, BinaryStreamWriter>
+  split(uint64_t Off) const;
 
   void setOffset(uint64_t Off) { Offset = Off; }
   uint64_t getOffset() const { return Offset; }
   uint64_t getLength() const { return Stream.getLength(); }
   uint64_t bytesRemaining() const { return getLength() - getOffset(); }
-  Error padToAlignment(uint32_t Align);
+  LLVM_ABI Error padToAlignment(uint32_t Align);
 
 protected:
   WritableBinaryStreamRef Stream;
diff --git a/llvm/include/llvm/Support/BlockFrequency.h b/llvm/include/llvm/Support/BlockFrequency.h
index aeab99615a951..eb979af8aa376 100644
--- a/llvm/include/llvm/Support/BlockFrequency.h
+++ b/llvm/include/llvm/Support/BlockFrequency.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_SUPPORT_BLOCKFREQUENCY_H
 #define LLVM_SUPPORT_BLOCKFREQUENCY_H
 
+#include "llvm/Support/Compiler.h"
 #include <cassert>
 #include <cstdint>
 #include <optional>
@@ -39,13 +40,13 @@ class BlockFrequency {
 
   /// Multiplies with a branch probability. The computation will never
   /// overflow.
-  BlockFrequency &operator*=(BranchProbability Prob);
-  BlockFrequency operator*(BranchProbability Prob) const;
+  LLVM_ABI BlockFrequency &operator*=(BranchProbability Prob);
+  LLVM_ABI BlockFrequency operator*(BranchProbability Prob) const;
 
   /// Divide by a non-zero branch probability using saturating
   /// arithmetic.
-  BlockFrequency &operator/=(BranchProbability Prob);
-  BlockFrequency operator/(BranchProbability Prob) const;
+  LLVM_ABI BlockFrequency &operator/=(BranchProbability Prob);
+  LLVM_ABI BlockFrequency operator/(BranchProbability Prob) const;
 
   /// Adds another block frequency using saturating arithmetic.
   BlockFrequency &operator+=(BlockFrequency Freq) {
@@ -80,7 +81,7 @@ class BlockFrequency {
   }
 
   /// Multiplies frequency with `Factor`. Returns `nullopt` in case of overflow.
-  std::optional<BlockFrequency> mul(uint64_t Factor) const;
+  LLVM_ABI std::optional<BlockFrequency> mul(uint64_t Factor) const;
 
   /// Shift block frequency to the right by count digits saturating to 1.
   BlockFrequency &operator>>=(const unsigned count) {
@@ -120,8 +121,8 @@ class BlockFrequency {
   }
 };
 
-void printRelativeBlockFreq(raw_ostream &OS, BlockFrequency EntryFreq,
-                            BlockFrequency Freq);
+LLVM_ABI void printRelativeBlockFreq(raw_ostream &OS, BlockFrequency EntryFreq,
+                                     BlockFrequency Freq);
 
 } // namespace llvm
 
diff --git a/llvm/include/llvm/Support/BranchProbability.h b/llvm/include/llvm/Support/BranchProbability.h
index 79d70cf611d41..90448...
[truncated]

@andrurogerz
Copy link
Contributor Author

++ @compnerd

@nikic
Copy link
Contributor

nikic commented Apr 22, 2025

The following manual adjustments were also applied after running IDS:

Is it possible to separate the manual adjustments into a separate commit? I'd like to understand the degree of fixing that is required on top of ids.

@andrurogerz
Copy link
Contributor Author

Is it possible to separate the manual adjustments into a separate commit? I'd like to understand the degree of fixing that is required on top of ids.

That's a good idea. Should not be too hard, let me take a look.

@andrurogerz andrurogerz force-pushed the llvmdll-lib-support branch from 0861af0 to 792c168 Compare April 22, 2025 22:31
@andrurogerz
Copy link
Contributor Author

Is it possible to separate the manual adjustments into a separate commit? I'd like to understand the degree of fixing that is required on top of ids.

@nikic I revised the commit history; the sequence of commits should be self explanatory, but let me know if you have questions. I am going to put together another couple of these annotation patches for review and will follow the same sequence of commits.

@nikic
Copy link
Contributor

nikic commented Apr 23, 2025

Thanks, that's very useful! TBH, I didn't expect that there would be that much cleanup afterwards. I understand some of it (e.g. code under different macros), but some of this feels like it shouldn't require manual fixup.

For example, are there ever cases where we don't want to add LLVM_ABI on classes with virtual methods?

Though I can't say I really get under which circumstances we need LLVM_ABI on the class for non-virtual cases. E.g. why do we need it on StringSaver?

@andrurogerz
Copy link
Contributor Author

@nikic thank you for taking a look, I appreciate the questions and feedback.

For example, are there ever cases where we don't want to add LLVM_ABI on classes with virtual methods?

I think it will be sufficient to have a simple "annotate at the class level for any class with a virtual method" rule. However, I have not found this to always be necessary in practice-- I think it depends on whether or not parts of the class or its children are implemented outside the class declarations. But simplicity should win here, and having a simple rule to follow would be better and (I think) simple enough to automate in IDS. I will get a definitive answer on this one, update the documentation to clarify, and attempt to update IDS to automate it.

Though I can't say I really get under which circumstances we need LLVM_ABI on the class for non-virtual cases. E.g. why do we need it on StringSaver?

It should not be necessary on classes without virtual methods, and what you're seeing here are mistakes. There are a few classes where I elevated the annotation unnecessarily like StringSaver, InitLLVM, and InitializeCOMRAII. The key here is that class-level annotation is harmless, but we should avoid it in general so we don't blow past the 64K DLL export method limit. I will definitely fix the instances I find, though. Thank you for flagging it.

@vgvassilev
Copy link
Contributor

Can we mention #109483 in the PR descriptions of that work?

@andrurogerz andrurogerz force-pushed the llvmdll-lib-support branch from 792c168 to 60a0d7a Compare April 23, 2025 21:12
@andrurogerz
Copy link
Contributor Author

I did a bit more clean-up of the manual fixups I had made and force-pushed so the commit history is clean. I found there were a number of classes where I unnecessarily promoted the export macro to the class level. I think I had done these prior to concluding we should do method-level annotations.

The classes I was able to revert back to original IDS auto-modded were:

BinaryStreamReader
InitializeCOMRAII
OptionCategory
SubCommand
directory_entry
InitLLVM
line_iterator
SMDiagnostic
StringSaver
Timer
CleanupInstaller
ToolOutputFile
WithColor

I also did some quick experimenting and found that the times where the export macro truly requires promotion to class-level is when the class (not a parent or child) has a virtual method that is defined external to class declaration (e.g., in the implementation file not the header). I think we can detect and automate this case in IDS to further avoid the need for manual fixups, and I will take a look into doing that.

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.

6 participants