Skip to content
Open
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
10 changes: 5 additions & 5 deletions llvm/include/llvm/CAS/ActionCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class ActionCache {
}

/// Asynchronous version of \c get.
std::future<AsyncCASIDValue> getFuture(const CacheKey &ActionKey,
bool Globally = false) const;
LLVM_ABI std::future<AsyncCASIDValue> getFuture(const CacheKey &ActionKey,
bool Globally = false) const;

/// Asynchronous version of \c get.
void getAsync(const CacheKey &ActionKey, bool Globally,
Expand All @@ -97,9 +97,9 @@ class ActionCache {
}

/// Asynchronous version of \c put.
std::future<AsyncErrorValue> putFuture(const CacheKey &ActionKey,
const CASID &Result,
bool Globally = false);
LLVM_ABI std::future<AsyncErrorValue> putFuture(const CacheKey &ActionKey,
const CASID &Result,
bool Globally = false);

/// Asynchronous version of \c put.
/// \param[out] CancelObj Optional pointer to receive a cancellation object.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/CAS/BuiltinObjectHasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ template <class HasherT> class BuiltinObjectHasher {
return H.finish();
}

static Expected<HashT> hashFile(StringRef FilePath);
LLVM_ABI static Expected<HashT> hashFile(StringRef FilePath);

private:
HashT finish() { return Hasher.final(); }
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/CAS/CASConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CASConfiguration {
}

// Get resolved CASPath.
void getResolvedCASPath(llvm::SmallVectorImpl<char> &Result) const;
LLVM_ABI void getResolvedCASPath(llvm::SmallVectorImpl<char> &Result) const;

// Create CASDatabase from the CASConfiguration.
LLVM_ABI
Expand All @@ -61,10 +61,10 @@ class CASConfiguration {
createDatabases() const;

/// Write CAS configuration file.
void writeConfigurationFile(raw_ostream &OS) const;
LLVM_ABI void writeConfigurationFile(raw_ostream &OS) const;

/// Create CASConfiguration from config file content.
static llvm::Expected<CASConfiguration>
LLVM_ABI static llvm::Expected<CASConfiguration>
createFromConfig(llvm::StringRef Content);

/// Create CASConfiguration from recurively search config file from a path.
Expand Down
12 changes: 6 additions & 6 deletions llvm/include/llvm/CAS/CASFSBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ class CachingOnDiskFileSystem;
class CASFSBuilder {
public:
/// \param Prefix maps used for file system ingestion.
explicit CASFSBuilder(ObjectStore &DB,
ArrayRef<MappedPrefix> PrefixMaps = {});
LLVM_ABI explicit CASFSBuilder(ObjectStore &DB,
ArrayRef<MappedPrefix> PrefixMaps = {});

~CASFSBuilder();
LLVM_ABI ~CASFSBuilder();

/// Ingest contents from the on-disk file-system. Symlinks are not followed.
/// Emits an error if the path doesn't exist.
///
/// \param Recursive if true, and path is a directory, its contents will be
/// ingested recursively, otherwise only the path will be included.
Error ingestFileSystemPath(const Twine &Path, bool Recursive = true);
LLVM_ABI Error ingestFileSystemPath(const Twine &Path, bool Recursive = true);

/// Merge a prior constructed CAS file-system tree root.
///
/// \param Path the path to place the root at; can be empty.
void mergeCASFSRoot(ObjectRef Root, const Twine &Path = "");
LLVM_ABI void mergeCASFSRoot(ObjectRef Root, const Twine &Path = "");

/// Produce the merged CAS file-system tree root. \c CASFSBuilder should not
/// be used after calling this.
Expected<ObjectProxy> finish();
LLVM_ABI Expected<ObjectProxy> finish();

private:
ObjectStore &DB;
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/CAS/CASFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class CASBackedFileSystem
/// open the file twice.
/// The IsText parameter is used to distinguish whether the file should be
/// opened as a binary or text file.
llvm::Expected<std::pair<std::unique_ptr<llvm::MemoryBuffer>, cas::ObjectRef>>
LLVM_ABI llvm::Expected<
std::pair<std::unique_ptr<llvm::MemoryBuffer>, cas::ObjectRef>>
getBufferAndObjectRefForFile(const Twine &Name, int64_t FileSize = -1,
bool RequiresNullTerminator = true,
bool IsVolatile = false, bool IsText = true);
Expand Down
18 changes: 9 additions & 9 deletions llvm/include/llvm/CAS/HashMappedTrie.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ThreadSafeHashMappedTrieBase {
static constexpr size_t DefaultNumSubtrieBits = 4;

LLVM_DUMP_METHOD void dump() const;
void print(raw_ostream &OS) const;
LLVM_ABI void print(raw_ostream &OS) const;

protected:
/// Result of a lookup. Suitable for an insertion hint. Maybe could be
Expand Down Expand Up @@ -82,27 +82,27 @@ class ThreadSafeHashMappedTrieBase {
unsigned B = 0;
};

PointerBase find(ArrayRef<uint8_t> Hash) const;
LLVM_ABI PointerBase find(ArrayRef<uint8_t> Hash) const;

/// Insert and return the stored content.
PointerBase
LLVM_ABI PointerBase
insert(PointerBase Hint, ArrayRef<uint8_t> Hash,
function_ref<const uint8_t *(void *Mem, ArrayRef<uint8_t> Hash)>
Constructor);

ThreadSafeHashMappedTrieBase() = delete;

ThreadSafeHashMappedTrieBase(size_t ContentAllocSize,
size_t ContentAllocAlign, size_t ContentOffset,
std::optional<size_t> NumRootBits = std::nullopt,
std::optional<size_t> NumSubtrieBits = std::nullopt);
LLVM_ABI ThreadSafeHashMappedTrieBase(
size_t ContentAllocSize, size_t ContentAllocAlign, size_t ContentOffset,
std::optional<size_t> NumRootBits = std::nullopt,
std::optional<size_t> NumSubtrieBits = std::nullopt);

/// Destructor, which asserts if there's anything to do. Subclasses should
/// call \a destroyImpl().
///
/// \pre \a destroyImpl() was already called.
~ThreadSafeHashMappedTrieBase();
void destroyImpl(function_ref<void (void *ValueMem)> Destructor);
LLVM_ABI ~ThreadSafeHashMappedTrieBase();
LLVM_ABI void destroyImpl(function_ref<void (void *ValueMem)> Destructor);

ThreadSafeHashMappedTrieBase(ThreadSafeHashMappedTrieBase &&RHS);

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/CAS/HierarchicalTreeBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class HierarchicalTreeBuilder {
/// * Calling push() for every non-tree
///
/// Allows merging the contents of multiple directories.
void pushTreeContent(ObjectRef Ref, const Twine &Path);
LLVM_ABI void pushTreeContent(ObjectRef Ref, const Twine &Path);

/// Drop all entries.
void clear() { Entries.clear(); }
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/CAS/ObjectStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ std::string getDefaultOnDiskCASStableID();
/// on-disk directory that the plugin should use, otherwise the default
/// OnDiskCAS location will be used.
/// FIXME: Need to implement proper URL encoding scheme that allows "%".
Expected<std::shared_ptr<ObjectStore>> createCASFromIdentifier(StringRef Path);
LLVM_ABI Expected<std::shared_ptr<ObjectStore>>
createCASFromIdentifier(StringRef Path);

/// Register a URL scheme to CAS Identifier.
using ObjectStoreCreateFuncTy =
Expand Down
56 changes: 31 additions & 25 deletions llvm/include/llvm/CAS/OnDiskCASLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,46 +30,52 @@ class OnDiskCASLogger {
/// \param Path The parent directory of the log file.
/// \param LogAllocations Whether to log all low-level allocations. This is
/// on the order of twice as expensive to log.
static Expected<std::unique_ptr<OnDiskCASLogger>> open(const Twine &Path,
bool LogAllocations);
LLVM_ABI static Expected<std::unique_ptr<OnDiskCASLogger>>
open(const Twine &Path, bool LogAllocations);

/// Create or append to a log file inside the given CAS directory \p Path if
/// logging is enabled by the environment variable \c LLVM_CAS_LOG. If
/// LLVM_CAS_LOG is set >= 2 then also log allocations.
static Expected<std::unique_ptr<OnDiskCASLogger>>
openIfEnabled(const Twine &Path);

~OnDiskCASLogger();
LLVM_ABI ~OnDiskCASLogger();

/// An offset into an \c OnDiskHashMappedTrie.
using TrieOffset = int64_t;

void log_compare_exchange_strong(void *Region, TrieOffset Trie, size_t SlotI,
TrieOffset Expected, TrieOffset New,
TrieOffset Previous);
void log_SubtrieHandle_create(void *Region, TrieOffset Trie,
uint32_t StartBit, uint32_t NumBits);
void log_HashMappedTrieHandle_createRecord(void *Region,
TrieOffset TrieOffset,
ArrayRef<uint8_t> Hash);
void log_MappedFileRegionBumpPtr_resizeFile(StringRef Path, size_t Before,
size_t After);
void log_MappedFileRegionBumpPtr_create(StringRef Path, int FD, void *Region,
size_t Capacity, size_t Size);
void log_MappedFileRegionBumpPtr_oom(StringRef Path, size_t Capacity,
size_t Size, size_t AllocSize);
void log_MappedFileRegionBumpPtr_close(StringRef Path);
void log_MappedFileRegionBumpPtr_allocate(void *Region, TrieOffset Off,
size_t Size);
void log_UnifiedOnDiskCache_collectGarbage(StringRef Path);
void log_UnifiedOnDiskCache_validateIfNeeded(
LLVM_ABI void log_compare_exchange_strong(void *Region, TrieOffset Trie,
size_t SlotI, TrieOffset Expected,
TrieOffset New,
TrieOffset Previous);
LLVM_ABI void log_SubtrieHandle_create(void *Region, TrieOffset Trie,
uint32_t StartBit, uint32_t NumBits);
LLVM_ABI void log_HashMappedTrieHandle_createRecord(void *Region,
TrieOffset TrieOffset,
ArrayRef<uint8_t> Hash);
LLVM_ABI void log_MappedFileRegionBumpPtr_resizeFile(StringRef Path,
size_t Before,
size_t After);
LLVM_ABI void log_MappedFileRegionBumpPtr_create(StringRef Path, int FD,
void *Region,
size_t Capacity,
size_t Size);
LLVM_ABI void log_MappedFileRegionBumpPtr_oom(StringRef Path, size_t Capacity,
size_t Size, size_t AllocSize);
LLVM_ABI void log_MappedFileRegionBumpPtr_close(StringRef Path);
LLVM_ABI void log_MappedFileRegionBumpPtr_allocate(void *Region,
TrieOffset Off,
size_t Size);
LLVM_ABI void log_UnifiedOnDiskCache_collectGarbage(StringRef Path);
LLVM_ABI void log_UnifiedOnDiskCache_validateIfNeeded(
StringRef Path, uint64_t BootTime, uint64_t ValidationTime,
bool CheckHash, bool AllowRecovery, bool Force,
std::optional<StringRef> LLVMCas, StringRef ValidationError, bool Skipped,
bool Recovered);
void log_TempFile_create(StringRef Name);
void log_TempFile_keep(StringRef TmpName, StringRef Name, std::error_code EC);
void log_TempFile_remove(StringRef TmpName, std::error_code EC);
LLVM_ABI void log_TempFile_create(StringRef Name);
LLVM_ABI void log_TempFile_keep(StringRef TmpName, StringRef Name,
std::error_code EC);
LLVM_ABI void log_TempFile_remove(StringRef TmpName, std::error_code EC);

private:
OnDiskCASLogger(raw_fd_ostream &OS, bool LogAllocations);
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/CAS/OnDiskGraphDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ class OnDiskGraphDB {
/// loading the data in memory and then writing it to a file, the client could
/// clone the underlying file directly. The client *must not* write to or
/// delete the underlying file, the path is provided only for reading/copying.
FileBackedData getInternalFileBackedObjectData(ObjectHandle Node) const;
LLVM_ABI_FOR_TEST FileBackedData
getInternalFileBackedObjectData(ObjectHandle Node) const;

/// \returns Total size of stored objects.
///
Expand Down
21 changes: 11 additions & 10 deletions llvm/include/llvm/CAS/OnDiskHashMappedTrie.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class OnDiskHashMappedTrie {
return pointer(CP.getOffset(), V);
}

const_pointer find(ArrayRef<uint8_t> Hash) const;
LLVM_ABI const_pointer find(ArrayRef<uint8_t> Hash) const;
pointer find(ArrayRef<uint8_t> Hash) {
return getMutablePointer(
const_cast<const OnDiskHashMappedTrie *>(this)->find(Hash));
Expand All @@ -194,7 +194,7 @@ class OnDiskHashMappedTrie {
HashBegin));
}

const_pointer recoverFromFileOffset(FileOffset Offset) const;
LLVM_ABI const_pointer recoverFromFileOffset(FileOffset Offset) const;
pointer recoverFromFileOffset(FileOffset Offset) {
return getMutablePointer(
const_cast<const OnDiskHashMappedTrie *>(this)->recoverFromFileOffset(
Expand All @@ -221,9 +221,10 @@ class OnDiskHashMappedTrie {
/// The in-memory \a HashMappedTrie 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<pointer> insertLazy(ArrayRef<uint8_t> Hash,
LazyInsertOnConstructCB OnConstruct = nullptr,
LazyInsertOnLeakCB OnLeak = nullptr);
LLVM_ABI Expected<pointer>
insertLazy(ArrayRef<uint8_t> Hash,
LazyInsertOnConstructCB OnConstruct = nullptr,
LazyInsertOnLeakCB OnLeak = nullptr);

Expected<pointer> insert(const ConstValueProxy &Value) {
return insertLazy(Value.Hash, [&](FileOffset, ValueProxy Allocated) {
Expand Down Expand Up @@ -253,17 +254,17 @@ class OnDiskHashMappedTrie {
/// adding more tables to a single file.
///
/// FIXME: Rename to getOrCreate().
static Expected<OnDiskHashMappedTrie>
LLVM_ABI static Expected<OnDiskHashMappedTrie>
create(const Twine &Path, const Twine &TrieName, size_t NumHashBits,
uint64_t DataSize, uint64_t MaxFileSize,
std::optional<uint64_t> NewFileInitialSize,
std::shared_ptr<ondisk::OnDiskCASLogger> Logger = nullptr,
std::optional<size_t> NewTableNumRootBits = std::nullopt,
std::optional<size_t> NewTableNumSubtrieBits = std::nullopt);

OnDiskHashMappedTrie(OnDiskHashMappedTrie &&RHS);
OnDiskHashMappedTrie &operator=(OnDiskHashMappedTrie &&RHS);
~OnDiskHashMappedTrie();
LLVM_ABI OnDiskHashMappedTrie(OnDiskHashMappedTrie &&RHS);
LLVM_ABI OnDiskHashMappedTrie &operator=(OnDiskHashMappedTrie &&RHS);
LLVM_ABI ~OnDiskHashMappedTrie();

private:
struct ImplType;
Expand Down Expand Up @@ -329,7 +330,7 @@ class OnDiskDataAllocator {
size_t size() const;
size_t capacity() const;

static Expected<OnDiskDataAllocator>
LLVM_ABI static Expected<OnDiskDataAllocator>
create(const Twine &Path, const Twine &TableName, uint64_t MaxFileSize,
std::optional<uint64_t> NewFileInitialSize,
uint32_t UserHeaderSize = 0,
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/CAS/TreeSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class TreeSchema : public RTTIExtends<TreeSchema, NodeSchema> {

class TreeProxy : public ObjectProxy {
public:
static Expected<TreeProxy> get(const TreeSchema &Schema,
Expected<ObjectProxy> Ref);
LLVM_ABI static Expected<TreeProxy> get(const TreeSchema &Schema,
Expected<ObjectProxy> Ref);

static Expected<TreeProxy> create(TreeSchema &Schema,
ArrayRef<NamedTreeEntry> Entries);
Expand Down
12 changes: 6 additions & 6 deletions llvm/include/llvm/CAS/UnifiedOnDiskCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class UnifiedOnDiskCache {
///
/// \returns the \p ObjectID associated with the \p Key. It may be different
/// than \p Value if another value was already associated with this key.
Expected<ObjectID> KVPut(ArrayRef<uint8_t> Key, ObjectID Value);
LLVM_ABI Expected<ObjectID> KVPut(ArrayRef<uint8_t> Key, ObjectID Value);

/// Associate an \p ObjectID, of the \p OnDiskGraphDB instance, with a key.
/// An \p ObjectID as a key is equivalent to its digest bytes.
Expand All @@ -62,11 +62,11 @@ class UnifiedOnDiskCache {
///
/// \returns the \p ObjectID associated with the \p Key. It may be different
/// than \p Value if another value was already associated with this key.
Expected<ObjectID> KVPut(ObjectID Key, ObjectID Value);
LLVM_ABI Expected<ObjectID> KVPut(ObjectID Key, ObjectID Value);

/// \returns the \p ObjectID, of the \p OnDiskGraphDB instance, associated
/// with the \p Key, or \p std::nullopt if the key does not exist.
Expected<std::optional<ObjectID>> KVGet(ArrayRef<uint8_t> Key);
LLVM_ABI Expected<std::optional<ObjectID>> KVGet(ArrayRef<uint8_t> Key);

/// Open a \p UnifiedOnDiskCache instance for a directory.
///
Expand Down Expand Up @@ -109,7 +109,7 @@ class UnifiedOnDiskCache {
/// was invalid but has been cleared, \c Skipped if validation is not needed,
/// or an \c Error if validation cannot be performed or if the data is left
/// in an invalid state because \p AllowRecovery is false.
static Expected<ValidationResult>
LLVM_ABI_FOR_TEST static Expected<ValidationResult>
validateIfNeeded(StringRef Path, StringRef HashName, unsigned HashByteSize,
bool CheckHash, OnDiskGraphDB::HashingFuncT HashFn,
bool AllowRecovery, bool ForceValidation,
Expand Down Expand Up @@ -153,11 +153,11 @@ class UnifiedOnDiskCache {
LLVM_ABI_FOR_TEST static Error
collectGarbage(StringRef Path, ondisk::OnDiskCASLogger *Logger = nullptr);

Error collectGarbage();
LLVM_ABI_FOR_TEST Error collectGarbage();

LLVM_ABI_FOR_TEST ~UnifiedOnDiskCache();

Error validateActionCache();
LLVM_ABI_FOR_TEST Error validateActionCache();

OnDiskGraphDB *getUpstreamGraphDB() const { return UpstreamGraphDB; }

Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/CASUtil/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace cas {
class ObjectStore;
class CASID;

Expected<CASID> readCASIDBuffer(cas::ObjectStore &CAS,
llvm::MemoryBufferRef Buffer);
LLVM_ABI Expected<CASID> readCASIDBuffer(cas::ObjectStore &CAS,
llvm::MemoryBufferRef Buffer);

LLVM_ABI void writeCASIDBuffer(const CASID &ID, llvm::raw_ostream &OS);

Expand All @@ -33,7 +33,7 @@ LLVM_ABI void writeCASIDBuffer(const CASID &ID, llvm::raw_ostream &OS);
/// * Null-terminated hash schema name, e.g. llvm.builtin.v2[BLAKE3]
/// * Hash length (4 bytes little-endian, e.g. 32)
/// * Hash bytes
Error writeCASHashXAttr(const CASID &ID, const llvm::Twine &Path);
LLVM_ABI Error writeCASHashXAttr(const CASID &ID, const llvm::Twine &Path);

} // namespace cas

Expand Down
Loading