Skip to content

[CAS] Add LLVMCAS library with InMemoryCAS implementation #114096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions llvm/docs/ContentAddressableStorage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Introduction to CAS

Content Addressable Storage, or `CAS`, is a storage system where it assigns
Content Addressable Storage, or `CAS`, is a storage system that assigns
unique addresses to the data stored. It is very useful for data deduplicaton
and creating unique identifiers.

Unlike other kinds of storage system like a file system, CAS is immutable. It
Unlike other kinds of storage systems like file systems, CAS is immutable. It
is more reliable to model a computation by representing the inputs and outputs
of the computation using objects stored in CAS.

Expand All @@ -24,7 +24,7 @@ struct CASObject {
}
```

With this abstraction, it is possible to compose CASObjects into a DAG that is
With this abstraction, it is possible to compose `CASObject`s into a DAG that is
capable of representing complicated data structures, while still allowing data
deduplication. Note you can compare two DAGs by just comparing the CASObject
hash of two root nodes.
Expand Down
4 changes: 4 additions & 0 deletions llvm/docs/Reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,9 @@ Additional Topics
A description of uniformity analysis in the presence of irreducible
control flow, and its implementation.

:doc:`MLGO`
Facilities for ML-Guided Optimization, such as collecting IR corpora from a
build, interfacing with ML models, an exposing features for training.

:doc:`ContentAddressableStorage`
A reference guide for using LLVM's CAS library.
1 change: 1 addition & 0 deletions llvm/include/llvm/CAS/BuiltinCASContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace llvm::cas::builtin {
using HasherT = BLAKE3;
using HashType = decltype(HasherT::hash(std::declval<ArrayRef<uint8_t> &>()));

/// CASContext for LLVM builtin CAS using BLAKE3 hash type.
class BuiltinCASContext : public CASContext {
void printIDImpl(raw_ostream &OS, const CASID &ID) const final;
void anchor() override;
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/CAS/BuiltinObjectHasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace llvm::cas {

/// Hasher for stored objects in builtin CAS.
template <class HasherT> class BuiltinObjectHasher {
public:
using HashT = decltype(HasherT::hash(std::declval<ArrayRef<uint8_t> &>()));
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/CAS/BuiltinCAS.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace llvm::cas {
class ActionCache;
namespace builtin {

/// Common base class for builtin CAS implementations using the same CASContext.
class BuiltinCAS : public ObjectStore {
public:
BuiltinCAS() : ObjectStore(BuiltinCASContext::getDefaultContext()) {}
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/CAS/InMemoryCAS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ using InMemoryIndexT =
/// their hash.
using InMemoryIndexValueT = InMemoryIndexT::value_type;

/// Builtin InMemory CAS that stores CAS object in the memory.
class InMemoryObject {
public:
enum class Kind {
Expand Down