-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[Support] Add clang tooling generated explicit visibility macros #113097
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
base: main
Are you sure you want to change the base?
Conversation
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/pr-subscribers-backend-hexagon @llvm/pr-subscribers-backend-amdgpu Author: Thomas Fransham (fsfod) ChangesThese will be needed to export symbols from llvm shared library on windows without If there are any files or classes you think shouldn't exported i can exclude them and regenerate. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window. Patch is 250.08 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/113097.diff 129 Files Affected:
diff --git a/llvm/include/llvm/Support/AMDGPUMetadata.h b/llvm/include/llvm/Support/AMDGPUMetadata.h
index 76ac7ab74a32e8..990c825ae68751 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 d1d953120ae7ed..da0884d823ffcb 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 35f8992ca93296..68acf30e52f3ec 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 b6710cca95650d..3c952bcae5f027 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<uint16_t, uint32_t> SavedRegisterMask(const RuntimeFunction &RF,
+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 568f0d34032fa2..36561cf5d5a93d 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 a8445fddc1a855..43df01462b59c3 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 539d157343fbe3..b1b120787516e8 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>
@@ -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 3d96884749b32f..997e8c0b7124e1 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,7 @@ 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/BinaryStream.h b/llvm/include/llvm/Support/BinaryStream.h
index 8fba5ee9b0b368..1cb783207a23cb 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 <cstdint>
@@ -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 cf6e034ffd2ceb..8a45f7bbd52cce 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 ca99388c5d03af..e61349d841cdb9 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 fdc46f5fd56057..351c3958aee98c 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>
@@ -150,7 +151,7 @@ template <class RefType, class StreamType> 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<BinaryStreamRef, BinaryStream> {
friend BinaryStreamRefBase<BinaryStreamRef, BinaryStream>;
friend class WritableBinaryStreamRef;
@@ -214,7 +215,7 @@ struct BinarySubstreamRef {
bool empty() const { return size() == 0; }
};
-class WritableBinaryStreamRef
+class LLVM_ABI WritableBinaryStreamRef
: public BinaryStreamRefBase<WritableBinaryStreamRef,
WritableBinaryStream> {
friend BinaryStreamRefBase<WritableBinaryStreamRef, WritableBinaryStream>;
diff --git a/llvm/include/llvm/Support/BinaryStreamWriter.h b/llvm/include/llvm/Support/BinaryStreamWriter.h
index bc1d7949841d6f..f5102ef1931014 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>
@@ -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 aeab99615a951a..4f630d28f72d63 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>
@@ -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 79d70cf611d415..4b48ce22ada14e 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 <algorithm>
#include <cassert>
@@ -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 276a5b7089c3e7..02144baed36af1 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 <memory>
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 <typename T> void BuryPointer(std::unique_ptr<T> Ptr) {
BuryPointer(Ptr.release());
}
diff --git a/llvm/include/llvm/Support/COM.h b/llvm/include/llvm/Support/COM.h
index d59966f849b485..53a599acc745b7 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 210890ae06d47c..b96e7664ba3724 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 <typename T> class ArrayRef;
// Compute the CRC-32 of Data.
-uint32_t crc32(ArrayRef<uint8_t> Data);
+LLVM_ABI uint32_t crc32(ArrayRef<uint8_t> Data);
// Compute the running CRC-32 of Data, with CRC being the previous value of the
// checksum.
-uint32_t crc32(uint32_t CRC, ArrayRef<uint8_t> Data);
+LLVM_ABI uint32_t crc32(uint32_t CRC, ArrayRef<uint8_t> Data);
// Class for computing the JamCRC.
//
@@ -42,7 +43,7 @@ uint32_t crc32(uint32_t CRC, ArrayRef<uint8_t> 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 e926ebe5e306e3..4bf89e3f69d436 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 723f2ceee8fb79..c16d3de96c2197 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 17e148830a73f9..50d5ea41ec9ba9 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 <chrono>
#include <optional>
@@ -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<CachePruningPolicy> parseCachePruningPolicy(StringRef PolicyStr);
+LLVM_ABI Expected<CachePruningPolicy> 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<CachePruningPolicy> 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<std::unique_ptr<MemoryBuffer>> &Files = {});
} // namespace llvm
diff --git a/llvm/include/llvm/Support/Caching.h b/llvm/include/llvm/Support/Caching.h
index cf45145619d95b..8c50902c42999b 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<void(unsigned Task, const Twine &ModuleName,
/// done lazily the first time a file is added. The cache name appears in error
/// messages for errors during caching. The temporary file prefix is used in the
/// temporary file naming scheme used when writing files atomically.
-Expected<FileCache> localCache(
+LLVM_ABI Expected<FileCache> 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 71859af7c7e4a5..e20cd30687d915 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...
[truncated]
|
You can test this locally with the following command:git-clang-format --diff 8129ba6c70aef54d87893adeb34e76f84fa69fe3 cc463293355dfbaa1361dff92a2778da7f1a7303 --extensions cpp,h -- llvm/include/llvm/Support/AMDGPUMetadata.h llvm/include/llvm/Support/ARMAttributeParser.h llvm/include/llvm/Support/ARMBuildAttributes.h llvm/include/llvm/Support/ARMWinEH.h llvm/include/llvm/Support/Allocator.h llvm/include/llvm/Support/Atomic.h llvm/include/llvm/Support/BalancedPartitioning.h llvm/include/llvm/Support/Base64.h llvm/include/llvm/Support/BinaryStream.h llvm/include/llvm/Support/BinaryStreamError.h llvm/include/llvm/Support/BinaryStreamReader.h llvm/include/llvm/Support/BinaryStreamRef.h llvm/include/llvm/Support/BinaryStreamWriter.h llvm/include/llvm/Support/BlockFrequency.h llvm/include/llvm/Support/BranchProbability.h llvm/include/llvm/Support/BuryPointer.h llvm/include/llvm/Support/COM.h llvm/include/llvm/Support/CRC.h llvm/include/llvm/Support/CSKYAttributeParser.h llvm/include/llvm/Support/CSKYAttributes.h llvm/include/llvm/Support/CachePruning.h llvm/include/llvm/Support/Caching.h llvm/include/llvm/Support/Chrono.h llvm/include/llvm/Support/CodeGenCoverage.h llvm/include/llvm/Support/CommandLine.h llvm/include/llvm/Support/Compression.h llvm/include/llvm/Support/ConvertEBCDIC.h llvm/include/llvm/Support/ConvertUTF.h llvm/include/llvm/Support/CrashRecoveryContext.h llvm/include/llvm/Support/DJB.h llvm/include/llvm/Support/DataExtractor.h llvm/include/llvm/Support/Debug.h llvm/include/llvm/Support/DebugCounter.h llvm/include/llvm/Support/DivisionByConstantInfo.h llvm/include/llvm/Support/DynamicLibrary.h llvm/include/llvm/Support/ELFAttributeParser.h llvm/include/llvm/Support/ELFAttributes.h llvm/include/llvm/Support/Errno.h llvm/include/llvm/Support/Error.h llvm/include/llvm/Support/ErrorHandling.h llvm/include/llvm/Support/ExponentialBackoff.h llvm/include/llvm/Support/ExtensibleRTTI.h llvm/include/llvm/Support/FileCollector.h llvm/include/llvm/Support/FileOutputBuffer.h llvm/include/llvm/Support/FileSystem.h llvm/include/llvm/Support/FileUtilities.h llvm/include/llvm/Support/Format.h llvm/include/llvm/Support/FormatVariadic.h llvm/include/llvm/Support/FormatVariadicDetails.h llvm/include/llvm/Support/FormattedStream.h llvm/include/llvm/Support/GlobPattern.h llvm/include/llvm/Support/GraphWriter.h llvm/include/llvm/Support/HexagonAttributeParser.h llvm/include/llvm/Support/HexagonAttributes.h llvm/include/llvm/Support/InitLLVM.h llvm/include/llvm/Support/InstructionCost.h llvm/include/llvm/Support/JSON.h llvm/include/llvm/Support/KnownBits.h llvm/include/llvm/Support/LEB128.h llvm/include/llvm/Support/LineIterator.h llvm/include/llvm/Support/Locale.h llvm/include/llvm/Support/LockFileManager.h llvm/include/llvm/Support/MD5.h llvm/include/llvm/Support/MSP430AttributeParser.h llvm/include/llvm/Support/MSP430Attributes.h llvm/include/llvm/Support/ManagedStatic.h llvm/include/llvm/Support/MathExtras.h llvm/include/llvm/Support/MemAlloc.h llvm/include/llvm/Support/Memory.h llvm/include/llvm/Support/MemoryBuffer.h llvm/include/llvm/Support/MemoryBufferRef.h llvm/include/llvm/Support/ModRef.h llvm/include/llvm/Support/NativeFormatting.h llvm/include/llvm/Support/OptimizedStructLayout.h llvm/include/llvm/Support/OptionStrCmp.h llvm/include/llvm/Support/PGOOptions.h llvm/include/llvm/Support/Parallel.h llvm/include/llvm/Support/Path.h llvm/include/llvm/Support/PluginLoader.h llvm/include/llvm/Support/PrettyStackTrace.h llvm/include/llvm/Support/Process.h llvm/include/llvm/Support/Program.h llvm/include/llvm/Support/RISCVAttributeParser.h llvm/include/llvm/Support/RISCVAttributes.h llvm/include/llvm/Support/RISCVISAUtils.h llvm/include/llvm/Support/RandomNumberGenerator.h llvm/include/llvm/Support/Recycler.h llvm/include/llvm/Support/Regex.h llvm/include/llvm/Support/SHA1.h llvm/include/llvm/Support/SHA256.h llvm/include/llvm/Support/SMTAPI.h llvm/include/llvm/Support/ScaledNumber.h llvm/include/llvm/Support/ScopedPrinter.h llvm/include/llvm/Support/Signals.h llvm/include/llvm/Support/Signposts.h llvm/include/llvm/Support/SipHash.h llvm/include/llvm/Support/SmallVectorMemoryBuffer.h llvm/include/llvm/Support/SourceMgr.h llvm/include/llvm/Support/SpecialCaseList.h llvm/include/llvm/Support/StringSaver.h llvm/include/llvm/Support/SuffixTree.h llvm/include/llvm/Support/SuffixTreeNode.h llvm/include/llvm/Support/SystemUtils.h llvm/include/llvm/Support/TarWriter.h llvm/include/llvm/Support/ThreadPool.h llvm/include/llvm/Support/Threading.h llvm/include/llvm/Support/TimeProfiler.h llvm/include/llvm/Support/Timer.h llvm/include/llvm/Support/ToolOutputFile.h llvm/include/llvm/Support/TypeSize.h llvm/include/llvm/Support/Unicode.h llvm/include/llvm/Support/Valgrind.h llvm/include/llvm/Support/VersionTuple.h llvm/include/llvm/Support/VirtualFileSystem.h llvm/include/llvm/Support/Watchdog.h llvm/include/llvm/Support/Windows/WindowsSupport.h llvm/include/llvm/Support/WindowsError.h llvm/include/llvm/Support/WithColor.h llvm/include/llvm/Support/YAMLParser.h llvm/include/llvm/Support/YAMLTraits.h llvm/include/llvm/Support/circular_raw_ostream.h llvm/include/llvm/Support/raw_os_ostream.h llvm/include/llvm/Support/raw_ostream.h llvm/include/llvm/Support/raw_socket_stream.h llvm/include/llvm/Support/thread.h llvm/include/llvm/Support/xxhash.h llvm/lib/Support/CommandLine.cpp llvm/lib/Support/Debug.cpp llvm/lib/Support/SmallVector.cpp View the diff from clang-format here.diff --git a/llvm/include/llvm/Support/FileUtilities.h b/llvm/include/llvm/Support/FileUtilities.h
index 6130284eb2..f237f950b3 100644
--- a/llvm/include/llvm/Support/FileUtilities.h
+++ b/llvm/include/llvm/Support/FileUtilities.h
@@ -79,24 +79,24 @@ public:
/// FilePermssionsApplier helps to copy permissions from an input file to
/// an output one. It memorizes the status of the input file and can apply
/// permissions and dates to the output file.
- class LLVM_ABI FilePermissionsApplier {
- public:
- static Expected<FilePermissionsApplier> create(StringRef InputFilename);
-
- /// Apply stored permissions to the \p OutputFilename.
- /// Copy LastAccess and ModificationTime if \p CopyDates is true.
- /// Overwrite stored permissions if \p OverwritePermissions is specified.
- Error
- apply(StringRef OutputFilename, bool CopyDates = false,
- std::optional<sys::fs::perms> OverwritePermissions = std::nullopt);
-
- private:
- FilePermissionsApplier(StringRef InputFilename, sys::fs::file_status Status)
- : InputFilename(InputFilename), InputStatus(Status) {}
-
- StringRef InputFilename;
- sys::fs::file_status InputStatus;
- };
+class LLVM_ABI FilePermissionsApplier {
+public:
+ static Expected<FilePermissionsApplier> create(StringRef InputFilename);
+
+ /// Apply stored permissions to the \p OutputFilename.
+ /// Copy LastAccess and ModificationTime if \p CopyDates is true.
+ /// Overwrite stored permissions if \p OverwritePermissions is specified.
+ Error
+ apply(StringRef OutputFilename, bool CopyDates = false,
+ std::optional<sys::fs::perms> OverwritePermissions = std::nullopt);
+
+private:
+ FilePermissionsApplier(StringRef InputFilename, sys::fs::file_status Status)
+ : InputFilename(InputFilename), InputStatus(Status) {}
+
+ StringRef InputFilename;
+ sys::fs::file_status InputStatus;
+};
} // End llvm namespace
#endif
|
ping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clang-format the edited lines
template <> struct LLVM_ABI unit<std::ratio<1>> { static const char value[]; }; | ||
template <> struct LLVM_ABI unit<std::milli> { static const char value[]; }; | ||
template <> struct LLVM_ABI unit<std::micro> { static const char value[]; }; | ||
template <> struct LLVM_ABI unit<std::nano> { static const char value[]; }; | ||
} // namespace detail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be/are they extern template
'ed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, at some earlier time i had excluded these from being exported fsfod@b24dc93
@@ -654,7 +655,7 @@ struct OptionValue<cl::boolOrDefault> final | |||
}; | |||
|
|||
template <> | |||
struct OptionValue<std::string> final : OptionValueCopy<std::string> { | |||
struct LLVM_ABI OptionValue<std::string> final : OptionValueCopy<std::string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these specializations marked as extern template
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are only extern template declarations for opt<> specializations, those also the ones that sufferer from MSVC bug i mentioned before where members are not getting exported from a dllexport'ed explicit template definition most likely because there deriving from built-in types like int.
@@ -157,7 +157,7 @@ class ErrorInfoBase { | |||
/// *All* Error instances must be checked before destruction, even if | |||
/// they're moved-assigned or constructed from Success values that have already | |||
/// been checked. This enforces checking through all levels of the call stack. | |||
class [[nodiscard]] Error { | |||
class LLVM_ABI [[nodiscard]] Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AaronBallman - I don't remember off hand what the correct order is for attributes and extension attributes. Should this be [[nodiscard]] __declspec(...)
or __declspec(...) [[nodiscard]]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember fixing this for functions where generalized attributes had to be first.
llvm/include/llvm/Support/ARMWinEH.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional that the classes in this file are not marked LLVM_ABI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any class with no out of line members is skipped to help reduce the number of exports created for MSVC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, do you have any idea what fraction of classes are like that? This seems like a bit of a foot-gun, as someone adding an out of line member is likely not going to check whether this is the first out of line member in the class and they have to add an ABI annotation.
Or is it expected that automation is going to check that all necessary annotations are present and we instead have to explicitly mark things that we don't want part of the ABI (with which macro? It is still the LIBRARY_VISIBILITY one?)
Generally I'd appreciate it if the PR included some useful context on what the wider maintenance plan here is supposed to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the idea is automate adding new annotations by running something like post commit action like gn syncbot does. There some discussion about this in the Clang PR #109702.
It is still the LIBRARY_VISIBILITY one?
I just added a new macro LLVM_ABI_NOT_EXPORTED that the tool looks for, I never really though about reusing LIBRARY_VISIBILITY maybe i could. It would have to be not defined when the tool runs so the tool can define it as a clang annotate attribute it can find.
One of the extra goals is default symbol visibility is eventually set to hidden for non windows platforms to also reduce the number of exported symbols for them #19707.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of this is also discussed in @compnerds old thread https://discourse.llvm.org/t/supporting-llvm-build-llvm-dylib-on-windows/58891
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added a new macro LLVM_ABI_NOT_EXPORTED that the tool looks for, I never really though about reusing LIBRARY_VISIBILITY maybe i could. It would have to be not defined when the tool runs so the tool can define it as a clang annotate attribute it can find.
It would generally be nice if the old LLVM_EXTERNAL_VISIBILTY, LLVM_LIBRARY_VISIBILITY and LLVM_ALWAYS_EXPORT and the new macros could be consolidated. Having 3 old macros on top of 5 new ones really doesn't make it easy to understand when you're supposed to use which one.
And on that note, it would be great to have a section in https://llvm.org/docs/ProgrammersManual.html that explains the different ABI macros and when you're supposed to use them. As these are going to be become widespread now, having a reference that we can point people to will be helpful. (There is some limited documentation in Compiler.h, but it does lose nuances like the "only use if there is an out of line member" guideline mentioned above.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would generally be nice if the old LLVM_EXTERNAL_VISIBILTY, LLVM_LIBRARY_VISIBILITY and LLVM_ALWAYS_EXPORT and the new macros could be consolidated. Having 3 old macros on top of 5 new ones really doesn't make it easy to understand when you're supposed to use which one.
This has been my concern as well. However, this is currently an intermediatory step. The desired end goal is to have ~3-4 of these macros for the libraries that we want to support.
In my mind the ones that we want:
LLVM_SUPPORT_ABI
- ABI surface for LLVMSupportLLVM_ABI
- ABI surface for LLVM (DSO)LLVM_C_ABI
- ABI surface for llvm-cCLANG_ABI
- ABI surface for clang (DSO)LLDB_ABI
- ABI surface for LLDB (DSO)
This would allow most of the common uses of the library builds be possible on all the platforms. There is a need for splitting out LLVMSupport as it is so commonly used, and LLVM and LLVM C are separate as there is somewhat of an ABI guarantee on the LLVM C interface.
And on that note, it would be great to have a section in https://llvm.org/docs/ProgrammersManual.html that explains the different ABI macros and when you're supposed to use them. As these are going to be become widespread now, having a reference that we can point people to will be helpful. (There is some limited documentation in Compiler.h, but it does lose nuances like the "only use if there is an out of line member" guideline mentioned above.)
I agree that documenting them is important. However, my concern is that it is going to spread fear and confusion due to the current state. We need to get to the state where the macros are properly setup so that we are able to build the DLLs with the reduced macro set to demonstrate that we are in the right state. At that point, as this becomes part of the development workflow, it would be something that must be documented and have clear guidelines on how to use the tooling to verify (as well as builds).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that documenting them is important. However, my concern is that it is going to spread fear and confusion due to the current state. We need to get to the state where the macros are properly setup so that we are able to build the DLLs with the reduced macro set to demonstrate that we are in the right state. At that point, as this becomes part of the development workflow, it would be something that must be documented and have clear guidelines on how to use the tooling to verify (as well as builds).
As the discussion on this PR and the clang one show, you already have fear and confusion now :)
I'd be fine with going ahead with this as long as there is some place we can point people to explaining what is going on here and what the plan going forward is. And by "some place" I don't mean "breadcrumbs spread across five different issues, PRs and discourse threads".
There should be a discourse post that says something along the lines of: We are going to be mass adding ABI annotations (because...), you should just ignore them for now (we'll add them to any new code ourselves), we're going to add automation (which does...?) to make sure they stay up to date once the bulk has landed. The annotations will only get used once we have automation and documentation in place.
I am not really an owner around these bits, hence I only have some high level concerns (that shouldn't be blocking if actual owners don't feel the same). It's completely unclear how the APIs to be exposed were chosen, and how it'll be kept up-to-date. I think this will turn into a maintenance nightmare for everyone going forward. People will keep tagging their new symbols as LLVM_ABI, without really understanding why (just because existing code does it that way), people will also keep breaking you as these attributes can be dropped during refactorings unintentionally etc. Moreover I don't see how this solves windows' 65k symbol limit per shared-library. Surely this will delay the inevitable, but inherently we still have a single library that exposes all the symbols. Have you considered any alternatives ? Is it possible to have a finer granular built for windows? Can we describe set of symbols to expose through a side-table instead ? |
The whole idea is people won't have to have to manually add or maintain them, it will be automated with a clang tooling based tool that might run like gn syncbot does.
What you describe is close to the existing non LLVM_BUILD_LLVM_DYLIB DLL build mode for windows which has the major limitation that data symbols can't be imported by code consuming the shared library. |
Windows requires this information at compile time really, which is why it must be annotated at the source level. The general approach is to explicitly specify the ABI for the library and indicate what functions are externally visible. That is, the default on Windows would be |
These will be needed to export symbols from llvm shared library on windows without
having to export every symbol and running in to the 65k symbol limit of DLLs.
If there are any files or classes you think shouldn't exported i can exclude them and regenerate.
I also skipped running clang-format for now to make diffs easier to read.
This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window.