Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/ADT/APFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/IR2Vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions llvm/include/llvm/AsmParser/AsmParserContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ 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.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/BinaryFormat/DXContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
7 changes: 4 additions & 3 deletions llvm/include/llvm/CAS/ActionCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -98,10 +98,11 @@ 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

Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/CAS/CASID.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/CAS/MappedFileRegionArena.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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; }
Expand All @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions llvm/include/llvm/CAS/ObjectStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ 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,
Expand All @@ -205,10 +206,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);
Expand Down Expand Up @@ -329,13 +330,14 @@ 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
Expand Down
17 changes: 9 additions & 8 deletions llvm/include/llvm/CAS/OnDiskDataAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,33 @@ 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;
Expand Down
28 changes: 16 additions & 12 deletions llvm/include/llvm/CAS/OnDiskGraphDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand All @@ -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 {
Expand All @@ -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.
///
Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions llvm/include/llvm/CAS/OnDiskKeyValueDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand All @@ -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);
Expand All @@ -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,
Expand Down
26 changes: 14 additions & 12 deletions llvm/include/llvm/CAS/OnDiskTrieRawHashMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)>;
Expand All @@ -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) {
Expand All @@ -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
Expand All @@ -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;
Expand Down
Loading
Loading