LLVM: lib/CAS/OnDiskKeyValueDB.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
28
29using namespace llvm;
32
34
39 "expected value size of " + itostr(ValueSize) +
42 auto ActionP = Cache.insertLazy(
47 });
49 return ActionP.takeError();
50 return (*ActionP)->Data;
51}
52
55
57 if (ActionP) {
59 return ActionP->Data;
60 }
61 if (!UnifiedCache || !UnifiedCache->UpstreamKVDB)
62 return std::nullopt;
63
64
65 return UnifiedCache->faultInFromUpstreamKV(Key);
66}
67
74
77 constexpr uint64_t MB = 1024ull * 1024ull;
78 constexpr uint64_t GB = 1024ull * 1024ull * 1024ull;
79
82 if (!CustomSize)
83 return CustomSize.takeError();
84 if (*CustomSize)
85 MaxFileSize = **CustomSize;
86
87 std::optional ActionCache;
89 CachePath,
90 "llvm.actioncache[" + HashName + "->" + ValueName + "]",
91 KeySize * 8,
92 ValueSize, MaxFileSize, MB)
94 return std::move(E);
95
96 return std::unique_ptr(
97 new OnDiskKeyValueDB(ValueSize, std::move(*ActionCache), Cache));
98}
99
101 if (UnifiedCache && UnifiedCache->UpstreamKVDB) {
102 if (auto E = UnifiedCache->UpstreamKVDB->validate(CheckValue))
103 return E;
104 }
105 return Cache.validate(
108 auto formatError = [&](Twine Msg) {
111 "bad cache value at 0x" +
112 utohexstr((unsigned)Offset.get(), true) + ": " +
113 Msg.str());
114 };
115
116 if (Record.Data.size() != ValueSize)
117 return formatError("wrong cache value size");
119 return formatError("wrong cache value alignment");
120 if (CheckValue)
123 });
124}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_UNLIKELY(EXPR)
static constexpr StringLiteral ActionCacheFile
Definition OnDiskKeyValueDB.cpp:33
This declares OnDiskKeyValueDB, a key value storage database of fixed size key and value.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
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...
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
A cache from a key (that describes an action) to the result of performing that action.
FileOffset is a wrapper around uint64_t to represent the offset of data from the beginning of the fil...
static LLVM_ABI_FOR_TEST Expected< OnDiskTrieRawHashMap > create(const Twine &Path, const Twine &TrieName, size_t NumHashBits, uint64_t DataSize, uint64_t MaxFileSize, std::optional< uint64_t > NewFileInitialSize, std::optional< size_t > NewTableNumRootBits=std::nullopt, std::optional< size_t > NewTableNumSubtrieBits=std::nullopt)
Gets or creates a file at Path with a hash-mapped trie named TrieName.
static LLVM_ABI_FOR_TEST Expected< std::unique_ptr< OnDiskKeyValueDB > > open(StringRef Path, StringRef HashName, unsigned KeySize, StringRef ValueName, size_t ValueSize, UnifiedOnDiskCache *UnifiedCache=nullptr)
Open the on-disk store from a directory.
Definition OnDiskKeyValueDB.cpp:69
LLVM_ABI_FOR_TEST Expected< ArrayRef< char > > put(ArrayRef< uint8_t > Key, ArrayRef< char > Value)
Associate a value with a key.
Definition OnDiskKeyValueDB.cpp:35
LLVM_ABI_FOR_TEST Expected< std::optional< ArrayRef< char > > > get(ArrayRef< uint8_t > Key)
Definition OnDiskKeyValueDB.cpp:54
function_ref< Error(FileOffset Offset, ArrayRef< char > Data)> CheckValueT
LLVM_ABI_FOR_TEST Error validate(CheckValueT CheckValue) const
Validate the storage with a callback CheckValue to check the stored value.
Definition OnDiskKeyValueDB.cpp:100
A unified CAS nodes and key-value database, using on-disk storage for both.
constexpr StringLiteral CASFormatVersion
The version for all the ondisk database files.
Expected< std::optional< uint64_t > > getOverriddenMaxMappingSize()
Retrieves an overridden maximum mapping size for CAS files, if any, speicified by LLVM_CAS_MAX_MAPPIN...
LLVM_ABI std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
StringMapEntry< Value * > ValueName
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
OutputIt copy(R &&Range, OutputIt Out)
std::string itostr(int64_t X)
bool isAddrAligned(Align Lhs, const void *Addr)
Checks that Addr is a multiple of the alignment.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Const value proxy to access the records stored in TrieRawHashMap.
Value proxy to access the records stored in TrieRawHashMap.
MutableArrayRef< char > Data