LLVM 22.0.0git
BuiltinUnifiedCASDatabases.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
10#include "BuiltinCAS.h"
13
14using namespace llvm;
15using namespace llvm::cas;
16
17Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>>
19 std::shared_ptr<ondisk::UnifiedOnDiskCache> UniDB;
20 if (Error E = builtin::createBuiltinUnifiedOnDiskCache(Path).moveInto(UniDB))
21 return std::move(E);
23 auto AC = builtin::createActionCacheFromUnifiedOnDiskCache(std::move(UniDB));
24 return std::make_pair(std::move(CAS), std::move(AC));
25}
26
28 StringRef Path, bool CheckHash, bool AllowRecovery, bool ForceValidation,
29 std::optional<StringRef> LLVMCasBinary) {
30#if LLVM_ENABLE_ONDISK_CAS
33 sizeof(builtin::HashType), CheckHash, AllowRecovery, ForceValidation,
34 LLVMCasBinary);
35#else
36 return createStringError(inconvertibleErrorCode(), "OnDiskCache is disabled");
37#endif
38}
This file contains the declaration of the ActionCache class, which is the base class for ActionCache ...
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
static StringRef getHashName()
Get the name of the hash for any table identifiers.
static Expected< ValidationResult > validateIfNeeded(StringRef Path, StringRef HashName, unsigned HashByteSize, bool CheckHash, bool AllowRecovery, bool ForceValidation, std::optional< StringRef > LLVMCasBinary)
Validate the data in Path, if needed to ensure correctness.
std::unique_ptr< ObjectStore > createObjectStoreFromUnifiedOnDiskCache(std::shared_ptr< ondisk::UnifiedOnDiskCache > UniDB)
decltype(HasherT::hash(std::declval< ArrayRef< uint8_t > & >())) HashType
std::unique_ptr< ActionCache > createActionCacheFromUnifiedOnDiskCache(std::shared_ptr< ondisk::UnifiedOnDiskCache > UniDB)
Expected< std::unique_ptr< ondisk::UnifiedOnDiskCache > > createBuiltinUnifiedOnDiskCache(StringRef Path)
Create a UnifiedOnDiskCache instance that uses BLAKE3 hashing.
Expected< std::pair< std::unique_ptr< ObjectStore >, std::unique_ptr< ActionCache > > > createOnDiskUnifiedCASDatabases(StringRef Path)
Create on-disk ObjectStore and ActionCache instances based on ondisk::UnifiedOnDiskCache,...
Expected< ValidationResult > validateOnDiskUnifiedCASDatabasesIfNeeded(StringRef Path, bool CheckHash, bool AllowRecovery, bool ForceValidation, std::optional< StringRef > LLVMCasBinaryPath)
Validate the data in Path, if needed to ensure correctness.
This is an optimization pass for GlobalISel generic memory operations.
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:98
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition Error.h:1305