18#define DEBUG_TYPE "cas-action-caches"
28template <
size_t Size>
class CacheEntry {
30 CacheEntry() =
default;
32 CacheEntry(
const CacheEntry &Entry) {
llvm::copy(Entry.Value,
Value.data()); }
36 std::array<uint8_t, Size>
Value;
40class InMemoryActionCache final :
public ActionCache {
46 bool CanBeDistributed)
final;
48 bool CanBeDistributed)
const final;
51 using DataT = CacheEntry<
sizeof(HashType)>;
62 std::string Existing =
65 toHex(KeyHash,
true, Key);
67 "cache poisoned for '" + Key +
"' (new='" +
68 Output.
toString() +
"' vs. existing '" +
75 auto Result = Cache.find(Key);
84 const InMemoryCacheT::value_type &Cached = *Cache.insertLazy(
85 Key, [&](
auto ValueConstructor) { ValueConstructor.emplace(
Expected); });
87 const DataT &Observed = Cached.Data;
88 if (
Expected.getValue() == Observed.getValue())
98 return std::make_unique<InMemoryActionCache>();
This file contains the declaration of the ActionCache class, which is the base class for ActionCache ...
static Error createResultCachePoisonedError(ArrayRef< uint8_t > KeyHash, const CASContext &Context, CASID Output, ArrayRef< uint8_t > ExistingOutput)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
A class that wraps the BLAKE3 algorithm.
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.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Lock-free thread-safe hash-mapped trie.
LLVM Value Representation.
A cache from a key (that describes an action) to the result of performing that action.
virtual Expected< std::optional< CASID > > getImpl(ArrayRef< uint8_t > ResolvedKey, bool CanBeDistributed) const =0
virtual Error putImpl(ArrayRef< uint8_t > ResolvedKey, const CASID &Result, bool CanBeDistributed)=0
Context for CAS identifiers.
Unique identifier for a CAS object.
std::string toString() const
Return a printable string for CASID.
static CASID create(const CASContext *Context, StringRef Hash)
Create CASID from CASContext and raw hash bytes.
static const BuiltinCASContext & getDefaultContext()
std::unique_ptr< ActionCache > createInMemoryActionCache()
Create an action cache in memory.
StringRef toStringRef(const std::optional< DWARFFormValue > &V, StringRef Default={})
Take an optional DWARFFormValue and try to extract a string value from it.
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
OutputIt copy(R &&Range, OutputIt Out)