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
8 changes: 5 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 {
// which then `getOrCompute` method can be used to avoid multiple calls to
// has function.
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 @@ -142,14 +142,16 @@ class ActionCache {
};

/// Create an action cache in memory.
std::unique_ptr<ActionCache> createInMemoryActionCache();
LLVM_ABI std::unique_ptr<ActionCache> createInMemoryActionCache();

/// Get a reasonable default on-disk path for a persistent ActionCache for the
/// current user.
std::string getDefaultOnDiskActionCachePath();

/// 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

#endif // LLVM_CAS_CASACTIONCACHE_H
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 @@ -67,7 +67,7 @@ class CASID {
ID.print(OS);
return OS;
}
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/MappedFileRegionBumpPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MappedFileRegionBumpPtr {
/// \param BumpPtrOffset the offset at which to store the bump pointer.
/// \param NewFileConstructor is for constructing new files. It has exclusive
/// access to the file. Must call \c initializeBumpPtr.
static Expected<MappedFileRegionBumpPtr>
LLVM_ABI_FOR_TEST static Expected<MappedFileRegionBumpPtr>
create(const Twine &Path, uint64_t Capacity, int64_t BumpPtrOffset,
std::shared_ptr<ondisk::OnDiskCASLogger> Logger,
function_ref<Error(MappedFileRegionBumpPtr &)> NewFileConstructor);
Expand All @@ -75,7 +75,7 @@ class MappedFileRegionBumpPtr {
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 @@ -97,7 +97,7 @@ class MappedFileRegionBumpPtr {
MappedFileRegionBumpPtr &operator=(const MappedFileRegionBumpPtr &) = delete;

private:
void destroyImpl();
LLVM_ABI_FOR_TEST void destroyImpl();
void moveImpl(MappedFileRegionBumpPtr &RHS) {
std::swap(Region, RHS.Region);
std::swap(H, RHS.H);
Expand Down
13 changes: 8 additions & 5 deletions llvm/include/llvm/CAS/ObjectStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,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 @@ -251,10 +252,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 @@ -394,7 +395,8 @@ class ObjectProxy {
ObjectHandle H;
};

std::unique_ptr<ObjectStore> createInMemoryCAS();
/// Create an in memory CAS.
LLVM_ABI std::unique_ptr<ObjectStore> createInMemoryCAS();

/// \returns true if \c LLVM_ENABLE_ONDISK_CAS configuration was enabled.
bool isOnDiskCASEnabled();
Expand All @@ -406,7 +408,8 @@ bool isOnDiskCASEnabled();
///
/// FIXME: Remove the special behaviour for getDefaultOnDiskCASStableID(). The
/// client should handle this logic, if/when desired.
Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path);
LLVM_ABI Expected<std::unique_ptr<ObjectStore>>
createOnDiskCAS(const Twine &Path);

/// Set \p Path to a reasonable default on-disk path for a persistent CAS for
/// the current user.
Expand Down
29 changes: 18 additions & 11 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 @@ -271,12 +272,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 @@ -289,7 +291,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;

object_refs_range getObjectRefs(ObjectHandle Node) const {
InternalRefArrayRef Refs = getInternalRefs(Node);
Expand All @@ -300,7 +302,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 @@ -335,13 +337,13 @@ 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,
std::unique_ptr<OnDiskGraphDB> UpstreamDB = nullptr,
std::shared_ptr<OnDiskCASLogger> Logger = nullptr,
FaultInPolicy Policy = FaultInPolicy::FullTree);

~OnDiskGraphDB();
LLVM_ABI_FOR_TEST ~OnDiskGraphDB();

private:
struct IndexProxy;
Expand All @@ -354,7 +356,9 @@ class OnDiskGraphDB {
OnlyInUpstreamDB,
};

ObjectPresence getObjectPresence(ObjectID Ref, bool CheckUpstream) const;
/// Check if object exists and if it is on upstream only.
LLVM_ABI_FOR_TEST ObjectPresence
getObjectPresence(ObjectID Ref, bool CheckUpstream) const;

bool containsObject(ObjectID Ref, bool CheckUpstream) const {
switch (getObjectPresence(Ref, CheckUpstream)) {
Expand Down Expand Up @@ -393,7 +397,9 @@ class OnDiskGraphDB {
void getStandalonePath(StringRef FileSuffix, const IndexProxy &I,
SmallVectorImpl<char> &Path) const;

ArrayRef<uint8_t> getDigest(InternalRef Ref) const;
LLVM_ABI_FOR_TEST ArrayRef<uint8_t>
getDigest(InternalRef Ref) const;

ArrayRef<uint8_t> getDigest(const IndexProxy &I) const;

IndexProxy getIndexProxyFromRef(InternalRef Ref) const;
Expand All @@ -403,7 +409,8 @@ class OnDiskGraphDB {
IndexProxy
getIndexProxyFromPointer(OnDiskHashMappedTrie::const_pointer P) const;

InternalRefArrayRef getInternalRefs(ObjectHandle Node) const;
LLVM_ABI_FOR_TEST InternalRefArrayRef
getInternalRefs(ObjectHandle Node) const;

void recordStandaloneSizeIncrease(size_t SizeIncrease);

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 @@ -28,11 +28,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 {
Expand All @@ -55,13 +57,13 @@ class OnDiskKeyValueDB {
/// \param KeySize Size for the key hash bytes.
/// \param ValueName Identifier name for the values.
/// \param ValueSize Size for the value bytes.
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,
std::shared_ptr<OnDiskCASLogger> Logger = nullptr);

using CheckValueT = function_ref<Error(FileOffset Offset, ArrayRef<char>)>;
Error validate(CheckValueT CheckValue) const;
LLVM_ABI_FOR_TEST Error validate(CheckValueT CheckValue) const;

private:
OnDiskKeyValueDB(size_t ValueSize, OnDiskHashMappedTrie Cache)
Expand Down
16 changes: 8 additions & 8 deletions llvm/include/llvm/CAS/UnifiedOnDiskCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,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<UnifiedOnDiskCache>>
open(StringRef Path, std::optional<uint64_t> SizeLimit, StringRef HashName,
unsigned HashByteSize,
OnDiskGraphDB::FaultInPolicy FaultInPolicy =
Expand Down Expand Up @@ -118,20 +118,20 @@ class UnifiedOnDiskCache {
/// \param CheckSizeLimit if true it will check whether the primary store has
/// exceeded its intended size limit. If false the check is skipped even if a
/// \p SizeLimit was passed to the \p open call.
Error close(bool CheckSizeLimit = true);
LLVM_ABI_FOR_TEST Error close(bool CheckSizeLimit = true);

/// Set the size for limiting growth. This has an effect for when the instance
/// is closed.
void setSizeLimit(std::optional<uint64_t> SizeLimit);
LLVM_ABI_FOR_TEST void setSizeLimit(std::optional<uint64_t> SizeLimit);

/// \returns the storage size of the cache data.
uint64_t getStorageSize() const;
LLVM_ABI_FOR_TEST uint64_t getStorageSize() const;

/// \returns whether the primary store has exceeded the intended size limit.
/// This can return false even if the overall size of the opened directory is
/// over the \p SizeLimit passed to \p open. To know whether garbage
/// collection needs to be triggered or not, call \p needsGarbaseCollection.
bool hasExceededSizeLimit() const;
LLVM_ABI_FOR_TEST bool hasExceededSizeLimit() const;

/// \returns whether there are unused data that can be deleted using a
/// \p collectGarbage call.
Expand All @@ -146,12 +146,12 @@ class UnifiedOnDiskCache {
///
/// It is recommended that garbage-collection is triggered concurrently in the
/// background, so that it has minimal effect on the workload of the process.
static Error collectGarbage(StringRef Path,
ondisk::OnDiskCASLogger *Logger = nullptr);
LLVM_ABI_FOR_TEST static Error
collectGarbage(StringRef Path, ondisk::OnDiskCASLogger *Logger = nullptr);

Error collectGarbage();

~UnifiedOnDiskCache();
LLVM_ABI_FOR_TEST ~UnifiedOnDiskCache();

Error validateActionCache();

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/BasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
/// instructions, so the order should be validated no more than once after
/// each ordering to ensure that transforms have the same algorithmic
/// complexity when asserts are enabled as when they are disabled.
void validateInstrOrdering() const;
LLVM_ABI_FOR_TEST void validateInstrOrdering() const;
};

// Create wrappers for C Binding types (see CBindingWrapping.h).
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/SandboxIR/Argument.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Argument : public sandboxir::Value {
assert(isa<llvm::Argument>(Val) && "Expected Argument!");
}
void printAsOperand(raw_ostream &OS) const;
void dumpOS(raw_ostream &OS) const final;
LLVM_ABI_FOR_TEST void dumpOS(raw_ostream &OS) const final;
#endif
};

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/SandboxIR/BasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class BasicBlock : public Value {

#ifndef NDEBUG
void verify() const final;
void dumpOS(raw_ostream &OS) const final;
LLVM_ABI_FOR_TEST void dumpOS(raw_ostream &OS) const final;
#endif
};

Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/SandboxIR/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class Function : public GlobalWithNodeAPI<Function, llvm::Function,
void verify() const final {
assert(isa<llvm::Function>(Val) && "Expected Function!");
}
void dumpNameAndArgs(raw_ostream &OS) const;
void dumpOS(raw_ostream &OS) const final;
LLVM_ABI_FOR_TEST void dumpNameAndArgs(raw_ostream &OS) const;
LLVM_ABI_FOR_TEST void dumpOS(raw_ostream &OS) const final;
#endif
};

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/SandboxIR/Pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Pass {
return OS;
}
virtual void print(raw_ostream &OS) const { OS << Name; }
LLVM_DUMP_METHOD virtual void dump() const;
LLVM_ABI_FOR_TEST LLVM_DUMP_METHOD virtual void dump() const;
#endif
/// Similar to print() but adds a newline. Used for testing.
virtual void printPipeline(raw_ostream &OS) const { OS << Name << "\n"; }
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/SandboxIR/Region.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ class Region {

#ifndef NDEBUG
/// This is an expensive check, meant for testing.
bool operator==(const Region &Other) const;
LLVM_ABI_FOR_TEST bool operator==(const Region &Other) const;
bool operator!=(const Region &other) const { return !(*this == other); }

void dump(raw_ostream &OS) const;
LLVM_ABI_FOR_TEST void dump(raw_ostream &OS) const;
void dump() const;
friend raw_ostream &operator<<(raw_ostream &OS, const Region &Rgn) {
Rgn.dump(OS);
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/SandboxIR/Tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ class IRSnapshotChecker {

/// Saves a snapshot of the current state. If there was any previous snapshot,
/// it will be replaced with the new one.
void save();
LLVM_ABI_FOR_TEST void save();

/// Checks current state against saved state, crashes if different.
void expectNoDiff();
LLVM_ABI_FOR_TEST void expectNoDiff();
};

#endif // NDEBUG
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/SandboxIR/Use.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Use {
}
bool operator!=(const Use &Other) const { return !(*this == Other); }
#ifndef NDEBUG
void dumpOS(raw_ostream &OS) const;
LLVM_ABI_FOR_TEST void dumpOS(raw_ostream &OS) const;
void dump() const;
#endif // NDEBUG
};
Expand Down
Loading