LLVM 24.0.0git
PluginCAS.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// Implements \c ObjectStore and \c ActionCache on top of a dynamically loaded
11/// plugin that provides the C API in \c "llvm-c/CAS/PluginAPI_functions.h".
12///
13/// The asynchronous entry points of the plugin API are not called yet; they
14/// will be wired up once \c ObjectStore and \c ActionCache grow asynchronous
15/// interfaces.
16///
17//===----------------------------------------------------------------------===//
18
19#include "PluginAPI.h"
20#include "llvm/ADT/ScopeExit.h"
24#include "llvm/Support/Error.h"
26
27using namespace llvm;
28using namespace llvm::cas;
29
30namespace {
31
32class PluginCASContext : public CASContext {
33public:
34 void printIDImpl(raw_ostream &OS, const CASID &ID) const final;
35
36 StringRef getHashSchemaIdentifier() const final { return SchemaName; }
37
38 static Expected<std::shared_ptr<PluginCASContext>>
39 create(StringRef PluginPath, StringRef OnDiskPath,
40 ArrayRef<std::pair<std::string, std::string>> PluginArgs);
41
42 ~PluginCASContext() { Functions.cas_dispose(c_cas); }
43
44 llcas_functions_t Functions{};
45 llcas_cas_t c_cas = nullptr;
46 std::string SchemaName;
47
48 static Error errorAndDispose(char *c_err, const llcas_functions_t &Funcs) {
50 Funcs.string_dispose(c_err);
51 return E;
52 }
53
54 Error errorAndDispose(char *c_err) const {
55 return errorAndDispose(c_err, Functions);
56 }
57};
58
59} // anonymous namespace
60
61void PluginCASContext::printIDImpl(raw_ostream &OS, const CASID &ID) const {
62 ArrayRef<uint8_t> Hash = ID.getHash();
63 char *c_printed_id = nullptr;
64 char *c_err = nullptr;
65 if (Functions.digest_print(c_cas, llcas_digest_t{Hash.data(), Hash.size()},
66 &c_printed_id, &c_err))
67 report_fatal_error(errorAndDispose(c_err));
68 OS << c_printed_id;
69 Functions.string_dispose(c_printed_id);
70}
71
72Expected<std::shared_ptr<PluginCASContext>> PluginCASContext::create(
73 StringRef PluginPath, StringRef OnDiskPath,
74 ArrayRef<std::pair<std::string, std::string>> PluginArgs) {
75 auto reportError = [PluginPath](const Twine &Description) -> Error {
76 std::error_code EC = inconvertibleErrorCode();
77 return createStringError(EC, "error loading '" + PluginPath +
78 "': " + Description);
79 };
80
81 SmallString<256> PathBuf = PluginPath;
82 std::string ErrMsg;
83 sys::DynamicLibrary Lib =
85 if (!Lib.isValid())
86 return reportError(ErrMsg);
87
88 llcas_functions_t Functions{};
89
90#define CASPLUGINAPI_FUNCTION(name, required) \
91 if (!(Functions.name = (decltype(llcas_functions_t::name)) \
92 Lib.getAddressOfSymbol("llcas_" #name))) { \
93 if (required) \
94 return reportError("failed symbol 'llcas_" #name "' lookup"); \
95 }
96#include "PluginAPI_functions.def"
97#undef CASPLUGINAPI_FUNCTION
98
99 llcas_cas_options_t c_opts = Functions.cas_options_create();
100 scope_exit DisposeOptions([&]() { Functions.cas_options_dispose(c_opts); });
101
104 SmallString<256> OnDiskPathBuf = OnDiskPath;
105 Functions.cas_options_set_ondisk_path(c_opts, OnDiskPathBuf.c_str());
106 for (const auto &Pair : PluginArgs) {
107 char *c_err = nullptr;
108 if (Functions.cas_options_set_option(c_opts, Pair.first.c_str(),
109 Pair.second.c_str(), &c_err))
110 return errorAndDispose(c_err, Functions);
111 }
112
113 char *c_err = nullptr;
114 llcas_cas_t c_cas = Functions.cas_create(c_opts, &c_err);
115 if (!c_cas)
116 return errorAndDispose(c_err, Functions);
117
118 char *c_schema = Functions.cas_get_hash_schema_name(c_cas);
119 std::string SchemaName = c_schema;
120 Functions.string_dispose(c_schema);
121
122 auto Ctx = std::make_shared<PluginCASContext>();
123 Ctx->Functions = Functions;
124 Ctx->c_cas = c_cas;
125 Ctx->SchemaName = std::move(SchemaName);
126 return Ctx;
127}
128
129//===----------------------------------------------------------------------===//
130// ObjectStore API
131//===----------------------------------------------------------------------===//
132
133namespace {
134
135class PluginObjectStore : public ObjectStore {
136public:
137 Expected<CASID> parseID(StringRef ID) final;
138 Expected<ObjectRef> store(ArrayRef<ObjectRef> Refs,
139 ArrayRef<char> Data) final;
140 Expected<ObjectRef> storeFromFile(StringRef Path) final;
141 Error exportDataToFile(ObjectHandle Node, StringRef Path) const final;
142 CASID getID(ObjectRef Ref) const final;
143 std::optional<ObjectRef> getReference(const CASID &ID) const final;
144 Expected<bool> isMaterialized(ObjectRef Ref) const final;
145 Expected<std::optional<ObjectHandle>> loadIfExists(ObjectRef Ref) final;
146 uint64_t getDataSize(ObjectHandle Node) const final;
147 Error forEachRef(ObjectHandle Node,
148 function_ref<Error(ObjectRef)> Callback) const final;
149 ObjectRef readRef(ObjectHandle Node, size_t I) const final;
150 size_t getNumRefs(ObjectHandle Node) const final;
151 ArrayRef<char> getData(ObjectHandle Node,
152 bool RequiresNullTerminator = false) const final;
153 std::unique_ptr<MemoryBuffer>
154 getStandaloneMemoryBufferImpl(ObjectHandle Node, StringRef Name,
155 bool RequiresNullTerminator) final;
156 Error validateObject(const CASID &ID) final {
157 // Not supported yet. Always return success.
158 return Error::success();
159 }
160
161 Error validate(bool CheckHash) const final;
162
163 Error setSizeLimit(std::optional<uint64_t> SizeLimit) final;
164 Expected<std::optional<uint64_t>> getStorageSize() const final;
165 Error pruneStorageData() final;
166
167 PluginObjectStore(std::shared_ptr<PluginCASContext>);
168
169 /// Exposes \c makeObjectRef to the file-local helpers below.
170 ObjectRef makeRef(uint64_t InternalRef) const {
171 return makeObjectRef(InternalRef);
172 }
173
174 std::shared_ptr<PluginCASContext> Ctx;
175};
176
177} // anonymous namespace
178
179Expected<CASID> PluginObjectStore::parseID(StringRef ID) {
180 // Use big enough stack so that we don't have to allocate in the heap.
181 SmallString<148> IDBuf(ID);
182 SmallVector<uint8_t, 68> BytesBuf(68);
183
184 auto parseDigest = [&]() -> Expected<unsigned> {
185 char *c_err = nullptr;
186 unsigned NumBytes = Ctx->Functions.digest_parse(
187 Ctx->c_cas, IDBuf.c_str(), BytesBuf.data(), BytesBuf.size(), &c_err);
188 if (NumBytes == 0)
189 return Ctx->errorAndDispose(c_err);
190 return NumBytes;
191 };
192
193 Expected<unsigned> NumBytes = parseDigest();
194 if (!NumBytes)
195 return NumBytes.takeError();
196
197 if (*NumBytes > BytesBuf.size()) {
198 BytesBuf.resize(*NumBytes);
199 NumBytes = parseDigest();
200 if (!NumBytes)
201 return NumBytes.takeError();
202 assert(*NumBytes == BytesBuf.size());
203 } else {
204 BytesBuf.truncate(*NumBytes);
205 }
206
207 return CASID::create(Ctx.get(), toStringRef(BytesBuf));
208}
209
210Expected<ObjectRef> PluginObjectStore::store(ArrayRef<ObjectRef> Refs,
211 ArrayRef<char> Data) {
213 c_ids.reserve(Refs.size());
214 for (ObjectRef Ref : Refs) {
215 c_ids.push_back(llcas_objectid_t{Ref.getInternalRef(*this)});
216 }
217
218 llcas_objectid_t c_stored_id;
219 char *c_err = nullptr;
220 if (Ctx->Functions.cas_store_object(
221 Ctx->c_cas, llcas_data_t{Data.data(), Data.size()}, c_ids.data(),
222 c_ids.size(), &c_stored_id, &c_err))
223 return Ctx->errorAndDispose(c_err);
224
225 return makeObjectRef(c_stored_id.opaque);
226}
227
228Expected<ObjectRef> PluginObjectStore::storeFromFile(StringRef Path) {
229 if (!Ctx->Functions.cas_store_from_filepath)
230 return ObjectStore::storeFromFile(Path);
231
232 llcas_objectid_t c_stored_id;
233 char *c_err = nullptr;
234 std::string PathStr = Path.str();
235 if (Ctx->Functions.cas_store_from_filepath(Ctx->c_cas, PathStr.c_str(),
236 &c_stored_id, &c_err))
237 return Ctx->errorAndDispose(c_err);
238
239 return makeObjectRef(c_stored_id.opaque);
240}
241
242Error PluginObjectStore::exportDataToFile(ObjectHandle Node,
243 StringRef Path) const {
244 if (!Ctx->Functions.loaded_object_export_data_to_filepath)
245 return ObjectStore::exportDataToFile(Node, Path);
246
247 char *c_err = nullptr;
248 std::string PathStr = Path.str();
249 if (Ctx->Functions.loaded_object_export_data_to_filepath(
250 Ctx->c_cas, llcas_loaded_object_t{Node.getInternalRef(*this)},
251 PathStr.c_str(), &c_err))
252 return Ctx->errorAndDispose(c_err);
253
254 return Error::success();
255}
256
258 return StringRef((const char *)c_digest.data, c_digest.size);
259}
260
261CASID PluginObjectStore::getID(ObjectRef Ref) const {
262 llcas_objectid_t c_id{Ref.getInternalRef(*this)};
263 llcas_digest_t c_digest =
264 Ctx->Functions.objectid_get_digest(Ctx->c_cas, c_id);
265 return CASID::create(Ctx.get(), toStringRef(c_digest));
266}
267
268std::optional<ObjectRef>
269PluginObjectStore::getReference(const CASID &ID) const {
270 ArrayRef<uint8_t> Hash = ID.getHash();
271 llcas_objectid_t c_id;
272 char *c_err = nullptr;
273 if (Ctx->Functions.cas_get_objectid(
274 Ctx->c_cas, llcas_digest_t{Hash.data(), Hash.size()}, &c_id, &c_err))
275 report_fatal_error(Ctx->errorAndDispose(c_err));
276
277 return makeObjectRef(c_id.opaque);
278}
279
280Expected<bool> PluginObjectStore::isMaterialized(ObjectRef Ref) const {
281 llcas_objectid_t c_id{Ref.getInternalRef(*this)};
282 char *c_err = nullptr;
283 llcas_lookup_result_t c_result = Ctx->Functions.cas_contains_object(
284 Ctx->c_cas, c_id, /*globally=*/false, &c_err);
285 switch (c_result) {
287 return true;
289 return false;
291 return Ctx->errorAndDispose(c_err);
292 }
293 llvm_unreachable("unknown llcas_lookup_result_t value");
294}
295
296Expected<std::optional<ObjectHandle>>
297PluginObjectStore::loadIfExists(ObjectRef Ref) {
298 llcas_objectid_t c_id{Ref.getInternalRef(*this)};
299 llcas_loaded_object_t c_obj;
300 char *c_err = nullptr;
301 llcas_lookup_result_t c_result =
302 Ctx->Functions.cas_load_object(Ctx->c_cas, c_id, &c_obj, &c_err);
303 switch (c_result) {
305 return makeObjectHandle(c_obj.opaque);
307 return std::nullopt;
309 return Ctx->errorAndDispose(c_err);
310 }
311 llvm_unreachable("unknown llcas_lookup_result_t value");
312}
313
314namespace {
315
316class ObjectRefsWrapper {
317public:
318 ObjectRefsWrapper(const ObjectHandle &Node, const PluginObjectStore &Store)
319 : Store(Store), Ctx(*Store.Ctx) {
320 llcas_loaded_object_t c_obj{Node.getInternalRef(Store)};
321 this->c_refs = Ctx.Functions.loaded_object_get_refs(Ctx.c_cas, c_obj);
322 }
323
324 size_t size() const {
325 return Ctx.Functions.object_refs_get_count(Ctx.c_cas, c_refs);
326 }
327
328 ObjectRef operator[](size_t I) const {
329 llcas_objectid_t c_id =
330 Ctx.Functions.object_refs_get_id(Ctx.c_cas, c_refs, I);
331 return Store.makeRef(c_id.opaque);
332 }
333
334private:
335 const PluginObjectStore &Store;
336 PluginCASContext &Ctx;
337 llcas_object_refs_t c_refs;
338};
339
340} // namespace
341
342// FIXME: Replace forEachRef/readRef/getNumRefs APIs with an iterator interface.
343Error PluginObjectStore::forEachRef(
344 ObjectHandle Node, function_ref<Error(ObjectRef)> Callback) const {
345 ObjectRefsWrapper Refs(Node, *this);
346 for (unsigned I = 0, E = Refs.size(); I != E; ++I) {
347 if (Error E = Callback(Refs[I]))
348 return E;
349 }
350 return Error::success();
351}
352
353ObjectRef PluginObjectStore::readRef(ObjectHandle Node, size_t I) const {
354 ObjectRefsWrapper Refs(Node, *this);
355 return Refs[I];
356}
357
358size_t PluginObjectStore::getNumRefs(ObjectHandle Node) const {
359 ObjectRefsWrapper Refs(Node, *this);
360 return Refs.size();
361}
362
363// FIXME: Remove getDataSize(ObjectHandle) from API requirement,
364// \c getData(ObjectHandle) should be enough.
365uint64_t PluginObjectStore::getDataSize(ObjectHandle Node) const {
366 ArrayRef<char> Data = getData(Node);
367 return Data.size();
368}
369
370ArrayRef<char> PluginObjectStore::getData(ObjectHandle Node,
371 bool RequiresNullTerminator) const {
372 // FIXME: Remove RequiresNullTerminator from ObjectStore API requirement?
373 // It is a requirement for the plugin API.
374 llcas_data_t c_data = Ctx->Functions.loaded_object_get_data(
375 Ctx->c_cas, llcas_loaded_object_t{Node.getInternalRef(*this)});
376 return ArrayRef((const char *)c_data.data, c_data.size);
377}
378
379namespace {
380/// A MemoryBuffer over a plugin's standalone buffer, which it releases when
381/// destroyed. It holds the dispose function directly rather than the
382/// \c llcas_cas_t, since the point of the buffer is to outlive that.
383class PluginStandaloneMemoryBuffer final : public MemoryBuffer {
384public:
385 using DisposeFn = void (*)(llcas_data_t);
386
387 PluginStandaloneMemoryBuffer(llcas_data_t Data, StringRef Name,
388 DisposeFn Dispose)
389 : Data(Data), Name(Name.str()), Dispose(Dispose) {
390 const char *Start = static_cast<const char *>(Data.data);
391 init(Start, Start + Data.size, /*RequiresNullTerminator=*/true);
392 }
393
394 ~PluginStandaloneMemoryBuffer() override { Dispose(Data); }
395
396 StringRef getBufferIdentifier() const final { return Name; }
397
398 BufferKind getBufferKind() const final { return MemoryBuffer_Malloc; }
399
400private:
401 llcas_data_t Data;
402 std::string Name;
403 DisposeFn Dispose;
404};
405} // namespace
406
407std::unique_ptr<MemoryBuffer> PluginObjectStore::getStandaloneMemoryBufferImpl(
408 ObjectHandle Node, StringRef Name, bool RequiresNullTerminator) {
409 // Both halves are needed: without the disposer there is no way to release
410 // what the getter hands out.
411 if (!Ctx->Functions.loaded_object_get_standalone_data ||
412 !Ctx->Functions.standalone_data_dispose)
414 RequiresNullTerminator);
415
416 llcas_data_t c_data = Ctx->Functions.loaded_object_get_standalone_data(
417 Ctx->c_cas, llcas_loaded_object_t{Node.getInternalRef(*this)});
418 if (!c_data.data)
420 RequiresNullTerminator);
421
422 return std::make_unique<PluginStandaloneMemoryBuffer>(
423 c_data, Name, Ctx->Functions.standalone_data_dispose);
424}
425
426Error PluginObjectStore::setSizeLimit(std::optional<uint64_t> SizeLimit) {
427 if (Ctx->Functions.cas_set_ondisk_size_limit) {
428 char *c_err = nullptr;
429 if (Ctx->Functions.cas_set_ondisk_size_limit(Ctx->c_cas,
430 SizeLimit.value_or(0), &c_err))
431 return Ctx->errorAndDispose(c_err);
432 }
433 return Error::success();
434}
435
436Expected<std::optional<uint64_t>> PluginObjectStore::getStorageSize() const {
437 if (!Ctx->Functions.cas_get_ondisk_size)
438 return std::nullopt;
439 char *c_err = nullptr;
440 int64_t ret = Ctx->Functions.cas_get_ondisk_size(Ctx->c_cas, &c_err);
441 switch (ret) {
442 case -1:
443 return std::nullopt;
444 case -2:
445 return Ctx->errorAndDispose(c_err);
446 default:
447 return ret;
448 }
449}
450
451Error PluginObjectStore::pruneStorageData() {
452 if (Ctx->Functions.cas_prune_ondisk_data) {
453 char *c_err = nullptr;
454 if (Ctx->Functions.cas_prune_ondisk_data(Ctx->c_cas, &c_err))
455 return Ctx->errorAndDispose(c_err);
456 }
457 return Error::success();
458}
459
460Error PluginObjectStore::validate(bool CheckHash) const {
461 if (Ctx->Functions.cas_validate) {
462 char *c_err = nullptr;
463 if (Ctx->Functions.cas_validate(Ctx->c_cas, CheckHash, &c_err))
464 return Ctx->errorAndDispose(c_err);
465 return Error::success();
466 }
467 return createStringError("plugin cas doesn't support validation");
468}
469
470PluginObjectStore::PluginObjectStore(std::shared_ptr<PluginCASContext> CASCtx)
471 : ObjectStore(*CASCtx), Ctx(std::move(CASCtx)) {}
472
473//===----------------------------------------------------------------------===//
474// ActionCache API
475//===----------------------------------------------------------------------===//
476
477namespace {
478
479class PluginActionCache : public ActionCache {
480public:
481 Expected<std::optional<CASID>> getImpl(ArrayRef<uint8_t> ResolvedKey,
482 bool CanBeDistributed) const final;
483
484 Error putImpl(ArrayRef<uint8_t> ResolvedKey, const CASID &Result,
485 bool CanBeDistributed) final;
486
487 PluginActionCache(std::shared_ptr<PluginCASContext>);
488
489 Error validate() const final;
490
491private:
492 std::shared_ptr<PluginCASContext> Ctx;
493};
494
495} // anonymous namespace
496
497Expected<std::optional<CASID>>
498PluginActionCache::getImpl(ArrayRef<uint8_t> ResolvedKey,
499 bool CanBeDistributed) const {
500 llcas_objectid_t c_value;
501 char *c_err = nullptr;
502 llcas_lookup_result_t c_result = Ctx->Functions.actioncache_get_for_digest(
503 Ctx->c_cas, llcas_digest_t{ResolvedKey.data(), ResolvedKey.size()},
504 &c_value, CanBeDistributed, &c_err);
505 switch (c_result) {
507 llcas_digest_t c_digest =
508 Ctx->Functions.objectid_get_digest(Ctx->c_cas, c_value);
509 return CASID::create(Ctx.get(), toStringRef(c_digest));
510 }
512 return std::nullopt;
514 return Ctx->errorAndDispose(c_err);
515 }
516 llvm_unreachable("unknown llcas_lookup_result_t value");
517}
518
519Error PluginActionCache::putImpl(ArrayRef<uint8_t> ResolvedKey,
520 const CASID &Result, bool CanBeDistributed) {
521 ArrayRef<uint8_t> Hash = Result.getHash();
522 llcas_objectid_t c_value;
523 char *c_err = nullptr;
524 if (Ctx->Functions.cas_get_objectid(Ctx->c_cas,
525 llcas_digest_t{Hash.data(), Hash.size()},
526 &c_value, &c_err))
527 return Ctx->errorAndDispose(c_err);
528
529 if (Ctx->Functions.actioncache_put_for_digest(
530 Ctx->c_cas, llcas_digest_t{ResolvedKey.data(), ResolvedKey.size()},
531 c_value, CanBeDistributed, &c_err))
532 return Ctx->errorAndDispose(c_err);
533
534 return Error::success();
535}
536
537PluginActionCache::PluginActionCache(std::shared_ptr<PluginCASContext> CASCtx)
538 : ActionCache(*CASCtx), Ctx(std::move(CASCtx)) {}
539
540Error PluginActionCache::validate() const {
541 if (Ctx->Functions.actioncache_validate) {
542 char *c_err = nullptr;
543 if (Ctx->Functions.actioncache_validate(Ctx->c_cas, &c_err))
544 return Ctx->errorAndDispose(c_err);
545 return Error::success();
546 }
547 return createStringError("plugin action cache doesn't support validation");
548}
549
550//===----------------------------------------------------------------------===//
551// createPluginCASDatabases API
552//===----------------------------------------------------------------------===//
553
554Expected<std::pair<std::shared_ptr<ObjectStore>, std::shared_ptr<ActionCache>>>
556 StringRef PluginPath, StringRef OnDiskPath,
557 ArrayRef<std::pair<std::string, std::string>> PluginArgs) {
558 std::shared_ptr<PluginCASContext> Ctx;
559 if (Error E = PluginCASContext::create(PluginPath, OnDiskPath, PluginArgs)
560 .moveInto(Ctx))
561 return std::move(E);
562 auto CAS = std::make_shared<PluginObjectStore>(Ctx);
563 auto AC = std::make_shared<PluginActionCache>(std::move(Ctx));
564 return std::make_pair(std::move(CAS), std::move(AC));
565}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
aarch64 promote const
This file contains the declaration of the ActionCache class, which is the base class for ActionCache ...
static Error reportError(StringRef Message)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static cl::opt< unsigned > SizeLimit("eif-limit", cl::init(6), cl::Hidden, cl::desc("Size limit in Hexagon early if-conversion"))
#define I(x, y, z)
Definition MD5.cpp:57
This file contains the declaration of the ObjectStore class.
Defines llcas_functions_t, the table of function pointers that is populated by looking up the llcas_*...
struct llcas_cas_options_s * llcas_cas_options_t
#define LLCAS_VERSION_MAJOR
struct llcas_cas_s * llcas_cas_t
#define LLCAS_VERSION_MINOR
llcas_lookup_result_t
Return values for a load operation.
@ LLCAS_LOOKUP_RESULT_NOTFOUND
The object was not found.
@ LLCAS_LOOKUP_RESULT_SUCCESS
The object was found.
@ LLCAS_LOOKUP_RESULT_ERROR
An error occurred.
This file defines the scope_exit class, which executes user-defined cleanup logic at scope exit.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Error takeError()
Take ownership of the stored error.
Definition Error.h:612
const char * c_str()
void reserve(size_type N)
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
A cache from a key (that describes an action) to the result of performing that action.
Definition ActionCache.h:49
Context for CAS identifiers.
Definition CASID.h:28
Unique identifier for a CAS object.
Definition CASID.h:58
static CASID create(const CASContext *Context, StringRef Hash)
Create CASID from CASContext and raw hash bytes.
Definition CASID.h:117
virtual std::unique_ptr< MemoryBuffer > getStandaloneMemoryBufferImpl(ObjectHandle Node, StringRef Name, bool RequiresNullTerminator)
Customization point for getStandaloneMemoryBuffer().
virtual Error exportDataToFile(ObjectHandle Node, StringRef Path) const
Exports the data of an object to a file path.
virtual Expected< ObjectRef > storeFromFile(StringRef Path)
Stores the data of a file into ObjectStore.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
static LLVM_ABI DynamicLibrary getPermanentLibrary(const char *filename, std::string *errMsg=nullptr)
This function permanently loads the dynamic library at the given path using the library load operatio...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
LLVM_ABI Expected< std::pair< std::shared_ptr< ObjectStore >, std::shared_ptr< ActionCache > > > createPluginCASDatabases(StringRef PluginPath, StringRef OnDiskPath, ArrayRef< std::pair< std::string, std::string > > PluginArgs)
Create ObjectStore and ActionCache instances backed by a plugin that implements the C API in "llvm-c/...
initializer< Ty > init(const Ty &Val)
uint64_t getDataSize(const FuncRecordTy *Record)
Return the coverage map data size for the function.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
Definition Transport.h:139
NodeAddr< NodeBase * > Node
Definition RDFGraph.h:381
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition STLExtras.h:1669
scope_exit(Callable) -> scope_exit< Callable >
@ Store
The extracted value is stored (ExtractElement only).
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition Error.h:1321
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
@ Ref
The access may reference the value stored in memory.
Definition ModRef.h:32
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
StringRef toStringRef(bool B)
Construct a string ref from a boolean.
const void * data
Digest hash bytes.
const uint8_t * data
void(* string_dispose)(char *)
Definition PluginAPI.h:25
size_t(* object_refs_get_count)(llcas_cas_t, llcas_object_refs_t)
Definition PluginAPI.h:96
bool(* digest_print)(llcas_cas_t, llcas_digest_t, char **printed_id, char **error)
Definition PluginAPI.h:59
bool(* cas_options_set_option)(llcas_cas_options_t, const char *name, const char *value, char **error)
Definition PluginAPI.h:40
llcas_cas_options_t(* cas_options_create)(void)
Definition PluginAPI.h:31
llcas_object_refs_t(* loaded_object_get_refs)(llcas_cas_t, llcas_loaded_object_t)
Definition PluginAPI.h:88
void(* cas_options_set_ondisk_path)(llcas_cas_options_t, const char *path)
Definition PluginAPI.h:38
void(* cas_options_set_client_version)(llcas_cas_options_t, unsigned major, unsigned minor)
Definition PluginAPI.h:35
llcas_cas_t(* cas_create)(llcas_cas_options_t, char **error)
Definition PluginAPI.h:43
char *(* cas_get_hash_schema_name)(llcas_cas_t)
Definition PluginAPI.h:62
void(* cas_options_dispose)(llcas_cas_options_t)
Definition PluginAPI.h:33
llcas_objectid_t(* object_refs_get_id)(llcas_cas_t, llcas_object_refs_t, size_t index)
Definition PluginAPI.h:98