From 305f60aa1d0b33d50467507a4cd48dfb961025c1 Mon Sep 17 00:00:00 2001 From: Thomas Fransham Date: Sun, 20 Oct 2024 18:00:03 +0100 Subject: [PATCH 1/4] [Support] Add clang tooling generated explicit visibility macros These will be needed to export symbols from llvm shared library on windows without having to export every symbol and running in to the 64k symbol limit of DLLs. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window. --- llvm/include/llvm/Support/AMDGPUMetadata.h | 5 +- .../include/llvm/Support/ARMAttributeParser.h | 3 +- .../include/llvm/Support/ARMBuildAttributes.h | 3 +- llvm/include/llvm/Support/ARMWinEH.h | 3 +- llvm/include/llvm/Support/Allocator.h | 2 +- llvm/include/llvm/Support/Atomic.h | 5 +- .../llvm/Support/BalancedPartitioning.h | 7 +- llvm/include/llvm/Support/Base64.h | 3 +- llvm/include/llvm/Support/BinaryStream.h | 5 +- llvm/include/llvm/Support/BinaryStreamError.h | 3 +- .../include/llvm/Support/BinaryStreamReader.h | 3 +- llvm/include/llvm/Support/BinaryStreamRef.h | 5 +- .../include/llvm/Support/BinaryStreamWriter.h | 3 +- llvm/include/llvm/Support/BlockFrequency.h | 5 +- llvm/include/llvm/Support/BranchProbability.h | 3 +- llvm/include/llvm/Support/BuryPointer.h | 3 +- llvm/include/llvm/Support/COM.h | 3 +- llvm/include/llvm/Support/CRC.h | 7 +- .../llvm/Support/CSKYAttributeParser.h | 3 +- llvm/include/llvm/Support/CSKYAttributes.h | 3 +- llvm/include/llvm/Support/CachePruning.h | 5 +- llvm/include/llvm/Support/Caching.h | 3 +- llvm/include/llvm/Support/Chrono.h | 20 +-- llvm/include/llvm/Support/CodeGenCoverage.h | 3 +- llvm/include/llvm/Support/CommandLine.h | 131 +++++++------- llvm/include/llvm/Support/Compression.h | 27 +-- llvm/include/llvm/Support/ConvertEBCDIC.h | 5 +- llvm/include/llvm/Support/ConvertUTF.h | 53 +++--- .../llvm/Support/CrashRecoveryContext.h | 5 +- llvm/include/llvm/Support/DJB.h | 3 +- llvm/include/llvm/Support/DataExtractor.h | 3 +- llvm/include/llvm/Support/Debug.h | 13 +- llvm/include/llvm/Support/DebugCounter.h | 5 +- .../llvm/Support/DivisionByConstantInfo.h | 5 +- llvm/include/llvm/Support/DynamicLibrary.h | 3 +- .../include/llvm/Support/ELFAttributeParser.h | 3 +- llvm/include/llvm/Support/ELFAttributes.h | 5 +- llvm/include/llvm/Support/Errno.h | 5 +- llvm/include/llvm/Support/Error.h | 30 ++-- llvm/include/llvm/Support/ErrorHandling.h | 20 +-- .../include/llvm/Support/ExponentialBackoff.h | 3 +- llvm/include/llvm/Support/ExtensibleRTTI.h | 3 +- llvm/include/llvm/Support/FileCollector.h | 7 +- llvm/include/llvm/Support/FileOutputBuffer.h | 3 +- llvm/include/llvm/Support/FileSystem.h | 161 +++++++++--------- llvm/include/llvm/Support/FileUtilities.h | 5 +- llvm/include/llvm/Support/Format.h | 3 +- llvm/include/llvm/Support/FormatVariadic.h | 3 +- .../llvm/Support/FormatVariadicDetails.h | 5 +- llvm/include/llvm/Support/FormattedStream.h | 9 +- llvm/include/llvm/Support/GlobPattern.h | 5 +- llvm/include/llvm/Support/GraphWriter.h | 9 +- .../llvm/Support/HexagonAttributeParser.h | 3 +- llvm/include/llvm/Support/HexagonAttributes.h | 3 +- llvm/include/llvm/Support/InitLLVM.h | 3 +- llvm/include/llvm/Support/InstructionCost.h | 3 +- llvm/include/llvm/Support/JSON.h | 30 ++-- llvm/include/llvm/Support/KnownBits.h | 3 +- llvm/include/llvm/Support/LEB128.h | 5 +- llvm/include/llvm/Support/LineIterator.h | 3 +- llvm/include/llvm/Support/Locale.h | 5 +- llvm/include/llvm/Support/LockFileManager.h | 3 +- llvm/include/llvm/Support/MD5.h | 5 +- .../llvm/Support/MSP430AttributeParser.h | 3 +- llvm/include/llvm/Support/MSP430Attributes.h | 3 +- llvm/include/llvm/Support/ManagedStatic.h | 5 +- llvm/include/llvm/Support/MathExtras.h | 2 +- llvm/include/llvm/Support/MemAlloc.h | 4 +- llvm/include/llvm/Support/Memory.h | 7 +- llvm/include/llvm/Support/MemoryBuffer.h | 7 +- llvm/include/llvm/Support/MemoryBufferRef.h | 3 +- llvm/include/llvm/Support/ModRef.h | 5 +- llvm/include/llvm/Support/NativeFormatting.h | 21 +-- .../llvm/Support/OptimizedStructLayout.h | 5 +- llvm/include/llvm/Support/OptionStrCmp.h | 5 +- llvm/include/llvm/Support/PGOOptions.h | 3 +- llvm/include/llvm/Support/Parallel.h | 11 +- llvm/include/llvm/Support/Path.h | 93 +++++----- llvm/include/llvm/Support/PluginLoader.h | 3 +- llvm/include/llvm/Support/PrettyStackTrace.h | 22 +-- llvm/include/llvm/Support/Process.h | 3 +- llvm/include/llvm/Support/Program.h | 29 ++-- .../llvm/Support/RISCVAttributeParser.h | 3 +- llvm/include/llvm/Support/RISCVAttributes.h | 3 +- llvm/include/llvm/Support/RISCVISAUtils.h | 3 +- .../llvm/Support/RandomNumberGenerator.h | 4 +- llvm/include/llvm/Support/Recycler.h | 3 +- llvm/include/llvm/Support/Regex.h | 3 +- llvm/include/llvm/Support/SHA1.h | 3 +- llvm/include/llvm/Support/SHA256.h | 3 +- llvm/include/llvm/Support/SMTAPI.h | 11 +- llvm/include/llvm/Support/ScaledNumber.h | 11 +- llvm/include/llvm/Support/ScopedPrinter.h | 9 +- llvm/include/llvm/Support/Signals.h | 31 ++-- llvm/include/llvm/Support/Signposts.h | 3 +- llvm/include/llvm/Support/SipHash.h | 7 +- .../llvm/Support/SmallVectorMemoryBuffer.h | 3 +- llvm/include/llvm/Support/SourceMgr.h | 9 +- llvm/include/llvm/Support/SpecialCaseList.h | 5 +- llvm/include/llvm/Support/StringSaver.h | 5 +- llvm/include/llvm/Support/SuffixTree.h | 5 +- llvm/include/llvm/Support/SuffixTreeNode.h | 7 +- llvm/include/llvm/Support/SystemUtils.h | 3 +- llvm/include/llvm/Support/TarWriter.h | 3 +- llvm/include/llvm/Support/ThreadPool.h | 7 +- llvm/include/llvm/Support/Threading.h | 20 +-- llvm/include/llvm/Support/TimeProfiler.h | 29 ++-- llvm/include/llvm/Support/Timer.h | 11 +- llvm/include/llvm/Support/ToolOutputFile.h | 5 +- llvm/include/llvm/Support/TypeSize.h | 5 +- llvm/include/llvm/Support/Unicode.h | 15 +- llvm/include/llvm/Support/Valgrind.h | 5 +- llvm/include/llvm/Support/VersionTuple.h | 5 +- llvm/include/llvm/Support/VirtualFileSystem.h | 37 ++-- llvm/include/llvm/Support/Watchdog.h | 2 +- .../llvm/Support/Windows/WindowsSupport.h | 12 +- llvm/include/llvm/Support/WindowsError.h | 5 +- llvm/include/llvm/Support/WithColor.h | 4 +- llvm/include/llvm/Support/YAMLParser.h | 29 ++-- llvm/include/llvm/Support/YAMLTraits.h | 43 ++--- .../llvm/Support/circular_raw_ostream.h | 3 +- llvm/include/llvm/Support/raw_os_ostream.h | 3 +- llvm/include/llvm/Support/raw_ostream.h | 29 ++-- llvm/include/llvm/Support/raw_socket_stream.h | 7 +- llvm/include/llvm/Support/thread.h | 13 +- llvm/include/llvm/Support/xxhash.h | 9 +- 126 files changed, 744 insertions(+), 631 deletions(-) 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 #include #include @@ -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 d1d953120ae7e..da0884d823ffc 100644 --- a/llvm/include/llvm/Support/ARMAttributeParser.h +++ b/llvm/include/llvm/Support/ARMAttributeParser.h @@ -12,13 +12,14 @@ #include "ARMBuildAttributes.h" #include "ELFAttributeParser.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" namespace llvm { class ScopedPrinter; -class ARMAttributeParser : public ELFAttributeParser { +class LLVM_ABI ARMAttributeParser : public ELFAttributeParser { 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..3c952bcae5f02 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,7 +206,7 @@ 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 SavedRegisterMask(const RuntimeFunction &RF, +LLVM_ABI std::pair 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..36561cf5d5a93 100644 --- a/llvm/include/llvm/Support/Allocator.h +++ b/llvm/include/llvm/Support/Allocator.h @@ -36,7 +36,7 @@ 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, +LLVM_ABI void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated, size_t TotalMemory); } // end namespace detail diff --git a/llvm/include/llvm/Support/Atomic.h b/llvm/include/llvm/Support/Atomic.h index a8445fddc1a85..43df01462b59c 100644 --- a/llvm/include/llvm/Support/Atomic.h +++ b/llvm/include/llvm/Support/Atomic.h @@ -17,6 +17,7 @@ #ifndef LLVM_SUPPORT_ATOMIC_H #define LLVM_SUPPORT_ATOMIC_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" // Windows will at times define MemoryFence. @@ -26,14 +27,14 @@ namespace llvm { namespace sys { - void MemoryFence(); + LLVM_ABI void MemoryFence(); #ifdef _MSC_VER typedef long cas_flag; #else typedef uint32_t cas_flag; #endif - cas_flag CompareAndSwap(volatile cas_flag* ptr, + LLVM_ABI cas_flag CompareAndSwap(volatile cas_flag* ptr, cas_flag new_value, cas_flag old_value); } diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h b/llvm/include/llvm/Support/BalancedPartitioning.h index 539d157343fbe..b1b120787516e 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 #include @@ -53,7 +54,7 @@ namespace llvm { class ThreadPoolInterface; /// A function with a set of utility nodes where it is beneficial to order two /// functions close together if they have similar utility nodes -class BPFunctionNode { +class LLVM_ABI BPFunctionNode { friend class BalancedPartitioning; public: @@ -97,7 +98,7 @@ struct BalancedPartitioningConfig { unsigned TaskSplitDepth = 9; }; -class BalancedPartitioning { +class LLVM_ABI BalancedPartitioning { public: BalancedPartitioning(const BalancedPartitioningConfig &Config); @@ -114,7 +115,7 @@ class BalancedPartitioning { /// wait(). BalancedPartitioning recursively spawns new threads inside other /// threads, so we need to track how many active threads that could spawn more /// threads. - struct BPThreadPool { + struct LLVM_ABI BPThreadPool { ThreadPoolInterface &TheThreadPool; std::mutex mtx; std::condition_variable cv; diff --git a/llvm/include/llvm/Support/Base64.h b/llvm/include/llvm/Support/Base64.h index 3d96884749b32..997e8c0b7124e 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 #include @@ -54,7 +55,7 @@ template std::string encodeBase64(InputBytes const &Bytes) { return Buffer; } -llvm::Error decodeBase64(llvm::StringRef Input, std::vector &Output); +LLVM_ABI llvm::Error decodeBase64(llvm::StringRef Input, std::vector &Output); } // end namespace llvm diff --git a/llvm/include/llvm/Support/BinaryStream.h b/llvm/include/llvm/Support/BinaryStream.h index 8fba5ee9b0b36..1cb783207a23c 100644 --- a/llvm/include/llvm/Support/BinaryStream.h +++ b/llvm/include/llvm/Support/BinaryStream.h @@ -12,6 +12,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitmaskEnum.h" #include "llvm/Support/BinaryStreamError.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include @@ -31,7 +32,7 @@ enum BinaryStreamFlags { /// single contiguous buffer (or even in memory at all), in such cases a it may /// be necessary for an implementation to cache such a buffer so that it can /// return it. -class BinaryStream { +class LLVM_ABI BinaryStream { public: virtual ~BinaryStream() = default; @@ -69,7 +70,7 @@ class BinaryStream { /// buffer to the stream's backing store. Streams are assumed to be buffered /// so that to be portable it is necessary to call commit() on the stream when /// all data has been written. -class WritableBinaryStream : public BinaryStream { +class LLVM_ABI WritableBinaryStream : public BinaryStream { public: ~WritableBinaryStream() override = default; 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 @@ -24,7 +25,7 @@ enum class stream_error_code { }; /// Base class for errors originating when parsing raw PDB files -class BinaryStreamError : public ErrorInfo { +class LLVM_ABI BinaryStreamError : public ErrorInfo { 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..351c3958aee98 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 #include @@ -150,7 +151,7 @@ template class BinaryStreamRefBase { /// general, you should not pass around pointers or references to BinaryStreams /// and use inheritance to achieve polymorphism. Instead, you should pass /// around BinaryStreamRefs by value and achieve polymorphism that way. -class BinaryStreamRef +class LLVM_ABI BinaryStreamRef : public BinaryStreamRefBase { friend BinaryStreamRefBase; friend class WritableBinaryStreamRef; @@ -214,7 +215,7 @@ struct BinarySubstreamRef { bool empty() const { return size() == 0; } }; -class WritableBinaryStreamRef +class LLVM_ABI WritableBinaryStreamRef : public BinaryStreamRefBase { friend BinaryStreamRefBase; diff --git a/llvm/include/llvm/Support/BinaryStreamWriter.h b/llvm/include/llvm/Support/BinaryStreamWriter.h index bc1d7949841d6..f5102ef193101 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 @@ -27,7 +28,7 @@ namespace llvm { /// such as null-terminated strings, integers in various flavors of endianness, /// etc. Can be subclassed to provide reading and writing of custom datatypes, /// although no methods are overridable. -class BinaryStreamWriter { +class LLVM_ABI BinaryStreamWriter { public: BinaryStreamWriter() = default; explicit BinaryStreamWriter(WritableBinaryStreamRef Ref); diff --git a/llvm/include/llvm/Support/BlockFrequency.h b/llvm/include/llvm/Support/BlockFrequency.h index aeab99615a951..4f630d28f72d6 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 #include #include @@ -23,7 +24,7 @@ class raw_ostream; class BranchProbability; // This class represents Block Frequency as a 64-bit value. -class BlockFrequency { +class LLVM_ABI BlockFrequency { uint64_t Frequency; public: @@ -120,7 +121,7 @@ class BlockFrequency { } }; -void printRelativeBlockFreq(raw_ostream &OS, BlockFrequency EntryFreq, +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..4b48ce22ada14 100644 --- a/llvm/include/llvm/Support/BranchProbability.h +++ b/llvm/include/llvm/Support/BranchProbability.h @@ -13,6 +13,7 @@ #ifndef LLVM_SUPPORT_BRANCHPROBABILITY_H #define LLVM_SUPPORT_BRANCHPROBABILITY_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" #include #include @@ -27,7 +28,7 @@ class raw_ostream; // no greater than 1. It uses a fixed-point-like implementation, in which the // denominator is always a constant value (here we use 1<<31 for maximum // precision). -class BranchProbability { +class LLVM_ABI BranchProbability { // Numerator uint32_t N; diff --git a/llvm/include/llvm/Support/BuryPointer.h b/llvm/include/llvm/Support/BuryPointer.h index 276a5b7089c3e..02144baed36af 100644 --- a/llvm/include/llvm/Support/BuryPointer.h +++ b/llvm/include/llvm/Support/BuryPointer.h @@ -9,6 +9,7 @@ #ifndef LLVM_SUPPORT_BURYPOINTER_H #define LLVM_SUPPORT_BURYPOINTER_H +#include "llvm/Support/Compiler.h" #include namespace llvm { @@ -19,7 +20,7 @@ namespace llvm { // the memory is not misdiagnosed as an unintentional leak by leak detection // tools (this is achieved by preserving pointers to the object in a globally // visible array). -void BuryPointer(const void *Ptr); +LLVM_ABI void BuryPointer(const void *Ptr); template void BuryPointer(std::unique_ptr Ptr) { BuryPointer(Ptr.release()); } diff --git a/llvm/include/llvm/Support/COM.h b/llvm/include/llvm/Support/COM.h index d59966f849b48..53a599acc745b 100644 --- a/llvm/include/llvm/Support/COM.h +++ b/llvm/include/llvm/Support/COM.h @@ -14,12 +14,13 @@ #ifndef LLVM_SUPPORT_COM_H #define LLVM_SUPPORT_COM_H +#include "llvm/Support/Compiler.h" namespace llvm { namespace sys { enum class COMThreadingMode { SingleThreaded, MultiThreaded }; -class InitializeCOMRAII { +class LLVM_ABI InitializeCOMRAII { public: explicit InitializeCOMRAII(COMThreadingMode Threading, bool SpeedOverMemory = false); diff --git a/llvm/include/llvm/Support/CRC.h b/llvm/include/llvm/Support/CRC.h index 210890ae06d47..b96e7664ba372 100644 --- a/llvm/include/llvm/Support/CRC.h +++ b/llvm/include/llvm/Support/CRC.h @@ -13,17 +13,18 @@ #ifndef LLVM_SUPPORT_CRC_H #define LLVM_SUPPORT_CRC_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" namespace llvm { template class ArrayRef; // Compute the CRC-32 of Data. -uint32_t crc32(ArrayRef Data); +LLVM_ABI uint32_t crc32(ArrayRef Data); // Compute the running CRC-32 of Data, with CRC being the previous value of the // checksum. -uint32_t crc32(uint32_t CRC, ArrayRef Data); +LLVM_ABI uint32_t crc32(uint32_t CRC, ArrayRef Data); // Class for computing the JamCRC. // @@ -42,7 +43,7 @@ uint32_t crc32(uint32_t CRC, ArrayRef Data); // // N.B. We permit flexibility of the "Init" value. Some consumers of this need // it to be zero. -class JamCRC { +class LLVM_ABI JamCRC { public: JamCRC(uint32_t Init = 0xFFFFFFFFU) : CRC(Init) {} diff --git a/llvm/include/llvm/Support/CSKYAttributeParser.h b/llvm/include/llvm/Support/CSKYAttributeParser.h index e926ebe5e306e..4bf89e3f69d43 100644 --- a/llvm/include/llvm/Support/CSKYAttributeParser.h +++ b/llvm/include/llvm/Support/CSKYAttributeParser.h @@ -10,10 +10,11 @@ #define LLVM_SUPPORT_CSKYATTRIBUTEPARSER_H #include "llvm/Support/CSKYAttributes.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ELFAttributeParser.h" namespace llvm { -class CSKYAttributeParser : public ELFAttributeParser { +class LLVM_ABI CSKYAttributeParser : public ELFAttributeParser { struct DisplayHandler { CSKYAttrs::AttrType attribute; Error (CSKYAttributeParser::*routine)(unsigned); diff --git a/llvm/include/llvm/Support/CSKYAttributes.h b/llvm/include/llvm/Support/CSKYAttributes.h index 723f2ceee8fb7..c16d3de96c219 100644 --- a/llvm/include/llvm/Support/CSKYAttributes.h +++ b/llvm/include/llvm/Support/CSKYAttributes.h @@ -12,12 +12,13 @@ #ifndef LLVM_SUPPORT_CSKYATTRIBUTES_H #define LLVM_SUPPORT_CSKYATTRIBUTES_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/ELFAttributes.h" namespace llvm { namespace CSKYAttrs { -const TagNameMap &getCSKYAttributeTags(); +LLVM_ABI const TagNameMap &getCSKYAttributeTags(); enum AttrType { CSKY_ARCH_NAME = 4, diff --git a/llvm/include/llvm/Support/CachePruning.h b/llvm/include/llvm/Support/CachePruning.h index 17e148830a73f..50d5ea41ec9ba 100644 --- a/llvm/include/llvm/Support/CachePruning.h +++ b/llvm/include/llvm/Support/CachePruning.h @@ -14,6 +14,7 @@ #ifndef LLVM_SUPPORT_CACHEPRUNING_H #define LLVM_SUPPORT_CACHEPRUNING_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/MemoryBuffer.h" #include #include @@ -66,7 +67,7 @@ struct CachePruningPolicy { /// For example: "prune_interval=30s:prune_after=24h:cache_size=50%" /// which means a pruning interval of 30 seconds, expiration time of 24 hours /// and maximum cache size of 50% of available disk space. -Expected parseCachePruningPolicy(StringRef PolicyStr); +LLVM_ABI Expected parseCachePruningPolicy(StringRef PolicyStr); /// Peform pruning using the supplied policy, returns true if pruning /// occurred, i.e. if Policy.Interval was expired. @@ -79,7 +80,7 @@ Expected parseCachePruningPolicy(StringRef PolicyStr); /// As a safeguard against data loss if the user specifies the wrong directory /// as their cache directory, this function will ignore files not matching the /// pattern "llvmcache-*". -bool pruneCache(StringRef Path, CachePruningPolicy Policy, +LLVM_ABI bool pruneCache(StringRef Path, CachePruningPolicy Policy, const std::vector> &Files = {}); } // namespace llvm diff --git a/llvm/include/llvm/Support/Caching.h b/llvm/include/llvm/Support/Caching.h index cf45145619d95..8c50902c42999 100644 --- a/llvm/include/llvm/Support/Caching.h +++ b/llvm/include/llvm/Support/Caching.h @@ -15,6 +15,7 @@ #ifndef LLVM_SUPPORT_CACHING_H #define LLVM_SUPPORT_CACHING_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" namespace llvm { @@ -96,7 +97,7 @@ using AddBufferFn = std::function localCache( +LLVM_ABI Expected localCache( const Twine &CacheNameRef, const Twine &TempFilePrefixRef, const Twine &CacheDirectoryPathRef, AddBufferFn AddBuffer = [](size_t Task, const Twine &ModuleName, diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h index 71859af7c7e4a..e20cd30687d91 100644 --- a/llvm/include/llvm/Support/Chrono.h +++ b/llvm/include/llvm/Support/Chrono.h @@ -77,8 +77,8 @@ toTimePoint(std::time_t T, uint32_t nsec) { } // namespace sys -raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP); -raw_ostream &operator<<(raw_ostream &OS, sys::UtcTime<> TP); +LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP); +LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, sys::UtcTime<> TP); /// Format provider for TimePoint<> /// @@ -89,12 +89,12 @@ raw_ostream &operator<<(raw_ostream &OS, sys::UtcTime<> TP); /// /// If no options are given, the default format is "%Y-%m-%d %H:%M:%S.%N". template <> -struct format_provider> { +struct LLVM_ABI format_provider> { static void format(const sys::TimePoint<> &TP, llvm::raw_ostream &OS, StringRef Style); }; -template <> struct format_provider> { +template <> struct LLVM_ABI format_provider> { static void format(const sys::UtcTime &TP, llvm::raw_ostream &OS, StringRef Style); }; @@ -103,12 +103,12 @@ namespace detail { template struct unit { static const char value[]; }; template const char unit::value[] = ""; -template <> struct unit> { static const char value[]; }; -template <> struct unit> { static const char value[]; }; -template <> struct unit> { static const char value[]; }; -template <> struct unit { static const char value[]; }; -template <> struct unit { static const char value[]; }; -template <> struct unit { static const char value[]; }; +template <> struct LLVM_ABI unit> { static const char value[]; }; +template <> struct LLVM_ABI unit> { static const char value[]; }; +template <> struct LLVM_ABI unit> { static const char value[]; }; +template <> struct LLVM_ABI unit { static const char value[]; }; +template <> struct LLVM_ABI unit { static const char value[]; }; +template <> struct LLVM_ABI unit { static const char value[]; }; } // namespace detail /// Implementation of format_provider for duration types. diff --git a/llvm/include/llvm/Support/CodeGenCoverage.h b/llvm/include/llvm/Support/CodeGenCoverage.h index 2acdd6a36a514..769e1918945ff 100644 --- a/llvm/include/llvm/Support/CodeGenCoverage.h +++ b/llvm/include/llvm/Support/CodeGenCoverage.h @@ -12,11 +12,12 @@ #define LLVM_SUPPORT_CODEGENCOVERAGE_H #include "llvm/ADT/BitVector.h" +#include "llvm/Support/Compiler.h" namespace llvm { class MemoryBuffer; -class CodeGenCoverage { +class LLVM_ABI CodeGenCoverage { protected: BitVector RuleCoverage; diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index 5d60bb64bbb20..2c685c5dc5950 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -27,6 +27,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/ADT/iterator_range.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/raw_ostream.h" @@ -65,7 +66,7 @@ namespace cl { // that give precedence to later occurrences. If your program supports options // that give precedence to earlier occurrences, you will need to extend this // function to support it correctly. -bool ParseCommandLineOptions(int argc, const char *const *argv, +LLVM_ABI bool ParseCommandLineOptions(int argc, const char *const *argv, StringRef Overview = "", raw_ostream *Errs = nullptr, const char *EnvVar = nullptr, @@ -78,20 +79,20 @@ using VersionPrinterTy = std::function; /// Override the default (LLVM specific) version printer used to print out the /// version when --version is given on the command line. This allows other /// systems using the CommandLine utilities to print their own version string. -void SetVersionPrinter(VersionPrinterTy func); +LLVM_ABI void SetVersionPrinter(VersionPrinterTy func); ///===---------------------------------------------------------------------===// /// Add an extra printer to use in addition to the default one. This can be /// called multiple times, and each time it adds a new function to the list /// which will be called after the basic LLVM version printing is complete. /// Each can then add additional information specific to the tool. -void AddExtraVersionPrinter(VersionPrinterTy func); +LLVM_ABI void AddExtraVersionPrinter(VersionPrinterTy func); // Print option values. // With -print-options print the difference between option values and defaults. // With -print-all-options print all option values. // (Currently not perfect, but best-effort.) -void PrintOptionValues(); +LLVM_ABI void PrintOptionValues(); // Forward declaration - AddLiteralOption needs to be up here to make gcc happy. class Option; @@ -103,7 +104,7 @@ class Option; /// /// Literal options are used by some parsers to register special option values. /// This is how the PassNameParser registers pass names for opt. -void AddLiteralOption(Option &O, StringRef Name); +LLVM_ABI void AddLiteralOption(Option &O, StringRef Name); //===----------------------------------------------------------------------===// // Flags permitted to be passed to command line arguments @@ -176,7 +177,7 @@ enum MiscFlags { // Miscellaneous flags to adjust argument //===----------------------------------------------------------------------===// // -class OptionCategory { +class LLVM_ABI OptionCategory { private: StringRef const Name; StringRef const Description; @@ -195,11 +196,11 @@ class OptionCategory { }; // The general Option Category (used as default category). -OptionCategory &getGeneralCategory(); +LLVM_ABI OptionCategory &getGeneralCategory(); //===----------------------------------------------------------------------===// // -class SubCommand { +class LLVM_ABI SubCommand { private: StringRef Name; StringRef Description; @@ -247,7 +248,7 @@ class SubCommandGroup { //===----------------------------------------------------------------------===// // -class Option { +class LLVM_ABI Option { friend class alias; // Overriden by subclasses to handle the value passed into an argument. Should @@ -529,7 +530,7 @@ callback(F CB) { //===----------------------------------------------------------------------===// // Support value comparison outside the template. -struct GenericOptionValue { +struct LLVM_ABI GenericOptionValue { virtual bool compare(const GenericOptionValue &V) const = 0; protected: @@ -636,7 +637,7 @@ struct OptionValue final // Other safe-to-copy-by-value common option types. enum boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE }; template <> -struct OptionValue final +struct LLVM_ABI OptionValue final : OptionValueCopy { using WrapperType = cl::boolOrDefault; @@ -654,7 +655,7 @@ struct OptionValue final }; template <> -struct OptionValue final : OptionValueCopy { +struct LLVM_ABI OptionValue final : OptionValueCopy { using WrapperType = StringRef; OptionValue() = default; @@ -724,7 +725,7 @@ template ValuesClass values(OptsTy... Options) { // every instance of the generic parser. This also allows us to put stuff into // CommandLine.cpp // -class generic_parser_base { +class LLVM_ABI generic_parser_base { protected: class GenericOptionInfo { public: @@ -890,7 +891,7 @@ template class parser : public generic_parser_base { //-------------------------------------------------- // Super class of parsers to provide boilerplate code // -class basic_parser_impl { // non-template implementation of basic_parser +class LLVM_ABI basic_parser_impl { // non-template implementation of basic_parser public: basic_parser_impl(Option &) {} @@ -939,9 +940,9 @@ template class basic_parser : public basic_parser_impl { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser : public basic_parser { +template <> class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -966,9 +967,9 @@ template <> class parser : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser : public basic_parser { +template <> class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -991,9 +992,9 @@ template <> class parser : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser : public basic_parser { +template <> class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1012,9 +1013,9 @@ template <> class parser : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser final : public basic_parser { +template <> class LLVM_ABI parser final : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1033,9 +1034,9 @@ template <> class parser final : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser : public basic_parser { +template <> class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1054,9 +1055,9 @@ template <> class parser : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser : public basic_parser { +template <> class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1075,10 +1076,10 @@ template <> class parser : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; template <> -class parser final : public basic_parser { +class LLVM_ABI parser final : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1097,10 +1098,10 @@ class parser final : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; template <> -class parser : public basic_parser { +class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1120,9 +1121,9 @@ class parser : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser : public basic_parser { +template <> class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1141,9 +1142,9 @@ template <> class parser : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser : public basic_parser { +template <> class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1162,9 +1163,9 @@ template <> class parser : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser : public basic_parser { +template <> class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1186,9 +1187,9 @@ template <> class parser : public basic_parser { //-------------------------------------------------- -extern template class basic_parser; +extern template class LLVM_TEMPLATE_ABI basic_parser; -template <> class parser : public basic_parser { +template <> class LLVM_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1510,11 +1511,11 @@ class opt [](const typename ParserClass::parser_data_type &) {}; }; -extern template class opt; -extern template class opt; -extern template class opt; -extern template class opt; -extern template class opt; +extern template class LLVM_TEMPLATE_ABI opt; +extern template class LLVM_TEMPLATE_ABI opt; +extern template class LLVM_TEMPLATE_ABI opt; +extern template class LLVM_TEMPLATE_ABI opt; +extern template class LLVM_TEMPLATE_ABI opt; //===----------------------------------------------------------------------===// // Default storage class definition: external storage. This implementation @@ -1910,7 +1911,7 @@ class bits : public Option, public bits_storage { // Aliased command line option (alias this name to a preexisting name) // -class alias : public Option { +class LLVM_ABI alias : public Option { Option *AliasFor; bool handleOccurrence(unsigned pos, StringRef /*ArgName*/, @@ -1980,30 +1981,30 @@ struct aliasopt { // Provide additional help at the end of the normal help output. All occurrences // of cl::extrahelp will be accumulated and printed to stderr at the end of the // regular help, just before exit is called. -struct extrahelp { +struct LLVM_ABI extrahelp { StringRef morehelp; explicit extrahelp(StringRef help); }; -void PrintVersionMessage(); +LLVM_ABI void PrintVersionMessage(); /// This function just prints the help message, exactly the same way as if the /// -help or -help-hidden option had been given on the command line. /// /// \param Hidden if true will print hidden options /// \param Categorized if true print options in categories -void PrintHelpMessage(bool Hidden = false, bool Categorized = false); +LLVM_ABI void PrintHelpMessage(bool Hidden = false, bool Categorized = false); /// An array of optional enabled settings in the LLVM build configuration, /// which may be of interest to compiler developers. For example, includes /// "+assertions" if assertions are enabled. Used by printBuildConfig. -ArrayRef getCompilerBuildConfig(); +LLVM_ABI ArrayRef getCompilerBuildConfig(); /// Prints the compiler build configuration. /// Designed for compiler developers, not compiler end-users. /// Intended to be used in --version output when enabled. -void printBuildConfig(raw_ostream &OS); +LLVM_ABI void printBuildConfig(raw_ostream &OS); //===----------------------------------------------------------------------===// // Public interface for accessing registered options. @@ -2036,7 +2037,7 @@ void printBuildConfig(raw_ostream &OS); /// Hopefully this API can be deprecated soon. Any situation where options need /// to be modified by tools or libraries should be handled by sane APIs rather /// than just handing around a global list. -StringMap