Skip to content

Conversation

@Steelskin
Copy link
Contributor

This patch updates various LLVM headers to properly add the LLVM_ABI and LLVM_ABI_FOR_TEST annotations to build LLVM as a DLL on Windows.

This effort is tracked in #109483.

@llvmbot
Copy link
Member

llvmbot commented Nov 12, 2025

@llvm/pr-subscribers-llvm-support
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-backend-directx

@llvm/pr-subscribers-llvm-adt

Author: Fabrice de Gans (Steelskin)

Changes

This patch updates various LLVM headers to properly add the LLVM_ABI and LLVM_ABI_FOR_TEST annotations to build LLVM as a DLL on Windows.

This effort is tracked in #109483.


Patch is 68.53 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/167718.diff

41 Files Affected:

  • (modified) llvm/include/llvm/ADT/APFloat.h (+1-1)
  • (modified) llvm/include/llvm/Analysis/IR2Vec.h (+1-1)
  • (modified) llvm/include/llvm/AsmParser/AsmParserContext.h (+3-3)
  • (modified) llvm/include/llvm/BinaryFormat/DXContainer.h (+1-1)
  • (modified) llvm/include/llvm/CAS/ActionCache.h (+3-3)
  • (modified) llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h (+1)
  • (modified) llvm/include/llvm/CAS/CASID.h (+1-1)
  • (modified) llvm/include/llvm/CAS/MappedFileRegionArena.h (+3-3)
  • (modified) llvm/include/llvm/CAS/ObjectStore.h (+5-5)
  • (modified) llvm/include/llvm/CAS/OnDiskDataAllocator.h (+8-8)
  • (modified) llvm/include/llvm/CAS/OnDiskGraphDB.h (+16-12)
  • (modified) llvm/include/llvm/CAS/OnDiskKeyValueDB.h (+6-4)
  • (modified) llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h (+14-12)
  • (modified) llvm/include/llvm/CAS/UnifiedOnDiskCache.h (+9-9)
  • (modified) llvm/include/llvm/CGData/StableFunctionMap.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/MIR2Vec.h (+12-8)
  • (modified) llvm/include/llvm/IR/BasicBlock.h (+1-1)
  • (modified) llvm/include/llvm/Option/ArgList.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Argument.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/BasicBlock.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Function.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Pass.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Region.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Tracker.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Use.h (+1-1)
  • (modified) llvm/include/llvm/Support/GlobPattern.h (+1-1)
  • (modified) llvm/include/llvm/Support/Jobserver.h (+2-2)
  • (modified) llvm/include/llvm/Support/LSP/Logging.h (+3-3)
  • (modified) llvm/include/llvm/Support/LSP/Protocol.h (+113-88)
  • (modified) llvm/include/llvm/Support/LSP/Transport.h (+9-6)
  • (modified) llvm/include/llvm/Support/VirtualOutputBackends.h (+4-4)
  • (modified) llvm/include/llvm/Support/VirtualOutputConfig.h (+6-3)
  • (modified) llvm/include/llvm/Support/VirtualOutputFile.h (+4-4)
  • (modified) llvm/include/llvm/Support/raw_ostream_proxy.h (+3-2)
  • (modified) llvm/include/llvm/Transforms/Utils/SSAUpdaterBulk.h (+1-1)
  • (modified) llvm/lib/CAS/OnDiskCommon.h (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+6-6)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanHelpers.h (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.h (+3-3)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanUtils.h (+2)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanValue.h (+3-2)
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index 82ac9a3a1ef80..b2d5ea33f888c 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -1471,7 +1471,7 @@ class APFloat : public APFloatBase { /// If this value is normal and has an exact, normal, multiplicative inverse, /// store it in inv and return true. - bool getExactInverse(APFloat *Inv) const; + LLVM_ABI bool getExactInverse(APFloat *Inv) const; // If this is an exact power of two, return the exponent while ignoring the // sign bit. If it's not an exact power of 2, return INT_MIN diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h index 7a68773a2643a..5957a3743f22e 100644 --- a/llvm/include/llvm/Analysis/IR2Vec.h +++ b/llvm/include/llvm/Analysis/IR2Vec.h @@ -164,7 +164,7 @@ class VocabStorage { VocabStorage() = default; /// Create a VocabStorage with pre-organized section data - VocabStorage(std::vector<std::vector<Embedding>> &&SectionData); + LLVM_ABI VocabStorage(std::vector<std::vector<Embedding>> &&SectionData); VocabStorage(VocabStorage &&) = default; VocabStorage &operator=(VocabStorage &&) = default; diff --git a/llvm/include/llvm/AsmParser/AsmParserContext.h b/llvm/include/llvm/AsmParser/AsmParserContext.h index 1a397486cba4f..8660babfde1b6 100644 --- a/llvm/include/llvm/AsmParser/AsmParserContext.h +++ b/llvm/include/llvm/AsmParser/AsmParserContext.h @@ -34,9 +34,9 @@ class AsmParserContext { DenseMap<Instruction *, FileLocRange> Instructions; public: - std::optional<FileLocRange> getFunctionLocation(const Function *) const; - std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const; - std::optional<FileLocRange> getInstructionLocation(const Instruction *) const; + LLVM_ABI std::optional<FileLocRange> getFunctionLocation(const Function *) const; + LLVM_ABI std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const; + LLVM_ABI std::optional<FileLocRange> getInstructionLocation(const Instruction *) const; /// Get the function at the requested location range. /// If no single function occupies the queried range, or the record is /// missing, a nullptr is returned. diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h index b9a08ce1ca14e..1756ab0b555ff 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainer.h +++ b/llvm/include/llvm/BinaryFormat/DXContainer.h @@ -201,7 +201,7 @@ enum class RootParameterType : uint32_t { LLVM_ABI ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes(); -bool isValidParameterType(uint32_t V); +LLVM_ABI_FOR_TEST bool isValidParameterType(uint32_t V); bool isValidRangeType(uint32_t V); diff --git a/llvm/include/llvm/CAS/ActionCache.h b/llvm/include/llvm/CAS/ActionCache.h index 7f5b11223c54d..9d3f46e798100 100644 --- a/llvm/include/llvm/CAS/ActionCache.h +++ b/llvm/include/llvm/CAS/ActionCache.h @@ -34,7 +34,7 @@ class CacheKey { StringRef getKey() const { return Key; } CacheKey(const CASID &ID); - CacheKey(const ObjectProxy &Proxy); + LLVM_ABI_FOR_TEST CacheKey(const ObjectProxy &Proxy); CacheKey(const ObjectStore &CAS, const ObjectRef &Ref); private: @@ -98,10 +98,10 @@ class ActionCache { }; /// Create an action cache in memory. -std::unique_ptr<ActionCache> createInMemoryActionCache(); +LLVM_ABI std::unique_ptr<ActionCache> createInMemoryActionCache(); /// Create an action cache on disk. -Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path); +LLVM_ABI Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path); } // end namespace llvm::cas diff --git a/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h b/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h index 6c165c421b168..6368fca4f7072 100644 --- a/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h +++ b/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h @@ -18,6 +18,7 @@ class ObjectStore; /// Create on-disk \c ObjectStore and \c ActionCache instances based on /// \c ondisk::UnifiedOnDiskCache, with built-in hashing. +LLVM_ABI Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>> createOnDiskUnifiedCASDatabases(StringRef Path); diff --git a/llvm/include/llvm/CAS/CASID.h b/llvm/include/llvm/CAS/CASID.h index f508ed3b26c23..8d5a48e26a1af 100644 --- a/llvm/include/llvm/CAS/CASID.h +++ b/llvm/include/llvm/CAS/CASID.h @@ -70,7 +70,7 @@ class CASID { } /// Return a printable string for CASID. - std::string toString() const; + LLVM_ABI std::string toString() const; ArrayRef<uint8_t> getHash() const { return arrayRefFromStringRef<uint8_t>(Hash); diff --git a/llvm/include/llvm/CAS/MappedFileRegionArena.h b/llvm/include/llvm/CAS/MappedFileRegionArena.h index ff51f0eb59929..b90cb53302c39 100644 --- a/llvm/include/llvm/CAS/MappedFileRegionArena.h +++ b/llvm/include/llvm/CAS/MappedFileRegionArena.h @@ -61,7 +61,7 @@ class MappedFileRegionArena { /// that information can be stored before the header, like a file magic. /// \param NewFileConstructor is for constructing new files. It has exclusive /// access to the file. Must call \c initializeBumpPtr. - static Expected<MappedFileRegionArena> + LLVM_ABI_FOR_TEST static Expected<MappedFileRegionArena> create(const Twine &Path, uint64_t Capacity, uint64_t HeaderOffset, function_ref<Error(MappedFileRegionArena &)> NewFileConstructor); @@ -81,7 +81,7 @@ class MappedFileRegionArena { return data() + *Offset; } /// Allocate, returning the offset from \a data() instead of a pointer. - Expected<int64_t> allocateOffset(uint64_t AllocSize); + LLVM_ABI_FOR_TEST Expected<int64_t> allocateOffset(uint64_t AllocSize); char *data() const { return Region.data(); } uint64_t size() const { return H->BumpPtr; } @@ -106,7 +106,7 @@ class MappedFileRegionArena { // initialize header from offset. void initializeHeader(uint64_t HeaderOffset); - void destroyImpl(); + LLVM_ABI_FOR_TEST void destroyImpl(); void moveImpl(MappedFileRegionArena &RHS) { std::swap(Region, RHS.Region); std::swap(H, RHS.H); diff --git a/llvm/include/llvm/CAS/ObjectStore.h b/llvm/include/llvm/CAS/ObjectStore.h index 29950fe9d9029..bcf3f9214051d 100644 --- a/llvm/include/llvm/CAS/ObjectStore.h +++ b/llvm/include/llvm/CAS/ObjectStore.h @@ -179,7 +179,7 @@ class ObjectStore { public: /// Helper functions to store object and returns a ObjectProxy. - Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data); + LLVM_ABI_FOR_TEST Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data); /// Store object from StringRef. Expected<ObjectRef> storeFromString(ArrayRef<ObjectRef> Refs, @@ -205,10 +205,10 @@ class ObjectStore { static Error createUnknownObjectError(const CASID &ID); /// Create ObjectProxy from CASID. If the object doesn't exist, get an error. - Expected<ObjectProxy> getProxy(const CASID &ID); + LLVM_ABI Expected<ObjectProxy> getProxy(const CASID &ID); /// Create ObjectProxy from ObjectRef. If the object can't be loaded, get an /// error. - Expected<ObjectProxy> getProxy(ObjectRef Ref); + LLVM_ABI Expected<ObjectProxy> getProxy(ObjectRef Ref); /// \returns \c std::nullopt if the object is missing from the CAS. Expected<std::optional<ObjectProxy>> getProxyIfExists(ObjectRef Ref); @@ -329,13 +329,13 @@ class ObjectProxy { }; /// Create an in memory CAS. -std::unique_ptr<ObjectStore> createInMemoryCAS(); +LLVM_ABI std::unique_ptr<ObjectStore> createInMemoryCAS(); /// \returns true if \c LLVM_ENABLE_ONDISK_CAS configuration was enabled. bool isOnDiskCASEnabled(); /// Create a persistent on-disk path at \p Path. -Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path); +LLVM_ABI Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path); } // namespace cas } // namespace llvm diff --git a/llvm/include/llvm/CAS/OnDiskDataAllocator.h b/llvm/include/llvm/CAS/OnDiskDataAllocator.h index b7099dce2069d..5539329a1a43c 100644 --- a/llvm/include/llvm/CAS/OnDiskDataAllocator.h +++ b/llvm/include/llvm/CAS/OnDiskDataAllocator.h @@ -57,32 +57,32 @@ class OnDiskDataAllocator { /// Get the data of \p Size stored at the given \p Offset. Note the allocator /// doesn't keep track of the allocation size, thus \p Size doesn't need to /// match the size of allocation but needs to be smaller. - Expected<ArrayRef<char>> get(FileOffset Offset, size_t Size) const; + LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> get(FileOffset Offset, size_t Size) const; /// Allocate at least \p Size with 8-byte alignment. - Expected<OnDiskPtr> allocate(size_t Size); + LLVM_ABI_FOR_TEST Expected<OnDiskPtr> allocate(size_t Size); /// \returns the buffer that was allocated at \p create time, with size /// \p UserHeaderSize. MutableArrayRef<uint8_t> getUserHeader() const; - size_t size() const; - size_t capacity() const; + LLVM_ABI_FOR_TEST size_t size() const; + LLVM_ABI_FOR_TEST size_t capacity() const; - static Expected<OnDiskDataAllocator> + LLVM_ABI_FOR_TEST static Expected<OnDiskDataAllocator> create(const Twine &Path, const Twine &TableName, uint64_t MaxFileSize, std::optional<uint64_t> NewFileInitialSize, uint32_t UserHeaderSize = 0, function_ref<void(void *)> UserHeaderInit = nullptr); - OnDiskDataAllocator(OnDiskDataAllocator &&RHS); - OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS); + LLVM_ABI_FOR_TEST OnDiskDataAllocator(OnDiskDataAllocator &&RHS); + LLVM_ABI_FOR_TEST OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS); // No copy. Just call \a create() again. OnDiskDataAllocator(const OnDiskDataAllocator &) = delete; OnDiskDataAllocator &operator=(const OnDiskDataAllocator &) = delete; - ~OnDiskDataAllocator(); + LLVM_ABI_FOR_TEST ~OnDiskDataAllocator(); private: struct ImplType; diff --git a/llvm/include/llvm/CAS/OnDiskGraphDB.h b/llvm/include/llvm/CAS/OnDiskGraphDB.h index 76cc528711b69..2fa8ecf4d81e2 100644 --- a/llvm/include/llvm/CAS/OnDiskGraphDB.h +++ b/llvm/include/llvm/CAS/OnDiskGraphDB.h @@ -259,10 +259,11 @@ class OnDiskGraphDB { /// already a record for this object the operation is a no-op. \param ID the /// object ID to associate the data & references with. \param Refs references /// \param Data data buffer. - Error store(ObjectID ID, ArrayRef<ObjectID> Refs, ArrayRef<char> Data); + LLVM_ABI_FOR_TEST Error store(ObjectID ID, ArrayRef<ObjectID> Refs, + ArrayRef<char> Data); /// \returns \p nullopt if the object associated with \p Ref does not exist. - Expected<std::optional<ObjectHandle>> load(ObjectID Ref); + LLVM_ABI_FOR_TEST Expected<std::optional<ObjectHandle>> load(ObjectID Ref); /// \returns the hash bytes digest for the object reference. ArrayRef<uint8_t> getDigest(ObjectID Ref) const { @@ -272,12 +273,13 @@ class OnDiskGraphDB { /// Form a reference for the provided hash. The reference can be used as part /// of a CAS object even if it's not associated with an object yet. - Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash); + LLVM_ABI_FOR_TEST Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash); /// Get an existing reference to the object \p Digest. /// /// Returns \p nullopt if the object is not stored in this CAS. - std::optional<ObjectID> getExistingReference(ArrayRef<uint8_t> Digest); + LLVM_ABI_FOR_TEST std::optional<ObjectID> + getExistingReference(ArrayRef<uint8_t> Digest); /// Check whether the object associated with \p Ref is stored in the CAS. /// Note that this function will fault-in according to the policy. @@ -290,7 +292,7 @@ class OnDiskGraphDB { } /// \returns the data part of the provided object handle. - ArrayRef<char> getObjectData(ObjectHandle Node) const; + LLVM_ABI_FOR_TEST ArrayRef<char> getObjectData(ObjectHandle Node) const; /// \returns the object referenced by the provided object handle. object_refs_range getObjectRefs(ObjectHandle Node) const { @@ -302,7 +304,7 @@ class OnDiskGraphDB { /// /// NOTE: There's a possibility that the returned size is not including a /// large object if the process crashed right at the point of inserting it. - size_t getStorageSize() const; + LLVM_ABI_FOR_TEST size_t getStorageSize() const; /// \returns The precentage of space utilization of hard space limits. /// @@ -347,12 +349,12 @@ class OnDiskGraphDB { /// \param Policy If \p UpstreamDB is provided, controls how nodes are copied /// to primary store. This is recorded at creation time and subsequent opens /// need to pass the same policy otherwise the \p open will fail. - static Expected<std::unique_ptr<OnDiskGraphDB>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskGraphDB>> open(StringRef Path, StringRef HashName, unsigned HashByteSize, OnDiskGraphDB *UpstreamDB = nullptr, FaultInPolicy Policy = FaultInPolicy::FullTree); - ~OnDiskGraphDB(); + LLVM_ABI_FOR_TEST ~OnDiskGraphDB(); private: /// Forward declaration for a proxy for an ondisk index record. @@ -365,8 +367,8 @@ class OnDiskGraphDB { }; /// Check if object exists and if it is on upstream only. - Expected<ObjectPresence> getObjectPresence(ObjectID Ref, - bool CheckUpstream) const; + LLVM_ABI_FOR_TEST Expected<ObjectPresence> + getObjectPresence(ObjectID Ref, bool CheckUpstream) const; /// \returns true if object can be found in database. bool containsObject(ObjectID Ref, bool CheckUpstream) const { @@ -418,7 +420,8 @@ class OnDiskGraphDB { static InternalRef makeInternalRef(FileOffset IndexOffset); - Expected<ArrayRef<uint8_t>> getDigest(InternalRef Ref) const; + LLVM_ABI_FOR_TEST Expected<ArrayRef<uint8_t>> + getDigest(InternalRef Ref) const; ArrayRef<uint8_t> getDigest(const IndexProxy &I) const; @@ -427,7 +430,8 @@ class OnDiskGraphDB { IndexProxy getIndexProxyFromPointer(OnDiskTrieRawHashMap::ConstOnDiskPtr P) const; - InternalRefArrayRef getInternalRefs(ObjectHandle Node) const; + LLVM_ABI_FOR_TEST InternalRefArrayRef + getInternalRefs(ObjectHandle Node) const; /// \} /// Get the atomic variable that keeps track of the standalone data storage diff --git a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h index 17ae52f0307fc..b19b6db847d5f 100644 --- a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h +++ b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h @@ -36,11 +36,13 @@ class OnDiskKeyValueDB { /// /// \returns the value associated with the \p Key. It may be different than /// \p Value if another value is already associated with this key. - Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key, ArrayRef<char> Value); + LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key, + ArrayRef<char> Value); /// \returns the value associated with the \p Key, or \p std::nullopt if the /// key does not exist. - Expected<std::optional<ArrayRef<char>>> get(ArrayRef<uint8_t> Key); + LLVM_ABI_FOR_TEST Expected<std::optional<ArrayRef<char>>> + get(ArrayRef<uint8_t> Key); /// \returns Total size of stored data. size_t getStorageSize() const { return Cache.size(); } @@ -64,7 +66,7 @@ class OnDiskKeyValueDB { /// \param UnifiedCache An optional UnifiedOnDiskCache that manages the size /// and lifetime of the CAS instance and it must owns current initializing /// KeyValueDB after initialized. - static Expected<std::unique_ptr<OnDiskKeyValueDB>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskKeyValueDB>> open(StringRef Path, StringRef HashName, unsigned KeySize, StringRef ValueName, size_t ValueSize, UnifiedOnDiskCache *UnifiedCache = nullptr); @@ -73,7 +75,7 @@ class OnDiskKeyValueDB { function_ref<Error(FileOffset Offset, ArrayRef<char> Data)>; /// Validate the storage with a callback \p CheckValue to check the stored /// value. - Error validate(CheckValueT CheckValue) const; + LLVM_ABI_FOR_TEST Error validate(CheckValueT CheckValue) const; private: OnDiskKeyValueDB(size_t ValueSize, OnDiskTrieRawHashMap Cache, diff --git a/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h b/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h index fbd68d0f2f53e..819058d2ae9af 100644 --- a/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h +++ b/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h @@ -83,7 +83,7 @@ class OnDiskTrieRawHashMap { /// Validate the trie data structure. /// /// Callback receives the file offset to the data entry and the data stored. - Error validate( + LLVM_ABI_FOR_TEST Error validate( function_ref<Error(FileOffset, ConstValueProxy)> RecordVerifier) const; /// Check the valid range of file offset for OnDiskTrieRawHashMap. @@ -161,10 +161,11 @@ class OnDiskTrieRawHashMap { /// /// \returns pointer to the value if exists, otherwise returns a non-value /// pointer that evaluates to `false` when convert to boolean. - ConstOnDiskPtr find(ArrayRef<uint8_t> Hash) const; + LLVM_ABI_FOR_TEST ConstOnDiskPtr find(ArrayRef<uint8_t> Hash) const; /// Helper function to recover a pointer into the trie from file offset. - Expected<ConstOnDiskPtr> recoverFromFileOffset(FileOffset Offset) const; + LLVM_ABI_FOR_TEST Expected<ConstOnDiskPtr> + recoverFromFileOffset(FileOffset Offset) const; using LazyInsertOnConstructCB = function_ref<void(FileOffset TentativeOffset, ValueProxy TentativeValue)>; @@ -186,9 +187,10 @@ class OnDiskTrieRawHashMap { /// The in-memory \a TrieRawHashMap uses LazyAtomicPointer to synchronize /// simultaneous writes, but that seems dangerous to use in a memory-mapped /// file in case a process crashes in the busy state. - Expected<OnDiskPtr> insertLazy(ArrayRef<uint8_t> Hash, - LazyInsertOnConstructCB OnConstruct = nullptr, - LazyInsertOnLeakCB OnLeak = nullptr); + LLVM_ABI_FOR_TEST Expected<OnDiskPtr> + insertLazy(ArrayRef<uint8_t> Hash, + LazyInsertOnConstructCB OnConstruct = nullptr, + LazyInsertOnLeakCB OnLeak = nullptr); Expected<OnDiskPtr> insert(const ConstValueProxy &Value) { return insertLazy(Value.Hash, [&](FileOffset, ValueProxy Allocated) { @@ -198,8 +200,8 @@ class OnDiskTrieRawHashMap { }); } - size_t size() const; - size_t capacity() const; + LLVM_ABI_FOR_TEST size_t size() const; + LLVM_ABI_FOR_TEST size_t capacity() const; /// Gets or creates a file at \p Path with a hash-mapped trie named \p /// TrieName. The hash size is \p NumHashBits (in bits) and the records store @@ -213,16 +215,16 @@ class OnDiskTrieRawHashMap { /// configure the trie, if it doesn't already exist. /// /// \pre NumHashBits is a multiple of 8 (byte-aligned). - static Expected<OnDiskTrieRawHashMap> + LLVM_ABI_FOR_TEST static Expected<OnDiskTrieRawHashMap> create(const Twine &Path, const Twine &TrieName, size_t NumHashBits, uint64_t DataSize, uint64_t MaxFileSize, std::optional<uint64_t> NewFileInitialSize, std::optional<size_t> NewTableNumRootBits = std::nullopt, std::optional<size_t> NewTableNumSubtrieBits = std::nullopt); - OnDiskTrieRawHashMap(OnDiskTrieRawHashMap &&RHS); - OnDiskTrieRawHashMap &operator=(OnDiskTrieRawHashMap &&RHS); - ~OnDiskTrieRawHashMap(); + LLVM_ABI_FOR_TEST OnDiskTrieRawHashMap(OnDiskTrieRawHashMap &&RHS); + LLVM_ABI_FOR_TEST OnDiskTrieRawHashMap &operator=(OnDiskTrieRawHashMap &&RHS); + LLVM_ABI_FOR_TEST ~OnDiskTrieRawHashMap(); private: struct ImplType; diff --git a/llvm/include/llvm/CAS/UnifiedOnDiskCache.h b/llvm/include/llvm/CAS/UnifiedOnDiskCache.h index 6e0878a65fe72..bb3d7f72e5679 100644 --- a/llvm/include/llvm/CAS/UnifiedOnDiskCache.h +++ b/llvm/include/llvm/CAS/UnifiedOnDiskCache.h @@ -58,7 +58,7 @@ class UnifiedOnDiskCache { /// \param FaultInPolicy Controls how nodes are copied to primary store. This /// is recorded at creation time and subsequent opens need to pass the same /// policy otherwise the \p open will fail. - static Expected<std::unique_ptr<UnifiedOnDiskCache>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<... [truncated] 
@llvmbot
Copy link
Member

llvmbot commented Nov 12, 2025

@llvm/pr-subscribers-llvm-ir

Author: Fabrice de Gans (Steelskin)

Changes

This patch updates various LLVM headers to properly add the LLVM_ABI and LLVM_ABI_FOR_TEST annotations to build LLVM as a DLL on Windows.

This effort is tracked in #109483.


Patch is 68.53 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/167718.diff

41 Files Affected:

  • (modified) llvm/include/llvm/ADT/APFloat.h (+1-1)
  • (modified) llvm/include/llvm/Analysis/IR2Vec.h (+1-1)
  • (modified) llvm/include/llvm/AsmParser/AsmParserContext.h (+3-3)
  • (modified) llvm/include/llvm/BinaryFormat/DXContainer.h (+1-1)
  • (modified) llvm/include/llvm/CAS/ActionCache.h (+3-3)
  • (modified) llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h (+1)
  • (modified) llvm/include/llvm/CAS/CASID.h (+1-1)
  • (modified) llvm/include/llvm/CAS/MappedFileRegionArena.h (+3-3)
  • (modified) llvm/include/llvm/CAS/ObjectStore.h (+5-5)
  • (modified) llvm/include/llvm/CAS/OnDiskDataAllocator.h (+8-8)
  • (modified) llvm/include/llvm/CAS/OnDiskGraphDB.h (+16-12)
  • (modified) llvm/include/llvm/CAS/OnDiskKeyValueDB.h (+6-4)
  • (modified) llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h (+14-12)
  • (modified) llvm/include/llvm/CAS/UnifiedOnDiskCache.h (+9-9)
  • (modified) llvm/include/llvm/CGData/StableFunctionMap.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/MIR2Vec.h (+12-8)
  • (modified) llvm/include/llvm/IR/BasicBlock.h (+1-1)
  • (modified) llvm/include/llvm/Option/ArgList.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Argument.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/BasicBlock.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Function.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Pass.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Region.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Tracker.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Use.h (+1-1)
  • (modified) llvm/include/llvm/Support/GlobPattern.h (+1-1)
  • (modified) llvm/include/llvm/Support/Jobserver.h (+2-2)
  • (modified) llvm/include/llvm/Support/LSP/Logging.h (+3-3)
  • (modified) llvm/include/llvm/Support/LSP/Protocol.h (+113-88)
  • (modified) llvm/include/llvm/Support/LSP/Transport.h (+9-6)
  • (modified) llvm/include/llvm/Support/VirtualOutputBackends.h (+4-4)
  • (modified) llvm/include/llvm/Support/VirtualOutputConfig.h (+6-3)
  • (modified) llvm/include/llvm/Support/VirtualOutputFile.h (+4-4)
  • (modified) llvm/include/llvm/Support/raw_ostream_proxy.h (+3-2)
  • (modified) llvm/include/llvm/Transforms/Utils/SSAUpdaterBulk.h (+1-1)
  • (modified) llvm/lib/CAS/OnDiskCommon.h (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+6-6)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanHelpers.h (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.h (+3-3)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanUtils.h (+2)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanValue.h (+3-2)
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index 82ac9a3a1ef80..b2d5ea33f888c 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -1471,7 +1471,7 @@ class APFloat : public APFloatBase { /// If this value is normal and has an exact, normal, multiplicative inverse, /// store it in inv and return true. - bool getExactInverse(APFloat *Inv) const; + LLVM_ABI bool getExactInverse(APFloat *Inv) const; // If this is an exact power of two, return the exponent while ignoring the // sign bit. If it's not an exact power of 2, return INT_MIN diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h index 7a68773a2643a..5957a3743f22e 100644 --- a/llvm/include/llvm/Analysis/IR2Vec.h +++ b/llvm/include/llvm/Analysis/IR2Vec.h @@ -164,7 +164,7 @@ class VocabStorage { VocabStorage() = default; /// Create a VocabStorage with pre-organized section data - VocabStorage(std::vector<std::vector<Embedding>> &&SectionData); + LLVM_ABI VocabStorage(std::vector<std::vector<Embedding>> &&SectionData); VocabStorage(VocabStorage &&) = default; VocabStorage &operator=(VocabStorage &&) = default; diff --git a/llvm/include/llvm/AsmParser/AsmParserContext.h b/llvm/include/llvm/AsmParser/AsmParserContext.h index 1a397486cba4f..8660babfde1b6 100644 --- a/llvm/include/llvm/AsmParser/AsmParserContext.h +++ b/llvm/include/llvm/AsmParser/AsmParserContext.h @@ -34,9 +34,9 @@ class AsmParserContext { DenseMap<Instruction *, FileLocRange> Instructions; public: - std::optional<FileLocRange> getFunctionLocation(const Function *) const; - std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const; - std::optional<FileLocRange> getInstructionLocation(const Instruction *) const; + LLVM_ABI std::optional<FileLocRange> getFunctionLocation(const Function *) const; + LLVM_ABI std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const; + LLVM_ABI std::optional<FileLocRange> getInstructionLocation(const Instruction *) const; /// Get the function at the requested location range. /// If no single function occupies the queried range, or the record is /// missing, a nullptr is returned. diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h index b9a08ce1ca14e..1756ab0b555ff 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainer.h +++ b/llvm/include/llvm/BinaryFormat/DXContainer.h @@ -201,7 +201,7 @@ enum class RootParameterType : uint32_t { LLVM_ABI ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes(); -bool isValidParameterType(uint32_t V); +LLVM_ABI_FOR_TEST bool isValidParameterType(uint32_t V); bool isValidRangeType(uint32_t V); diff --git a/llvm/include/llvm/CAS/ActionCache.h b/llvm/include/llvm/CAS/ActionCache.h index 7f5b11223c54d..9d3f46e798100 100644 --- a/llvm/include/llvm/CAS/ActionCache.h +++ b/llvm/include/llvm/CAS/ActionCache.h @@ -34,7 +34,7 @@ class CacheKey { StringRef getKey() const { return Key; } CacheKey(const CASID &ID); - CacheKey(const ObjectProxy &Proxy); + LLVM_ABI_FOR_TEST CacheKey(const ObjectProxy &Proxy); CacheKey(const ObjectStore &CAS, const ObjectRef &Ref); private: @@ -98,10 +98,10 @@ class ActionCache { }; /// Create an action cache in memory. -std::unique_ptr<ActionCache> createInMemoryActionCache(); +LLVM_ABI std::unique_ptr<ActionCache> createInMemoryActionCache(); /// Create an action cache on disk. -Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path); +LLVM_ABI Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path); } // end namespace llvm::cas diff --git a/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h b/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h index 6c165c421b168..6368fca4f7072 100644 --- a/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h +++ b/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h @@ -18,6 +18,7 @@ class ObjectStore; /// Create on-disk \c ObjectStore and \c ActionCache instances based on /// \c ondisk::UnifiedOnDiskCache, with built-in hashing. +LLVM_ABI Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>> createOnDiskUnifiedCASDatabases(StringRef Path); diff --git a/llvm/include/llvm/CAS/CASID.h b/llvm/include/llvm/CAS/CASID.h index f508ed3b26c23..8d5a48e26a1af 100644 --- a/llvm/include/llvm/CAS/CASID.h +++ b/llvm/include/llvm/CAS/CASID.h @@ -70,7 +70,7 @@ class CASID { } /// Return a printable string for CASID. - std::string toString() const; + LLVM_ABI std::string toString() const; ArrayRef<uint8_t> getHash() const { return arrayRefFromStringRef<uint8_t>(Hash); diff --git a/llvm/include/llvm/CAS/MappedFileRegionArena.h b/llvm/include/llvm/CAS/MappedFileRegionArena.h index ff51f0eb59929..b90cb53302c39 100644 --- a/llvm/include/llvm/CAS/MappedFileRegionArena.h +++ b/llvm/include/llvm/CAS/MappedFileRegionArena.h @@ -61,7 +61,7 @@ class MappedFileRegionArena { /// that information can be stored before the header, like a file magic. /// \param NewFileConstructor is for constructing new files. It has exclusive /// access to the file. Must call \c initializeBumpPtr. - static Expected<MappedFileRegionArena> + LLVM_ABI_FOR_TEST static Expected<MappedFileRegionArena> create(const Twine &Path, uint64_t Capacity, uint64_t HeaderOffset, function_ref<Error(MappedFileRegionArena &)> NewFileConstructor); @@ -81,7 +81,7 @@ class MappedFileRegionArena { return data() + *Offset; } /// Allocate, returning the offset from \a data() instead of a pointer. - Expected<int64_t> allocateOffset(uint64_t AllocSize); + LLVM_ABI_FOR_TEST Expected<int64_t> allocateOffset(uint64_t AllocSize); char *data() const { return Region.data(); } uint64_t size() const { return H->BumpPtr; } @@ -106,7 +106,7 @@ class MappedFileRegionArena { // initialize header from offset. void initializeHeader(uint64_t HeaderOffset); - void destroyImpl(); + LLVM_ABI_FOR_TEST void destroyImpl(); void moveImpl(MappedFileRegionArena &RHS) { std::swap(Region, RHS.Region); std::swap(H, RHS.H); diff --git a/llvm/include/llvm/CAS/ObjectStore.h b/llvm/include/llvm/CAS/ObjectStore.h index 29950fe9d9029..bcf3f9214051d 100644 --- a/llvm/include/llvm/CAS/ObjectStore.h +++ b/llvm/include/llvm/CAS/ObjectStore.h @@ -179,7 +179,7 @@ class ObjectStore { public: /// Helper functions to store object and returns a ObjectProxy. - Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data); + LLVM_ABI_FOR_TEST Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data); /// Store object from StringRef. Expected<ObjectRef> storeFromString(ArrayRef<ObjectRef> Refs, @@ -205,10 +205,10 @@ class ObjectStore { static Error createUnknownObjectError(const CASID &ID); /// Create ObjectProxy from CASID. If the object doesn't exist, get an error. - Expected<ObjectProxy> getProxy(const CASID &ID); + LLVM_ABI Expected<ObjectProxy> getProxy(const CASID &ID); /// Create ObjectProxy from ObjectRef. If the object can't be loaded, get an /// error. - Expected<ObjectProxy> getProxy(ObjectRef Ref); + LLVM_ABI Expected<ObjectProxy> getProxy(ObjectRef Ref); /// \returns \c std::nullopt if the object is missing from the CAS. Expected<std::optional<ObjectProxy>> getProxyIfExists(ObjectRef Ref); @@ -329,13 +329,13 @@ class ObjectProxy { }; /// Create an in memory CAS. -std::unique_ptr<ObjectStore> createInMemoryCAS(); +LLVM_ABI std::unique_ptr<ObjectStore> createInMemoryCAS(); /// \returns true if \c LLVM_ENABLE_ONDISK_CAS configuration was enabled. bool isOnDiskCASEnabled(); /// Create a persistent on-disk path at \p Path. -Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path); +LLVM_ABI Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path); } // namespace cas } // namespace llvm diff --git a/llvm/include/llvm/CAS/OnDiskDataAllocator.h b/llvm/include/llvm/CAS/OnDiskDataAllocator.h index b7099dce2069d..5539329a1a43c 100644 --- a/llvm/include/llvm/CAS/OnDiskDataAllocator.h +++ b/llvm/include/llvm/CAS/OnDiskDataAllocator.h @@ -57,32 +57,32 @@ class OnDiskDataAllocator { /// Get the data of \p Size stored at the given \p Offset. Note the allocator /// doesn't keep track of the allocation size, thus \p Size doesn't need to /// match the size of allocation but needs to be smaller. - Expected<ArrayRef<char>> get(FileOffset Offset, size_t Size) const; + LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> get(FileOffset Offset, size_t Size) const; /// Allocate at least \p Size with 8-byte alignment. - Expected<OnDiskPtr> allocate(size_t Size); + LLVM_ABI_FOR_TEST Expected<OnDiskPtr> allocate(size_t Size); /// \returns the buffer that was allocated at \p create time, with size /// \p UserHeaderSize. MutableArrayRef<uint8_t> getUserHeader() const; - size_t size() const; - size_t capacity() const; + LLVM_ABI_FOR_TEST size_t size() const; + LLVM_ABI_FOR_TEST size_t capacity() const; - static Expected<OnDiskDataAllocator> + LLVM_ABI_FOR_TEST static Expected<OnDiskDataAllocator> create(const Twine &Path, const Twine &TableName, uint64_t MaxFileSize, std::optional<uint64_t> NewFileInitialSize, uint32_t UserHeaderSize = 0, function_ref<void(void *)> UserHeaderInit = nullptr); - OnDiskDataAllocator(OnDiskDataAllocator &&RHS); - OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS); + LLVM_ABI_FOR_TEST OnDiskDataAllocator(OnDiskDataAllocator &&RHS); + LLVM_ABI_FOR_TEST OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS); // No copy. Just call \a create() again. OnDiskDataAllocator(const OnDiskDataAllocator &) = delete; OnDiskDataAllocator &operator=(const OnDiskDataAllocator &) = delete; - ~OnDiskDataAllocator(); + LLVM_ABI_FOR_TEST ~OnDiskDataAllocator(); private: struct ImplType; diff --git a/llvm/include/llvm/CAS/OnDiskGraphDB.h b/llvm/include/llvm/CAS/OnDiskGraphDB.h index 76cc528711b69..2fa8ecf4d81e2 100644 --- a/llvm/include/llvm/CAS/OnDiskGraphDB.h +++ b/llvm/include/llvm/CAS/OnDiskGraphDB.h @@ -259,10 +259,11 @@ class OnDiskGraphDB { /// already a record for this object the operation is a no-op. \param ID the /// object ID to associate the data & references with. \param Refs references /// \param Data data buffer. - Error store(ObjectID ID, ArrayRef<ObjectID> Refs, ArrayRef<char> Data); + LLVM_ABI_FOR_TEST Error store(ObjectID ID, ArrayRef<ObjectID> Refs, + ArrayRef<char> Data); /// \returns \p nullopt if the object associated with \p Ref does not exist. - Expected<std::optional<ObjectHandle>> load(ObjectID Ref); + LLVM_ABI_FOR_TEST Expected<std::optional<ObjectHandle>> load(ObjectID Ref); /// \returns the hash bytes digest for the object reference. ArrayRef<uint8_t> getDigest(ObjectID Ref) const { @@ -272,12 +273,13 @@ class OnDiskGraphDB { /// Form a reference for the provided hash. The reference can be used as part /// of a CAS object even if it's not associated with an object yet. - Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash); + LLVM_ABI_FOR_TEST Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash); /// Get an existing reference to the object \p Digest. /// /// Returns \p nullopt if the object is not stored in this CAS. - std::optional<ObjectID> getExistingReference(ArrayRef<uint8_t> Digest); + LLVM_ABI_FOR_TEST std::optional<ObjectID> + getExistingReference(ArrayRef<uint8_t> Digest); /// Check whether the object associated with \p Ref is stored in the CAS. /// Note that this function will fault-in according to the policy. @@ -290,7 +292,7 @@ class OnDiskGraphDB { } /// \returns the data part of the provided object handle. - ArrayRef<char> getObjectData(ObjectHandle Node) const; + LLVM_ABI_FOR_TEST ArrayRef<char> getObjectData(ObjectHandle Node) const; /// \returns the object referenced by the provided object handle. object_refs_range getObjectRefs(ObjectHandle Node) const { @@ -302,7 +304,7 @@ class OnDiskGraphDB { /// /// NOTE: There's a possibility that the returned size is not including a /// large object if the process crashed right at the point of inserting it. - size_t getStorageSize() const; + LLVM_ABI_FOR_TEST size_t getStorageSize() const; /// \returns The precentage of space utilization of hard space limits. /// @@ -347,12 +349,12 @@ class OnDiskGraphDB { /// \param Policy If \p UpstreamDB is provided, controls how nodes are copied /// to primary store. This is recorded at creation time and subsequent opens /// need to pass the same policy otherwise the \p open will fail. - static Expected<std::unique_ptr<OnDiskGraphDB>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskGraphDB>> open(StringRef Path, StringRef HashName, unsigned HashByteSize, OnDiskGraphDB *UpstreamDB = nullptr, FaultInPolicy Policy = FaultInPolicy::FullTree); - ~OnDiskGraphDB(); + LLVM_ABI_FOR_TEST ~OnDiskGraphDB(); private: /// Forward declaration for a proxy for an ondisk index record. @@ -365,8 +367,8 @@ class OnDiskGraphDB { }; /// Check if object exists and if it is on upstream only. - Expected<ObjectPresence> getObjectPresence(ObjectID Ref, - bool CheckUpstream) const; + LLVM_ABI_FOR_TEST Expected<ObjectPresence> + getObjectPresence(ObjectID Ref, bool CheckUpstream) const; /// \returns true if object can be found in database. bool containsObject(ObjectID Ref, bool CheckUpstream) const { @@ -418,7 +420,8 @@ class OnDiskGraphDB { static InternalRef makeInternalRef(FileOffset IndexOffset); - Expected<ArrayRef<uint8_t>> getDigest(InternalRef Ref) const; + LLVM_ABI_FOR_TEST Expected<ArrayRef<uint8_t>> + getDigest(InternalRef Ref) const; ArrayRef<uint8_t> getDigest(const IndexProxy &I) const; @@ -427,7 +430,8 @@ class OnDiskGraphDB { IndexProxy getIndexProxyFromPointer(OnDiskTrieRawHashMap::ConstOnDiskPtr P) const; - InternalRefArrayRef getInternalRefs(ObjectHandle Node) const; + LLVM_ABI_FOR_TEST InternalRefArrayRef + getInternalRefs(ObjectHandle Node) const; /// \} /// Get the atomic variable that keeps track of the standalone data storage diff --git a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h index 17ae52f0307fc..b19b6db847d5f 100644 --- a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h +++ b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h @@ -36,11 +36,13 @@ class OnDiskKeyValueDB { /// /// \returns the value associated with the \p Key. It may be different than /// \p Value if another value is already associated with this key. - Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key, ArrayRef<char> Value); + LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key, + ArrayRef<char> Value); /// \returns the value associated with the \p Key, or \p std::nullopt if the /// key does not exist. - Expected<std::optional<ArrayRef<char>>> get(ArrayRef<uint8_t> Key); + LLVM_ABI_FOR_TEST Expected<std::optional<ArrayRef<char>>> + get(ArrayRef<uint8_t> Key); /// \returns Total size of stored data. size_t getStorageSize() const { return Cache.size(); } @@ -64,7 +66,7 @@ class OnDiskKeyValueDB { /// \param UnifiedCache An optional UnifiedOnDiskCache that manages the size /// and lifetime of the CAS instance and it must owns current initializing /// KeyValueDB after initialized. - static Expected<std::unique_ptr<OnDiskKeyValueDB>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskKeyValueDB>> open(StringRef Path, StringRef HashName, unsigned KeySize, StringRef ValueName, size_t ValueSize, UnifiedOnDiskCache *UnifiedCache = nullptr); @@ -73,7 +75,7 @@ class OnDiskKeyValueDB { function_ref<Error(FileOffset Offset, ArrayRef<char> Data)>; /// Validate the storage with a callback \p CheckValue to check the stored /// value. - Error validate(CheckValueT CheckValue) const; + LLVM_ABI_FOR_TEST Error validate(CheckValueT CheckValue) const; private: OnDiskKeyValueDB(size_t ValueSize, OnDiskTrieRawHashMap Cache, diff --git a/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h b/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h index fbd68d0f2f53e..819058d2ae9af 100644 --- a/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h +++ b/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h @@ -83,7 +83,7 @@ class OnDiskTrieRawHashMap { /// Validate the trie data structure. /// /// Callback receives the file offset to the data entry and the data stored. - Error validate( + LLVM_ABI_FOR_TEST Error validate( function_ref<Error(FileOffset, ConstValueProxy)> RecordVerifier) const; /// Check the valid range of file offset for OnDiskTrieRawHashMap. @@ -161,10 +161,11 @@ class OnDiskTrieRawHashMap { /// /// \returns pointer to the value if exists, otherwise returns a non-value /// pointer that evaluates to `false` when convert to boolean. - ConstOnDiskPtr find(ArrayRef<uint8_t> Hash) const; + LLVM_ABI_FOR_TEST ConstOnDiskPtr find(ArrayRef<uint8_t> Hash) const; /// Helper function to recover a pointer into the trie from file offset. - Expected<ConstOnDiskPtr> recoverFromFileOffset(FileOffset Offset) const; + LLVM_ABI_FOR_TEST Expected<ConstOnDiskPtr> + recoverFromFileOffset(FileOffset Offset) const; using LazyInsertOnConstructCB = function_ref<void(FileOffset TentativeOffset, ValueProxy TentativeValue)>; @@ -186,9 +187,10 @@ class OnDiskTrieRawHashMap { /// The in-memory \a TrieRawHashMap uses LazyAtomicPointer to synchronize /// simultaneous writes, but that seems dangerous to use in a memory-mapped /// file in case a process crashes in the busy state. - Expected<OnDiskPtr> insertLazy(ArrayRef<uint8_t> Hash, - LazyInsertOnConstructCB OnConstruct = nullptr, - LazyInsertOnLeakCB OnLeak = nullptr); + LLVM_ABI_FOR_TEST Expected<OnDiskPtr> + insertLazy(ArrayRef<uint8_t> Hash, + LazyInsertOnConstructCB OnConstruct = nullptr, + LazyInsertOnLeakCB OnLeak = nullptr); Expected<OnDiskPtr> insert(const ConstValueProxy &Value) { return insertLazy(Value.Hash, [&](FileOffset, ValueProxy Allocated) { @@ -198,8 +200,8 @@ class OnDiskTrieRawHashMap { }); } - size_t size() const; - size_t capacity() const; + LLVM_ABI_FOR_TEST size_t size() const; + LLVM_ABI_FOR_TEST size_t capacity() const; /// Gets or creates a file at \p Path with a hash-mapped trie named \p /// TrieName. The hash size is \p NumHashBits (in bits) and the records store @@ -213,16 +215,16 @@ class OnDiskTrieRawHashMap { /// configure the trie, if it doesn't already exist. /// /// \pre NumHashBits is a multiple of 8 (byte-aligned). - static Expected<OnDiskTrieRawHashMap> + LLVM_ABI_FOR_TEST static Expected<OnDiskTrieRawHashMap> create(const Twine &Path, const Twine &TrieName, size_t NumHashBits, uint64_t DataSize, uint64_t MaxFileSize, std::optional<uint64_t> NewFileInitialSize, std::optional<size_t> NewTableNumRootBits = std::nullopt, std::optional<size_t> NewTableNumSubtrieBits = std::nullopt); - OnDiskTrieRawHashMap(OnDiskTrieRawHashMap &&RHS); - OnDiskTrieRawHashMap &operator=(OnDiskTrieRawHashMap &&RHS); - ~OnDiskTrieRawHashMap(); + LLVM_ABI_FOR_TEST OnDiskTrieRawHashMap(OnDiskTrieRawHashMap &&RHS); + LLVM_ABI_FOR_TEST OnDiskTrieRawHashMap &operator=(OnDiskTrieRawHashMap &&RHS); + LLVM_ABI_FOR_TEST ~OnDiskTrieRawHashMap(); private: struct ImplType; diff --git a/llvm/include/llvm/CAS/UnifiedOnDiskCache.h b/llvm/include/llvm/CAS/UnifiedOnDiskCache.h index 6e0878a65fe72..bb3d7f72e5679 100644 --- a/llvm/include/llvm/CAS/UnifiedOnDiskCache.h +++ b/llvm/include/llvm/CAS/UnifiedOnDiskCache.h @@ -58,7 +58,7 @@ class UnifiedOnDiskCache { /// \param FaultInPolicy Controls how nodes are copied to primary store. This /// is recorded at creation time and subsequent opens need to pass the same /// policy otherwise the \p open will fail. - static Expected<std::unique_ptr<UnifiedOnDiskCache>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<... [truncated] 
@llvmbot
Copy link
Member

llvmbot commented Nov 12, 2025

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

Author: Fabrice de Gans (Steelskin)

Changes

This patch updates various LLVM headers to properly add the LLVM_ABI and LLVM_ABI_FOR_TEST annotations to build LLVM as a DLL on Windows.

This effort is tracked in #109483.


Patch is 68.53 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/167718.diff

41 Files Affected:

  • (modified) llvm/include/llvm/ADT/APFloat.h (+1-1)
  • (modified) llvm/include/llvm/Analysis/IR2Vec.h (+1-1)
  • (modified) llvm/include/llvm/AsmParser/AsmParserContext.h (+3-3)
  • (modified) llvm/include/llvm/BinaryFormat/DXContainer.h (+1-1)
  • (modified) llvm/include/llvm/CAS/ActionCache.h (+3-3)
  • (modified) llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h (+1)
  • (modified) llvm/include/llvm/CAS/CASID.h (+1-1)
  • (modified) llvm/include/llvm/CAS/MappedFileRegionArena.h (+3-3)
  • (modified) llvm/include/llvm/CAS/ObjectStore.h (+5-5)
  • (modified) llvm/include/llvm/CAS/OnDiskDataAllocator.h (+8-8)
  • (modified) llvm/include/llvm/CAS/OnDiskGraphDB.h (+16-12)
  • (modified) llvm/include/llvm/CAS/OnDiskKeyValueDB.h (+6-4)
  • (modified) llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h (+14-12)
  • (modified) llvm/include/llvm/CAS/UnifiedOnDiskCache.h (+9-9)
  • (modified) llvm/include/llvm/CGData/StableFunctionMap.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/MIR2Vec.h (+12-8)
  • (modified) llvm/include/llvm/IR/BasicBlock.h (+1-1)
  • (modified) llvm/include/llvm/Option/ArgList.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Argument.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/BasicBlock.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Function.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Pass.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Region.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Tracker.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Use.h (+1-1)
  • (modified) llvm/include/llvm/Support/GlobPattern.h (+1-1)
  • (modified) llvm/include/llvm/Support/Jobserver.h (+2-2)
  • (modified) llvm/include/llvm/Support/LSP/Logging.h (+3-3)
  • (modified) llvm/include/llvm/Support/LSP/Protocol.h (+113-88)
  • (modified) llvm/include/llvm/Support/LSP/Transport.h (+9-6)
  • (modified) llvm/include/llvm/Support/VirtualOutputBackends.h (+4-4)
  • (modified) llvm/include/llvm/Support/VirtualOutputConfig.h (+6-3)
  • (modified) llvm/include/llvm/Support/VirtualOutputFile.h (+4-4)
  • (modified) llvm/include/llvm/Support/raw_ostream_proxy.h (+3-2)
  • (modified) llvm/include/llvm/Transforms/Utils/SSAUpdaterBulk.h (+1-1)
  • (modified) llvm/lib/CAS/OnDiskCommon.h (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+6-6)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanHelpers.h (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.h (+3-3)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanUtils.h (+2)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanValue.h (+3-2)
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index 82ac9a3a1ef80..b2d5ea33f888c 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -1471,7 +1471,7 @@ class APFloat : public APFloatBase { /// If this value is normal and has an exact, normal, multiplicative inverse, /// store it in inv and return true. - bool getExactInverse(APFloat *Inv) const; + LLVM_ABI bool getExactInverse(APFloat *Inv) const; // If this is an exact power of two, return the exponent while ignoring the // sign bit. If it's not an exact power of 2, return INT_MIN diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h index 7a68773a2643a..5957a3743f22e 100644 --- a/llvm/include/llvm/Analysis/IR2Vec.h +++ b/llvm/include/llvm/Analysis/IR2Vec.h @@ -164,7 +164,7 @@ class VocabStorage { VocabStorage() = default; /// Create a VocabStorage with pre-organized section data - VocabStorage(std::vector<std::vector<Embedding>> &&SectionData); + LLVM_ABI VocabStorage(std::vector<std::vector<Embedding>> &&SectionData); VocabStorage(VocabStorage &&) = default; VocabStorage &operator=(VocabStorage &&) = default; diff --git a/llvm/include/llvm/AsmParser/AsmParserContext.h b/llvm/include/llvm/AsmParser/AsmParserContext.h index 1a397486cba4f..8660babfde1b6 100644 --- a/llvm/include/llvm/AsmParser/AsmParserContext.h +++ b/llvm/include/llvm/AsmParser/AsmParserContext.h @@ -34,9 +34,9 @@ class AsmParserContext { DenseMap<Instruction *, FileLocRange> Instructions; public: - std::optional<FileLocRange> getFunctionLocation(const Function *) const; - std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const; - std::optional<FileLocRange> getInstructionLocation(const Instruction *) const; + LLVM_ABI std::optional<FileLocRange> getFunctionLocation(const Function *) const; + LLVM_ABI std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const; + LLVM_ABI std::optional<FileLocRange> getInstructionLocation(const Instruction *) const; /// Get the function at the requested location range. /// If no single function occupies the queried range, or the record is /// missing, a nullptr is returned. diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h index b9a08ce1ca14e..1756ab0b555ff 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainer.h +++ b/llvm/include/llvm/BinaryFormat/DXContainer.h @@ -201,7 +201,7 @@ enum class RootParameterType : uint32_t { LLVM_ABI ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes(); -bool isValidParameterType(uint32_t V); +LLVM_ABI_FOR_TEST bool isValidParameterType(uint32_t V); bool isValidRangeType(uint32_t V); diff --git a/llvm/include/llvm/CAS/ActionCache.h b/llvm/include/llvm/CAS/ActionCache.h index 7f5b11223c54d..9d3f46e798100 100644 --- a/llvm/include/llvm/CAS/ActionCache.h +++ b/llvm/include/llvm/CAS/ActionCache.h @@ -34,7 +34,7 @@ class CacheKey { StringRef getKey() const { return Key; } CacheKey(const CASID &ID); - CacheKey(const ObjectProxy &Proxy); + LLVM_ABI_FOR_TEST CacheKey(const ObjectProxy &Proxy); CacheKey(const ObjectStore &CAS, const ObjectRef &Ref); private: @@ -98,10 +98,10 @@ class ActionCache { }; /// Create an action cache in memory. -std::unique_ptr<ActionCache> createInMemoryActionCache(); +LLVM_ABI std::unique_ptr<ActionCache> createInMemoryActionCache(); /// Create an action cache on disk. -Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path); +LLVM_ABI Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path); } // end namespace llvm::cas diff --git a/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h b/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h index 6c165c421b168..6368fca4f7072 100644 --- a/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h +++ b/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h @@ -18,6 +18,7 @@ class ObjectStore; /// Create on-disk \c ObjectStore and \c ActionCache instances based on /// \c ondisk::UnifiedOnDiskCache, with built-in hashing. +LLVM_ABI Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>> createOnDiskUnifiedCASDatabases(StringRef Path); diff --git a/llvm/include/llvm/CAS/CASID.h b/llvm/include/llvm/CAS/CASID.h index f508ed3b26c23..8d5a48e26a1af 100644 --- a/llvm/include/llvm/CAS/CASID.h +++ b/llvm/include/llvm/CAS/CASID.h @@ -70,7 +70,7 @@ class CASID { } /// Return a printable string for CASID. - std::string toString() const; + LLVM_ABI std::string toString() const; ArrayRef<uint8_t> getHash() const { return arrayRefFromStringRef<uint8_t>(Hash); diff --git a/llvm/include/llvm/CAS/MappedFileRegionArena.h b/llvm/include/llvm/CAS/MappedFileRegionArena.h index ff51f0eb59929..b90cb53302c39 100644 --- a/llvm/include/llvm/CAS/MappedFileRegionArena.h +++ b/llvm/include/llvm/CAS/MappedFileRegionArena.h @@ -61,7 +61,7 @@ class MappedFileRegionArena { /// that information can be stored before the header, like a file magic. /// \param NewFileConstructor is for constructing new files. It has exclusive /// access to the file. Must call \c initializeBumpPtr. - static Expected<MappedFileRegionArena> + LLVM_ABI_FOR_TEST static Expected<MappedFileRegionArena> create(const Twine &Path, uint64_t Capacity, uint64_t HeaderOffset, function_ref<Error(MappedFileRegionArena &)> NewFileConstructor); @@ -81,7 +81,7 @@ class MappedFileRegionArena { return data() + *Offset; } /// Allocate, returning the offset from \a data() instead of a pointer. - Expected<int64_t> allocateOffset(uint64_t AllocSize); + LLVM_ABI_FOR_TEST Expected<int64_t> allocateOffset(uint64_t AllocSize); char *data() const { return Region.data(); } uint64_t size() const { return H->BumpPtr; } @@ -106,7 +106,7 @@ class MappedFileRegionArena { // initialize header from offset. void initializeHeader(uint64_t HeaderOffset); - void destroyImpl(); + LLVM_ABI_FOR_TEST void destroyImpl(); void moveImpl(MappedFileRegionArena &RHS) { std::swap(Region, RHS.Region); std::swap(H, RHS.H); diff --git a/llvm/include/llvm/CAS/ObjectStore.h b/llvm/include/llvm/CAS/ObjectStore.h index 29950fe9d9029..bcf3f9214051d 100644 --- a/llvm/include/llvm/CAS/ObjectStore.h +++ b/llvm/include/llvm/CAS/ObjectStore.h @@ -179,7 +179,7 @@ class ObjectStore { public: /// Helper functions to store object and returns a ObjectProxy. - Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data); + LLVM_ABI_FOR_TEST Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data); /// Store object from StringRef. Expected<ObjectRef> storeFromString(ArrayRef<ObjectRef> Refs, @@ -205,10 +205,10 @@ class ObjectStore { static Error createUnknownObjectError(const CASID &ID); /// Create ObjectProxy from CASID. If the object doesn't exist, get an error. - Expected<ObjectProxy> getProxy(const CASID &ID); + LLVM_ABI Expected<ObjectProxy> getProxy(const CASID &ID); /// Create ObjectProxy from ObjectRef. If the object can't be loaded, get an /// error. - Expected<ObjectProxy> getProxy(ObjectRef Ref); + LLVM_ABI Expected<ObjectProxy> getProxy(ObjectRef Ref); /// \returns \c std::nullopt if the object is missing from the CAS. Expected<std::optional<ObjectProxy>> getProxyIfExists(ObjectRef Ref); @@ -329,13 +329,13 @@ class ObjectProxy { }; /// Create an in memory CAS. -std::unique_ptr<ObjectStore> createInMemoryCAS(); +LLVM_ABI std::unique_ptr<ObjectStore> createInMemoryCAS(); /// \returns true if \c LLVM_ENABLE_ONDISK_CAS configuration was enabled. bool isOnDiskCASEnabled(); /// Create a persistent on-disk path at \p Path. -Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path); +LLVM_ABI Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path); } // namespace cas } // namespace llvm diff --git a/llvm/include/llvm/CAS/OnDiskDataAllocator.h b/llvm/include/llvm/CAS/OnDiskDataAllocator.h index b7099dce2069d..5539329a1a43c 100644 --- a/llvm/include/llvm/CAS/OnDiskDataAllocator.h +++ b/llvm/include/llvm/CAS/OnDiskDataAllocator.h @@ -57,32 +57,32 @@ class OnDiskDataAllocator { /// Get the data of \p Size stored at the given \p Offset. Note the allocator /// doesn't keep track of the allocation size, thus \p Size doesn't need to /// match the size of allocation but needs to be smaller. - Expected<ArrayRef<char>> get(FileOffset Offset, size_t Size) const; + LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> get(FileOffset Offset, size_t Size) const; /// Allocate at least \p Size with 8-byte alignment. - Expected<OnDiskPtr> allocate(size_t Size); + LLVM_ABI_FOR_TEST Expected<OnDiskPtr> allocate(size_t Size); /// \returns the buffer that was allocated at \p create time, with size /// \p UserHeaderSize. MutableArrayRef<uint8_t> getUserHeader() const; - size_t size() const; - size_t capacity() const; + LLVM_ABI_FOR_TEST size_t size() const; + LLVM_ABI_FOR_TEST size_t capacity() const; - static Expected<OnDiskDataAllocator> + LLVM_ABI_FOR_TEST static Expected<OnDiskDataAllocator> create(const Twine &Path, const Twine &TableName, uint64_t MaxFileSize, std::optional<uint64_t> NewFileInitialSize, uint32_t UserHeaderSize = 0, function_ref<void(void *)> UserHeaderInit = nullptr); - OnDiskDataAllocator(OnDiskDataAllocator &&RHS); - OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS); + LLVM_ABI_FOR_TEST OnDiskDataAllocator(OnDiskDataAllocator &&RHS); + LLVM_ABI_FOR_TEST OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS); // No copy. Just call \a create() again. OnDiskDataAllocator(const OnDiskDataAllocator &) = delete; OnDiskDataAllocator &operator=(const OnDiskDataAllocator &) = delete; - ~OnDiskDataAllocator(); + LLVM_ABI_FOR_TEST ~OnDiskDataAllocator(); private: struct ImplType; diff --git a/llvm/include/llvm/CAS/OnDiskGraphDB.h b/llvm/include/llvm/CAS/OnDiskGraphDB.h index 76cc528711b69..2fa8ecf4d81e2 100644 --- a/llvm/include/llvm/CAS/OnDiskGraphDB.h +++ b/llvm/include/llvm/CAS/OnDiskGraphDB.h @@ -259,10 +259,11 @@ class OnDiskGraphDB { /// already a record for this object the operation is a no-op. \param ID the /// object ID to associate the data & references with. \param Refs references /// \param Data data buffer. - Error store(ObjectID ID, ArrayRef<ObjectID> Refs, ArrayRef<char> Data); + LLVM_ABI_FOR_TEST Error store(ObjectID ID, ArrayRef<ObjectID> Refs, + ArrayRef<char> Data); /// \returns \p nullopt if the object associated with \p Ref does not exist. - Expected<std::optional<ObjectHandle>> load(ObjectID Ref); + LLVM_ABI_FOR_TEST Expected<std::optional<ObjectHandle>> load(ObjectID Ref); /// \returns the hash bytes digest for the object reference. ArrayRef<uint8_t> getDigest(ObjectID Ref) const { @@ -272,12 +273,13 @@ class OnDiskGraphDB { /// Form a reference for the provided hash. The reference can be used as part /// of a CAS object even if it's not associated with an object yet. - Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash); + LLVM_ABI_FOR_TEST Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash); /// Get an existing reference to the object \p Digest. /// /// Returns \p nullopt if the object is not stored in this CAS. - std::optional<ObjectID> getExistingReference(ArrayRef<uint8_t> Digest); + LLVM_ABI_FOR_TEST std::optional<ObjectID> + getExistingReference(ArrayRef<uint8_t> Digest); /// Check whether the object associated with \p Ref is stored in the CAS. /// Note that this function will fault-in according to the policy. @@ -290,7 +292,7 @@ class OnDiskGraphDB { } /// \returns the data part of the provided object handle. - ArrayRef<char> getObjectData(ObjectHandle Node) const; + LLVM_ABI_FOR_TEST ArrayRef<char> getObjectData(ObjectHandle Node) const; /// \returns the object referenced by the provided object handle. object_refs_range getObjectRefs(ObjectHandle Node) const { @@ -302,7 +304,7 @@ class OnDiskGraphDB { /// /// NOTE: There's a possibility that the returned size is not including a /// large object if the process crashed right at the point of inserting it. - size_t getStorageSize() const; + LLVM_ABI_FOR_TEST size_t getStorageSize() const; /// \returns The precentage of space utilization of hard space limits. /// @@ -347,12 +349,12 @@ class OnDiskGraphDB { /// \param Policy If \p UpstreamDB is provided, controls how nodes are copied /// to primary store. This is recorded at creation time and subsequent opens /// need to pass the same policy otherwise the \p open will fail. - static Expected<std::unique_ptr<OnDiskGraphDB>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskGraphDB>> open(StringRef Path, StringRef HashName, unsigned HashByteSize, OnDiskGraphDB *UpstreamDB = nullptr, FaultInPolicy Policy = FaultInPolicy::FullTree); - ~OnDiskGraphDB(); + LLVM_ABI_FOR_TEST ~OnDiskGraphDB(); private: /// Forward declaration for a proxy for an ondisk index record. @@ -365,8 +367,8 @@ class OnDiskGraphDB { }; /// Check if object exists and if it is on upstream only. - Expected<ObjectPresence> getObjectPresence(ObjectID Ref, - bool CheckUpstream) const; + LLVM_ABI_FOR_TEST Expected<ObjectPresence> + getObjectPresence(ObjectID Ref, bool CheckUpstream) const; /// \returns true if object can be found in database. bool containsObject(ObjectID Ref, bool CheckUpstream) const { @@ -418,7 +420,8 @@ class OnDiskGraphDB { static InternalRef makeInternalRef(FileOffset IndexOffset); - Expected<ArrayRef<uint8_t>> getDigest(InternalRef Ref) const; + LLVM_ABI_FOR_TEST Expected<ArrayRef<uint8_t>> + getDigest(InternalRef Ref) const; ArrayRef<uint8_t> getDigest(const IndexProxy &I) const; @@ -427,7 +430,8 @@ class OnDiskGraphDB { IndexProxy getIndexProxyFromPointer(OnDiskTrieRawHashMap::ConstOnDiskPtr P) const; - InternalRefArrayRef getInternalRefs(ObjectHandle Node) const; + LLVM_ABI_FOR_TEST InternalRefArrayRef + getInternalRefs(ObjectHandle Node) const; /// \} /// Get the atomic variable that keeps track of the standalone data storage diff --git a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h index 17ae52f0307fc..b19b6db847d5f 100644 --- a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h +++ b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h @@ -36,11 +36,13 @@ class OnDiskKeyValueDB { /// /// \returns the value associated with the \p Key. It may be different than /// \p Value if another value is already associated with this key. - Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key, ArrayRef<char> Value); + LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key, + ArrayRef<char> Value); /// \returns the value associated with the \p Key, or \p std::nullopt if the /// key does not exist. - Expected<std::optional<ArrayRef<char>>> get(ArrayRef<uint8_t> Key); + LLVM_ABI_FOR_TEST Expected<std::optional<ArrayRef<char>>> + get(ArrayRef<uint8_t> Key); /// \returns Total size of stored data. size_t getStorageSize() const { return Cache.size(); } @@ -64,7 +66,7 @@ class OnDiskKeyValueDB { /// \param UnifiedCache An optional UnifiedOnDiskCache that manages the size /// and lifetime of the CAS instance and it must owns current initializing /// KeyValueDB after initialized. - static Expected<std::unique_ptr<OnDiskKeyValueDB>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskKeyValueDB>> open(StringRef Path, StringRef HashName, unsigned KeySize, StringRef ValueName, size_t ValueSize, UnifiedOnDiskCache *UnifiedCache = nullptr); @@ -73,7 +75,7 @@ class OnDiskKeyValueDB { function_ref<Error(FileOffset Offset, ArrayRef<char> Data)>; /// Validate the storage with a callback \p CheckValue to check the stored /// value. - Error validate(CheckValueT CheckValue) const; + LLVM_ABI_FOR_TEST Error validate(CheckValueT CheckValue) const; private: OnDiskKeyValueDB(size_t ValueSize, OnDiskTrieRawHashMap Cache, diff --git a/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h b/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h index fbd68d0f2f53e..819058d2ae9af 100644 --- a/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h +++ b/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h @@ -83,7 +83,7 @@ class OnDiskTrieRawHashMap { /// Validate the trie data structure. /// /// Callback receives the file offset to the data entry and the data stored. - Error validate( + LLVM_ABI_FOR_TEST Error validate( function_ref<Error(FileOffset, ConstValueProxy)> RecordVerifier) const; /// Check the valid range of file offset for OnDiskTrieRawHashMap. @@ -161,10 +161,11 @@ class OnDiskTrieRawHashMap { /// /// \returns pointer to the value if exists, otherwise returns a non-value /// pointer that evaluates to `false` when convert to boolean. - ConstOnDiskPtr find(ArrayRef<uint8_t> Hash) const; + LLVM_ABI_FOR_TEST ConstOnDiskPtr find(ArrayRef<uint8_t> Hash) const; /// Helper function to recover a pointer into the trie from file offset. - Expected<ConstOnDiskPtr> recoverFromFileOffset(FileOffset Offset) const; + LLVM_ABI_FOR_TEST Expected<ConstOnDiskPtr> + recoverFromFileOffset(FileOffset Offset) const; using LazyInsertOnConstructCB = function_ref<void(FileOffset TentativeOffset, ValueProxy TentativeValue)>; @@ -186,9 +187,10 @@ class OnDiskTrieRawHashMap { /// The in-memory \a TrieRawHashMap uses LazyAtomicPointer to synchronize /// simultaneous writes, but that seems dangerous to use in a memory-mapped /// file in case a process crashes in the busy state. - Expected<OnDiskPtr> insertLazy(ArrayRef<uint8_t> Hash, - LazyInsertOnConstructCB OnConstruct = nullptr, - LazyInsertOnLeakCB OnLeak = nullptr); + LLVM_ABI_FOR_TEST Expected<OnDiskPtr> + insertLazy(ArrayRef<uint8_t> Hash, + LazyInsertOnConstructCB OnConstruct = nullptr, + LazyInsertOnLeakCB OnLeak = nullptr); Expected<OnDiskPtr> insert(const ConstValueProxy &Value) { return insertLazy(Value.Hash, [&](FileOffset, ValueProxy Allocated) { @@ -198,8 +200,8 @@ class OnDiskTrieRawHashMap { }); } - size_t size() const; - size_t capacity() const; + LLVM_ABI_FOR_TEST size_t size() const; + LLVM_ABI_FOR_TEST size_t capacity() const; /// Gets or creates a file at \p Path with a hash-mapped trie named \p /// TrieName. The hash size is \p NumHashBits (in bits) and the records store @@ -213,16 +215,16 @@ class OnDiskTrieRawHashMap { /// configure the trie, if it doesn't already exist. /// /// \pre NumHashBits is a multiple of 8 (byte-aligned). - static Expected<OnDiskTrieRawHashMap> + LLVM_ABI_FOR_TEST static Expected<OnDiskTrieRawHashMap> create(const Twine &Path, const Twine &TrieName, size_t NumHashBits, uint64_t DataSize, uint64_t MaxFileSize, std::optional<uint64_t> NewFileInitialSize, std::optional<size_t> NewTableNumRootBits = std::nullopt, std::optional<size_t> NewTableNumSubtrieBits = std::nullopt); - OnDiskTrieRawHashMap(OnDiskTrieRawHashMap &&RHS); - OnDiskTrieRawHashMap &operator=(OnDiskTrieRawHashMap &&RHS); - ~OnDiskTrieRawHashMap(); + LLVM_ABI_FOR_TEST OnDiskTrieRawHashMap(OnDiskTrieRawHashMap &&RHS); + LLVM_ABI_FOR_TEST OnDiskTrieRawHashMap &operator=(OnDiskTrieRawHashMap &&RHS); + LLVM_ABI_FOR_TEST ~OnDiskTrieRawHashMap(); private: struct ImplType; diff --git a/llvm/include/llvm/CAS/UnifiedOnDiskCache.h b/llvm/include/llvm/CAS/UnifiedOnDiskCache.h index 6e0878a65fe72..bb3d7f72e5679 100644 --- a/llvm/include/llvm/CAS/UnifiedOnDiskCache.h +++ b/llvm/include/llvm/CAS/UnifiedOnDiskCache.h @@ -58,7 +58,7 @@ class UnifiedOnDiskCache { /// \param FaultInPolicy Controls how nodes are copied to primary store. This /// is recorded at creation time and subsequent opens need to pass the same /// policy otherwise the \p open will fail. - static Expected<std::unique_ptr<UnifiedOnDiskCache>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<... [truncated] 
@llvmbot
Copy link
Member

llvmbot commented Nov 12, 2025

@llvm/pr-subscribers-vectorizers

Author: Fabrice de Gans (Steelskin)

Changes

This patch updates various LLVM headers to properly add the LLVM_ABI and LLVM_ABI_FOR_TEST annotations to build LLVM as a DLL on Windows.

This effort is tracked in #109483.


Patch is 68.53 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/167718.diff

41 Files Affected:

  • (modified) llvm/include/llvm/ADT/APFloat.h (+1-1)
  • (modified) llvm/include/llvm/Analysis/IR2Vec.h (+1-1)
  • (modified) llvm/include/llvm/AsmParser/AsmParserContext.h (+3-3)
  • (modified) llvm/include/llvm/BinaryFormat/DXContainer.h (+1-1)
  • (modified) llvm/include/llvm/CAS/ActionCache.h (+3-3)
  • (modified) llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h (+1)
  • (modified) llvm/include/llvm/CAS/CASID.h (+1-1)
  • (modified) llvm/include/llvm/CAS/MappedFileRegionArena.h (+3-3)
  • (modified) llvm/include/llvm/CAS/ObjectStore.h (+5-5)
  • (modified) llvm/include/llvm/CAS/OnDiskDataAllocator.h (+8-8)
  • (modified) llvm/include/llvm/CAS/OnDiskGraphDB.h (+16-12)
  • (modified) llvm/include/llvm/CAS/OnDiskKeyValueDB.h (+6-4)
  • (modified) llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h (+14-12)
  • (modified) llvm/include/llvm/CAS/UnifiedOnDiskCache.h (+9-9)
  • (modified) llvm/include/llvm/CGData/StableFunctionMap.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/MIR2Vec.h (+12-8)
  • (modified) llvm/include/llvm/IR/BasicBlock.h (+1-1)
  • (modified) llvm/include/llvm/Option/ArgList.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Argument.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/BasicBlock.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Function.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Pass.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Region.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Tracker.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Use.h (+1-1)
  • (modified) llvm/include/llvm/Support/GlobPattern.h (+1-1)
  • (modified) llvm/include/llvm/Support/Jobserver.h (+2-2)
  • (modified) llvm/include/llvm/Support/LSP/Logging.h (+3-3)
  • (modified) llvm/include/llvm/Support/LSP/Protocol.h (+113-88)
  • (modified) llvm/include/llvm/Support/LSP/Transport.h (+9-6)
  • (modified) llvm/include/llvm/Support/VirtualOutputBackends.h (+4-4)
  • (modified) llvm/include/llvm/Support/VirtualOutputConfig.h (+6-3)
  • (modified) llvm/include/llvm/Support/VirtualOutputFile.h (+4-4)
  • (modified) llvm/include/llvm/Support/raw_ostream_proxy.h (+3-2)
  • (modified) llvm/include/llvm/Transforms/Utils/SSAUpdaterBulk.h (+1-1)
  • (modified) llvm/lib/CAS/OnDiskCommon.h (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+6-6)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanHelpers.h (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.h (+3-3)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanUtils.h (+2)
  • (modified) llvm/lib/Transforms/Vectorize/VPlanValue.h (+3-2)
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index 82ac9a3a1ef80..b2d5ea33f888c 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -1471,7 +1471,7 @@ class APFloat : public APFloatBase { /// If this value is normal and has an exact, normal, multiplicative inverse, /// store it in inv and return true. - bool getExactInverse(APFloat *Inv) const; + LLVM_ABI bool getExactInverse(APFloat *Inv) const; // If this is an exact power of two, return the exponent while ignoring the // sign bit. If it's not an exact power of 2, return INT_MIN diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h index 7a68773a2643a..5957a3743f22e 100644 --- a/llvm/include/llvm/Analysis/IR2Vec.h +++ b/llvm/include/llvm/Analysis/IR2Vec.h @@ -164,7 +164,7 @@ class VocabStorage { VocabStorage() = default; /// Create a VocabStorage with pre-organized section data - VocabStorage(std::vector<std::vector<Embedding>> &&SectionData); + LLVM_ABI VocabStorage(std::vector<std::vector<Embedding>> &&SectionData); VocabStorage(VocabStorage &&) = default; VocabStorage &operator=(VocabStorage &&) = default; diff --git a/llvm/include/llvm/AsmParser/AsmParserContext.h b/llvm/include/llvm/AsmParser/AsmParserContext.h index 1a397486cba4f..8660babfde1b6 100644 --- a/llvm/include/llvm/AsmParser/AsmParserContext.h +++ b/llvm/include/llvm/AsmParser/AsmParserContext.h @@ -34,9 +34,9 @@ class AsmParserContext { DenseMap<Instruction *, FileLocRange> Instructions; public: - std::optional<FileLocRange> getFunctionLocation(const Function *) const; - std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const; - std::optional<FileLocRange> getInstructionLocation(const Instruction *) const; + LLVM_ABI std::optional<FileLocRange> getFunctionLocation(const Function *) const; + LLVM_ABI std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const; + LLVM_ABI std::optional<FileLocRange> getInstructionLocation(const Instruction *) const; /// Get the function at the requested location range. /// If no single function occupies the queried range, or the record is /// missing, a nullptr is returned. diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h index b9a08ce1ca14e..1756ab0b555ff 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainer.h +++ b/llvm/include/llvm/BinaryFormat/DXContainer.h @@ -201,7 +201,7 @@ enum class RootParameterType : uint32_t { LLVM_ABI ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes(); -bool isValidParameterType(uint32_t V); +LLVM_ABI_FOR_TEST bool isValidParameterType(uint32_t V); bool isValidRangeType(uint32_t V); diff --git a/llvm/include/llvm/CAS/ActionCache.h b/llvm/include/llvm/CAS/ActionCache.h index 7f5b11223c54d..9d3f46e798100 100644 --- a/llvm/include/llvm/CAS/ActionCache.h +++ b/llvm/include/llvm/CAS/ActionCache.h @@ -34,7 +34,7 @@ class CacheKey { StringRef getKey() const { return Key; } CacheKey(const CASID &ID); - CacheKey(const ObjectProxy &Proxy); + LLVM_ABI_FOR_TEST CacheKey(const ObjectProxy &Proxy); CacheKey(const ObjectStore &CAS, const ObjectRef &Ref); private: @@ -98,10 +98,10 @@ class ActionCache { }; /// Create an action cache in memory. -std::unique_ptr<ActionCache> createInMemoryActionCache(); +LLVM_ABI std::unique_ptr<ActionCache> createInMemoryActionCache(); /// Create an action cache on disk. -Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path); +LLVM_ABI Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path); } // end namespace llvm::cas diff --git a/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h b/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h index 6c165c421b168..6368fca4f7072 100644 --- a/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h +++ b/llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h @@ -18,6 +18,7 @@ class ObjectStore; /// Create on-disk \c ObjectStore and \c ActionCache instances based on /// \c ondisk::UnifiedOnDiskCache, with built-in hashing. +LLVM_ABI Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>> createOnDiskUnifiedCASDatabases(StringRef Path); diff --git a/llvm/include/llvm/CAS/CASID.h b/llvm/include/llvm/CAS/CASID.h index f508ed3b26c23..8d5a48e26a1af 100644 --- a/llvm/include/llvm/CAS/CASID.h +++ b/llvm/include/llvm/CAS/CASID.h @@ -70,7 +70,7 @@ class CASID { } /// Return a printable string for CASID. - std::string toString() const; + LLVM_ABI std::string toString() const; ArrayRef<uint8_t> getHash() const { return arrayRefFromStringRef<uint8_t>(Hash); diff --git a/llvm/include/llvm/CAS/MappedFileRegionArena.h b/llvm/include/llvm/CAS/MappedFileRegionArena.h index ff51f0eb59929..b90cb53302c39 100644 --- a/llvm/include/llvm/CAS/MappedFileRegionArena.h +++ b/llvm/include/llvm/CAS/MappedFileRegionArena.h @@ -61,7 +61,7 @@ class MappedFileRegionArena { /// that information can be stored before the header, like a file magic. /// \param NewFileConstructor is for constructing new files. It has exclusive /// access to the file. Must call \c initializeBumpPtr. - static Expected<MappedFileRegionArena> + LLVM_ABI_FOR_TEST static Expected<MappedFileRegionArena> create(const Twine &Path, uint64_t Capacity, uint64_t HeaderOffset, function_ref<Error(MappedFileRegionArena &)> NewFileConstructor); @@ -81,7 +81,7 @@ class MappedFileRegionArena { return data() + *Offset; } /// Allocate, returning the offset from \a data() instead of a pointer. - Expected<int64_t> allocateOffset(uint64_t AllocSize); + LLVM_ABI_FOR_TEST Expected<int64_t> allocateOffset(uint64_t AllocSize); char *data() const { return Region.data(); } uint64_t size() const { return H->BumpPtr; } @@ -106,7 +106,7 @@ class MappedFileRegionArena { // initialize header from offset. void initializeHeader(uint64_t HeaderOffset); - void destroyImpl(); + LLVM_ABI_FOR_TEST void destroyImpl(); void moveImpl(MappedFileRegionArena &RHS) { std::swap(Region, RHS.Region); std::swap(H, RHS.H); diff --git a/llvm/include/llvm/CAS/ObjectStore.h b/llvm/include/llvm/CAS/ObjectStore.h index 29950fe9d9029..bcf3f9214051d 100644 --- a/llvm/include/llvm/CAS/ObjectStore.h +++ b/llvm/include/llvm/CAS/ObjectStore.h @@ -179,7 +179,7 @@ class ObjectStore { public: /// Helper functions to store object and returns a ObjectProxy. - Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data); + LLVM_ABI_FOR_TEST Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data); /// Store object from StringRef. Expected<ObjectRef> storeFromString(ArrayRef<ObjectRef> Refs, @@ -205,10 +205,10 @@ class ObjectStore { static Error createUnknownObjectError(const CASID &ID); /// Create ObjectProxy from CASID. If the object doesn't exist, get an error. - Expected<ObjectProxy> getProxy(const CASID &ID); + LLVM_ABI Expected<ObjectProxy> getProxy(const CASID &ID); /// Create ObjectProxy from ObjectRef. If the object can't be loaded, get an /// error. - Expected<ObjectProxy> getProxy(ObjectRef Ref); + LLVM_ABI Expected<ObjectProxy> getProxy(ObjectRef Ref); /// \returns \c std::nullopt if the object is missing from the CAS. Expected<std::optional<ObjectProxy>> getProxyIfExists(ObjectRef Ref); @@ -329,13 +329,13 @@ class ObjectProxy { }; /// Create an in memory CAS. -std::unique_ptr<ObjectStore> createInMemoryCAS(); +LLVM_ABI std::unique_ptr<ObjectStore> createInMemoryCAS(); /// \returns true if \c LLVM_ENABLE_ONDISK_CAS configuration was enabled. bool isOnDiskCASEnabled(); /// Create a persistent on-disk path at \p Path. -Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path); +LLVM_ABI Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path); } // namespace cas } // namespace llvm diff --git a/llvm/include/llvm/CAS/OnDiskDataAllocator.h b/llvm/include/llvm/CAS/OnDiskDataAllocator.h index b7099dce2069d..5539329a1a43c 100644 --- a/llvm/include/llvm/CAS/OnDiskDataAllocator.h +++ b/llvm/include/llvm/CAS/OnDiskDataAllocator.h @@ -57,32 +57,32 @@ class OnDiskDataAllocator { /// Get the data of \p Size stored at the given \p Offset. Note the allocator /// doesn't keep track of the allocation size, thus \p Size doesn't need to /// match the size of allocation but needs to be smaller. - Expected<ArrayRef<char>> get(FileOffset Offset, size_t Size) const; + LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> get(FileOffset Offset, size_t Size) const; /// Allocate at least \p Size with 8-byte alignment. - Expected<OnDiskPtr> allocate(size_t Size); + LLVM_ABI_FOR_TEST Expected<OnDiskPtr> allocate(size_t Size); /// \returns the buffer that was allocated at \p create time, with size /// \p UserHeaderSize. MutableArrayRef<uint8_t> getUserHeader() const; - size_t size() const; - size_t capacity() const; + LLVM_ABI_FOR_TEST size_t size() const; + LLVM_ABI_FOR_TEST size_t capacity() const; - static Expected<OnDiskDataAllocator> + LLVM_ABI_FOR_TEST static Expected<OnDiskDataAllocator> create(const Twine &Path, const Twine &TableName, uint64_t MaxFileSize, std::optional<uint64_t> NewFileInitialSize, uint32_t UserHeaderSize = 0, function_ref<void(void *)> UserHeaderInit = nullptr); - OnDiskDataAllocator(OnDiskDataAllocator &&RHS); - OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS); + LLVM_ABI_FOR_TEST OnDiskDataAllocator(OnDiskDataAllocator &&RHS); + LLVM_ABI_FOR_TEST OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS); // No copy. Just call \a create() again. OnDiskDataAllocator(const OnDiskDataAllocator &) = delete; OnDiskDataAllocator &operator=(const OnDiskDataAllocator &) = delete; - ~OnDiskDataAllocator(); + LLVM_ABI_FOR_TEST ~OnDiskDataAllocator(); private: struct ImplType; diff --git a/llvm/include/llvm/CAS/OnDiskGraphDB.h b/llvm/include/llvm/CAS/OnDiskGraphDB.h index 76cc528711b69..2fa8ecf4d81e2 100644 --- a/llvm/include/llvm/CAS/OnDiskGraphDB.h +++ b/llvm/include/llvm/CAS/OnDiskGraphDB.h @@ -259,10 +259,11 @@ class OnDiskGraphDB { /// already a record for this object the operation is a no-op. \param ID the /// object ID to associate the data & references with. \param Refs references /// \param Data data buffer. - Error store(ObjectID ID, ArrayRef<ObjectID> Refs, ArrayRef<char> Data); + LLVM_ABI_FOR_TEST Error store(ObjectID ID, ArrayRef<ObjectID> Refs, + ArrayRef<char> Data); /// \returns \p nullopt if the object associated with \p Ref does not exist. - Expected<std::optional<ObjectHandle>> load(ObjectID Ref); + LLVM_ABI_FOR_TEST Expected<std::optional<ObjectHandle>> load(ObjectID Ref); /// \returns the hash bytes digest for the object reference. ArrayRef<uint8_t> getDigest(ObjectID Ref) const { @@ -272,12 +273,13 @@ class OnDiskGraphDB { /// Form a reference for the provided hash. The reference can be used as part /// of a CAS object even if it's not associated with an object yet. - Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash); + LLVM_ABI_FOR_TEST Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash); /// Get an existing reference to the object \p Digest. /// /// Returns \p nullopt if the object is not stored in this CAS. - std::optional<ObjectID> getExistingReference(ArrayRef<uint8_t> Digest); + LLVM_ABI_FOR_TEST std::optional<ObjectID> + getExistingReference(ArrayRef<uint8_t> Digest); /// Check whether the object associated with \p Ref is stored in the CAS. /// Note that this function will fault-in according to the policy. @@ -290,7 +292,7 @@ class OnDiskGraphDB { } /// \returns the data part of the provided object handle. - ArrayRef<char> getObjectData(ObjectHandle Node) const; + LLVM_ABI_FOR_TEST ArrayRef<char> getObjectData(ObjectHandle Node) const; /// \returns the object referenced by the provided object handle. object_refs_range getObjectRefs(ObjectHandle Node) const { @@ -302,7 +304,7 @@ class OnDiskGraphDB { /// /// NOTE: There's a possibility that the returned size is not including a /// large object if the process crashed right at the point of inserting it. - size_t getStorageSize() const; + LLVM_ABI_FOR_TEST size_t getStorageSize() const; /// \returns The precentage of space utilization of hard space limits. /// @@ -347,12 +349,12 @@ class OnDiskGraphDB { /// \param Policy If \p UpstreamDB is provided, controls how nodes are copied /// to primary store. This is recorded at creation time and subsequent opens /// need to pass the same policy otherwise the \p open will fail. - static Expected<std::unique_ptr<OnDiskGraphDB>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskGraphDB>> open(StringRef Path, StringRef HashName, unsigned HashByteSize, OnDiskGraphDB *UpstreamDB = nullptr, FaultInPolicy Policy = FaultInPolicy::FullTree); - ~OnDiskGraphDB(); + LLVM_ABI_FOR_TEST ~OnDiskGraphDB(); private: /// Forward declaration for a proxy for an ondisk index record. @@ -365,8 +367,8 @@ class OnDiskGraphDB { }; /// Check if object exists and if it is on upstream only. - Expected<ObjectPresence> getObjectPresence(ObjectID Ref, - bool CheckUpstream) const; + LLVM_ABI_FOR_TEST Expected<ObjectPresence> + getObjectPresence(ObjectID Ref, bool CheckUpstream) const; /// \returns true if object can be found in database. bool containsObject(ObjectID Ref, bool CheckUpstream) const { @@ -418,7 +420,8 @@ class OnDiskGraphDB { static InternalRef makeInternalRef(FileOffset IndexOffset); - Expected<ArrayRef<uint8_t>> getDigest(InternalRef Ref) const; + LLVM_ABI_FOR_TEST Expected<ArrayRef<uint8_t>> + getDigest(InternalRef Ref) const; ArrayRef<uint8_t> getDigest(const IndexProxy &I) const; @@ -427,7 +430,8 @@ class OnDiskGraphDB { IndexProxy getIndexProxyFromPointer(OnDiskTrieRawHashMap::ConstOnDiskPtr P) const; - InternalRefArrayRef getInternalRefs(ObjectHandle Node) const; + LLVM_ABI_FOR_TEST InternalRefArrayRef + getInternalRefs(ObjectHandle Node) const; /// \} /// Get the atomic variable that keeps track of the standalone data storage diff --git a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h index 17ae52f0307fc..b19b6db847d5f 100644 --- a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h +++ b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h @@ -36,11 +36,13 @@ class OnDiskKeyValueDB { /// /// \returns the value associated with the \p Key. It may be different than /// \p Value if another value is already associated with this key. - Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key, ArrayRef<char> Value); + LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key, + ArrayRef<char> Value); /// \returns the value associated with the \p Key, or \p std::nullopt if the /// key does not exist. - Expected<std::optional<ArrayRef<char>>> get(ArrayRef<uint8_t> Key); + LLVM_ABI_FOR_TEST Expected<std::optional<ArrayRef<char>>> + get(ArrayRef<uint8_t> Key); /// \returns Total size of stored data. size_t getStorageSize() const { return Cache.size(); } @@ -64,7 +66,7 @@ class OnDiskKeyValueDB { /// \param UnifiedCache An optional UnifiedOnDiskCache that manages the size /// and lifetime of the CAS instance and it must owns current initializing /// KeyValueDB after initialized. - static Expected<std::unique_ptr<OnDiskKeyValueDB>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskKeyValueDB>> open(StringRef Path, StringRef HashName, unsigned KeySize, StringRef ValueName, size_t ValueSize, UnifiedOnDiskCache *UnifiedCache = nullptr); @@ -73,7 +75,7 @@ class OnDiskKeyValueDB { function_ref<Error(FileOffset Offset, ArrayRef<char> Data)>; /// Validate the storage with a callback \p CheckValue to check the stored /// value. - Error validate(CheckValueT CheckValue) const; + LLVM_ABI_FOR_TEST Error validate(CheckValueT CheckValue) const; private: OnDiskKeyValueDB(size_t ValueSize, OnDiskTrieRawHashMap Cache, diff --git a/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h b/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h index fbd68d0f2f53e..819058d2ae9af 100644 --- a/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h +++ b/llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h @@ -83,7 +83,7 @@ class OnDiskTrieRawHashMap { /// Validate the trie data structure. /// /// Callback receives the file offset to the data entry and the data stored. - Error validate( + LLVM_ABI_FOR_TEST Error validate( function_ref<Error(FileOffset, ConstValueProxy)> RecordVerifier) const; /// Check the valid range of file offset for OnDiskTrieRawHashMap. @@ -161,10 +161,11 @@ class OnDiskTrieRawHashMap { /// /// \returns pointer to the value if exists, otherwise returns a non-value /// pointer that evaluates to `false` when convert to boolean. - ConstOnDiskPtr find(ArrayRef<uint8_t> Hash) const; + LLVM_ABI_FOR_TEST ConstOnDiskPtr find(ArrayRef<uint8_t> Hash) const; /// Helper function to recover a pointer into the trie from file offset. - Expected<ConstOnDiskPtr> recoverFromFileOffset(FileOffset Offset) const; + LLVM_ABI_FOR_TEST Expected<ConstOnDiskPtr> + recoverFromFileOffset(FileOffset Offset) const; using LazyInsertOnConstructCB = function_ref<void(FileOffset TentativeOffset, ValueProxy TentativeValue)>; @@ -186,9 +187,10 @@ class OnDiskTrieRawHashMap { /// The in-memory \a TrieRawHashMap uses LazyAtomicPointer to synchronize /// simultaneous writes, but that seems dangerous to use in a memory-mapped /// file in case a process crashes in the busy state. - Expected<OnDiskPtr> insertLazy(ArrayRef<uint8_t> Hash, - LazyInsertOnConstructCB OnConstruct = nullptr, - LazyInsertOnLeakCB OnLeak = nullptr); + LLVM_ABI_FOR_TEST Expected<OnDiskPtr> + insertLazy(ArrayRef<uint8_t> Hash, + LazyInsertOnConstructCB OnConstruct = nullptr, + LazyInsertOnLeakCB OnLeak = nullptr); Expected<OnDiskPtr> insert(const ConstValueProxy &Value) { return insertLazy(Value.Hash, [&](FileOffset, ValueProxy Allocated) { @@ -198,8 +200,8 @@ class OnDiskTrieRawHashMap { }); } - size_t size() const; - size_t capacity() const; + LLVM_ABI_FOR_TEST size_t size() const; + LLVM_ABI_FOR_TEST size_t capacity() const; /// Gets or creates a file at \p Path with a hash-mapped trie named \p /// TrieName. The hash size is \p NumHashBits (in bits) and the records store @@ -213,16 +215,16 @@ class OnDiskTrieRawHashMap { /// configure the trie, if it doesn't already exist. /// /// \pre NumHashBits is a multiple of 8 (byte-aligned). - static Expected<OnDiskTrieRawHashMap> + LLVM_ABI_FOR_TEST static Expected<OnDiskTrieRawHashMap> create(const Twine &Path, const Twine &TrieName, size_t NumHashBits, uint64_t DataSize, uint64_t MaxFileSize, std::optional<uint64_t> NewFileInitialSize, std::optional<size_t> NewTableNumRootBits = std::nullopt, std::optional<size_t> NewTableNumSubtrieBits = std::nullopt); - OnDiskTrieRawHashMap(OnDiskTrieRawHashMap &&RHS); - OnDiskTrieRawHashMap &operator=(OnDiskTrieRawHashMap &&RHS); - ~OnDiskTrieRawHashMap(); + LLVM_ABI_FOR_TEST OnDiskTrieRawHashMap(OnDiskTrieRawHashMap &&RHS); + LLVM_ABI_FOR_TEST OnDiskTrieRawHashMap &operator=(OnDiskTrieRawHashMap &&RHS); + LLVM_ABI_FOR_TEST ~OnDiskTrieRawHashMap(); private: struct ImplType; diff --git a/llvm/include/llvm/CAS/UnifiedOnDiskCache.h b/llvm/include/llvm/CAS/UnifiedOnDiskCache.h index 6e0878a65fe72..bb3d7f72e5679 100644 --- a/llvm/include/llvm/CAS/UnifiedOnDiskCache.h +++ b/llvm/include/llvm/CAS/UnifiedOnDiskCache.h @@ -58,7 +58,7 @@ class UnifiedOnDiskCache { /// \param FaultInPolicy Controls how nodes are copied to primary store. This /// is recorded at creation time and subsequent opens need to pass the same /// policy otherwise the \p open will fail. - static Expected<std::unique_ptr<UnifiedOnDiskCache>> + LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<... [truncated] 
@github-actions
Copy link

github-actions bot commented Nov 12, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

This patch updates various LLVM headers to properly add the `LLVM_ABI` and `LLVM_ABI_FOR_TEST` annotations to build LLVM as a DLL on Windows. This effort is tracked in llvm#109483.
@Steelskin Steelskin force-pushed the fabrice/llvm-dll-abi-annotations2 branch from 9c73af6 to 281bad0 Compare November 12, 2025 18:01
@compnerd compnerd merged commit 23f6a8a into llvm:main Nov 13, 2025
10 checks passed
@Steelskin Steelskin deleted the fabrice/llvm-dll-abi-annotations2 branch November 13, 2025 18:01
Steelskin added a commit to Steelskin/llvm-project that referenced this pull request Nov 18, 2025
This patch updates various LLVM headers to properly add the `LLVM_ABI` and `LLVM_ABI_FOR_TEST` annotations to build LLVM as a DLL on Windows. This effort is tracked in swiftlang/swift#85241.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment