20void CASContext::anchor() {}
21void ObjectStore::anchor() {}
35 uint64_t InternalRef, std::optional<CASID>
ID) {
36 OS << Kind <<
"=" << InternalRef;
38 OS <<
"[" << *
ID <<
"]";
49 std::optional<CASID>
ID;
50#if LLVM_ENABLE_ABI_BREAKING_CHECKS
52 ID = CAS->getID(This);
58 std::optional<ObjectHandle> Handle;
67std::unique_ptr<MemoryBuffer>
69 bool RequiresNullTerminator) {
72 RequiresNullTerminator);
92 std::optional<ObjectHandle>
H;
101 std::optional<ObjectHandle>
H;
111 "unknown object '" +
ID.toString() +
"'");
118 return Ref.takeError();
124 std::optional<sys::fs::file_status>
Status) {
140 while (!RefsToValidate.
empty()) {
142 auto [
I, Inserted] = ValidatedRefs.
insert(
Ref);
169 if (
this == &Upstream)
174 struct UpstreamCursor {
178 std::deque<ObjectRef> Refs;
189 std::deque<ObjectRef> Refs;
190 for (
unsigned I = 0;
I < NumRefs; ++
I)
196 auto UpstreamHandle = Upstream.
load(
Other);
198 return UpstreamHandle.takeError();
199 enqueueNode(
Other, *UpstreamHandle);
201 while (!CursorStack.
empty()) {
202 UpstreamCursor &Cur = CursorStack.
back();
203 if (Cur.Refs.empty()) {
207 assert(PrimaryRefStack.
size() >= Cur.RefsCount);
208 auto Refs =
ArrayRef(PrimaryRefStack)
209 .slice(PrimaryRefStack.
size() - Cur.RefsCount);
212 return NewNode.takeError();
215 PrimaryRefStack.
truncate(PrimaryRefStack.
size() - Cur.RefsCount);
224 auto CurrentID = Cur.Refs.front();
225 Cur.Refs.pop_front();
226 auto Ref = CreatedObjects.
find(CurrentID);
227 if (
Ref != CreatedObjects.
end()) {
234 auto PrimaryID = Upstream.
load(CurrentID);
236 return PrimaryID.takeError();
238 enqueueNode(CurrentID, *PrimaryID);
242 return PrimaryRefStack.
front();
245std::unique_ptr<MemoryBuffer>
247 bool RequiresNullTerminator)
const {
248 return CAS->getMemoryBuffer(H, Name, RequiresNullTerminator);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Mark last scratch load
#define LLVM_UNLIKELY(EXPR)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file defines the DenseSet and SmallDenseSet classes.
static void printReferenceBase(raw_ostream &OS, StringRef Kind, uint64_t InternalRef, std::optional< CASID > ID)
This file contains the declaration of the ObjectStore class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
Implements a dense probed hash-table based set with some number of buckets stored inline.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void truncate(size_type N)
Like resize, but requires that N is less than size().
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Unique identifier for a CAS object.
void print(raw_ostream &OS) const
Print CASID.
std::string toString() const
Return a printable string for CASID.
Handle to a loaded object in a ObjectStore instance.
void print(raw_ostream &OS) const
Print internal ref and/or CASID. Only suitable for debugging.
LLVM_DUMP_METHOD void dump() const
static ObjectProxy load(ObjectStore &CAS, ObjectRef Ref, ObjectHandle Node)
std::unique_ptr< MemoryBuffer > getMemoryBuffer(StringRef Name="", bool RequiresNullTerminator=true) const
Reference to an object in an ObjectStore instance.
void print(raw_ostream &OS) const
Print internal ref and/or CASID. Only suitable for debugging.
LLVM_DUMP_METHOD void dump() const
Expected< ObjectHandle > load(ObjectRef Ref)
Like loadIfExists but returns an error if the object is missing.
Expected< ObjectProxy > createProxy(ArrayRef< ObjectRef > Refs, StringRef Data)
Helper functions to store object and returns a ObjectProxy.
virtual void print(raw_ostream &) const
Print the ObjectStore internals for debugging purpose.
virtual Error validateObject(const CASID &ID)=0
Validate the underlying object referred by CASID.
Expected< ObjectRef > importObject(ObjectStore &Upstream, ObjectRef Other)
Import object from another CAS.
Expected< std::optional< ObjectProxy > > getProxyIfExists(ObjectRef Ref)
virtual Expected< ObjectRef > store(ArrayRef< ObjectRef > Refs, ArrayRef< char > Data)=0
Store object into ObjectStore.
virtual ArrayRef< char > getData(ObjectHandle Node, bool RequiresNullTerminator=false) const =0
virtual CASID getID(ObjectRef Ref) const =0
Get an ID for Ref.
static Error createUnknownObjectError(const CASID &ID)
virtual Expected< std::optional< ObjectHandle > > loadIfExists(ObjectRef Ref)=0
Load the object referenced by Ref.
Error validateTree(ObjectRef Ref)
Validate the whole node tree.
virtual ObjectRef readRef(ObjectHandle Node, size_t I) const =0
ObjectStore(const CASContext &Context)
virtual Expected< ObjectRef > storeFromOpenFileImpl(sys::fs::file_t FD, std::optional< sys::fs::file_status > Status)
Get ObjectRef from open file.
virtual void readRefs(ObjectHandle Node, SmallVectorImpl< ObjectRef > &Refs) const
Read all the refs from object in a SmallVector.
virtual size_t getNumRefs(ObjectHandle Node) const =0
std::unique_ptr< MemoryBuffer > getMemoryBuffer(ObjectHandle Node, StringRef Name="", bool RequiresNullTerminator=true)
Get a lifetime-extended MemoryBuffer pointing at Data.
virtual std::optional< ObjectRef > getReference(const CASID &ID) const =0
Get an existing reference to the object called ID.
Expected< ObjectProxy > getProxy(const CASID &ID)
Create ObjectProxy from CASID. If the object doesn't exist, get an error.
virtual Error forEachRef(ObjectHandle Node, function_ref< Error(ObjectRef)> Callback) const =0
Methods for handling objects.
void print(raw_ostream &OS, const ObjectHandle &This) const
std::pair< iterator, bool > insert(const ValueT &V)
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
ArrayRef< CharT > arrayRefFromStringRef(StringRef Input)
Construct a string ref from an array ref of unsigned chars.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
@ Ref
The access may reference the value stored in memory.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
ArrayRef(const T &OneElt) -> ArrayRef< T >
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
LLVM_ABI Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
void consumeError(Error Err)
Consume a Error without doing anything.
StringRef toStringRef(bool B)
Construct a string ref from a boolean.