68#define DEBUG_TYPE "on-disk-cas"
86 return ID.takeError();
89 "corrupt object '" +
toHex(*
ID) +
"'");
99 enum class StorageKind : uint8_t {
116 StandaloneLeaf0 = 12,
119 static StringRef getStandaloneFilePrefix(StorageKind SK) {
123 case TrieRecord::StorageKind::Standalone:
125 case TrieRecord::StorageKind::StandaloneLeaf:
127 case TrieRecord::StorageKind::StandaloneLeaf0:
132 enum Limits : int64_t {
134 MaxEmbeddedSize = 64LL * 1024LL - 1,
138 StorageKind SK = StorageKind::Unknown;
143 static uint64_t pack(Data
D) {
144 assert(
D.Offset.get() < (int64_t)(1ULL << 56));
145 uint64_t
Packed = uint64_t(
D.SK) << 56 |
D.Offset.get();
146 assert(
D.SK != StorageKind::Unknown || Packed == 0);
148 Data RoundTrip = unpack(Packed);
150 assert(
D.Offset.get() == RoundTrip.Offset.get());
156 static Data unpack(uint64_t Packed) {
160 D.SK = (StorageKind)(Packed >> 56);
165 TrieRecord() : Storage(0) {}
167 Data
load()
const {
return unpack(Storage); }
168 bool compare_exchange_strong(Data &Existing, Data New);
171 std::atomic<uint64_t> Storage;
181struct DataRecordHandle {
184 enum class NumRefsFlags : uint8_t {
194 enum class DataSizeFlags {
203 enum class RefKindFlags {
212 DataSizeShift = NumRefsShift + NumRefsBits,
214 RefKindShift = DataSizeShift + DataSizeBits,
217 static_assert(((UINT32_MAX << NumRefsBits) & (uint32_t)NumRefsFlags::Max) ==
220 static_assert(((UINT32_MAX << DataSizeBits) & (uint32_t)DataSizeFlags::Max) ==
223 static_assert(((UINT32_MAX << RefKindBits) & (uint32_t)RefKindFlags::Max) ==
229 NumRefsFlags NumRefs;
230 DataSizeFlags DataSize;
231 RefKindFlags RefKind;
233 static uint64_t pack(LayoutFlags LF) {
234 unsigned Packed = ((unsigned)LF.NumRefs << NumRefsShift) |
235 ((
unsigned)LF.DataSize << DataSizeShift) |
236 ((unsigned)LF.RefKind << RefKindShift);
238 LayoutFlags RoundTrip = unpack(Packed);
239 assert(LF.NumRefs == RoundTrip.NumRefs);
240 assert(LF.DataSize == RoundTrip.DataSize);
241 assert(LF.RefKind == RoundTrip.RefKind);
245 static LayoutFlags unpack(uint64_t Storage) {
246 assert(Storage <= UINT8_MAX &&
"Expect storage to fit in a byte");
249 (NumRefsFlags)((Storage >> NumRefsShift) & ((1U << NumRefsBits) - 1));
250 LF.DataSize = (DataSizeFlags)((Storage >> DataSizeShift) &
251 ((1U << DataSizeBits) - 1));
253 (RefKindFlags)((Storage >> RefKindShift) & ((1U << RefKindBits) - 1));
263 using PackTy = uint32_t;
266 static constexpr unsigned LayoutFlagsShift =
267 (
sizeof(PackTy) - 1) * CHAR_BIT;
271 InternalRefArrayRef Refs;
275 LayoutFlags getLayoutFlags()
const {
276 return LayoutFlags::unpack(H->Packed >> Header::LayoutFlagsShift);
280 void skipDataSize(LayoutFlags LF, int64_t &RelOffset)
const;
281 uint32_t getNumRefs()
const;
282 void skipNumRefs(LayoutFlags LF, int64_t &RelOffset)
const;
283 int64_t getRefsRelOffset()
const;
284 int64_t getDataRelOffset()
const;
286 static uint64_t getTotalSize(uint64_t DataRelOffset, uint64_t
DataSize) {
287 return DataRelOffset +
DataSize + 1;
289 uint64_t getTotalSize()
const {
296 explicit Layout(
const Input &
I);
299 uint64_t DataSize = 0;
300 uint32_t NumRefs = 0;
301 int64_t RefsRelOffset = 0;
302 int64_t DataRelOffset = 0;
303 uint64_t getTotalSize()
const {
304 return DataRecordHandle::getTotalSize(DataRelOffset, DataSize);
308 InternalRefArrayRef getRefs()
const {
309 assert(H &&
"Expected valid handle");
310 auto *BeginByte =
reinterpret_cast<const char *
>(H) + getRefsRelOffset();
311 size_t Size = getNumRefs();
313 return InternalRefArrayRef();
314 if (getLayoutFlags().RefKind == RefKindFlags::InternalRef4B)
315 return ArrayRef(
reinterpret_cast<const InternalRef4B *
>(BeginByte),
Size);
316 return ArrayRef(
reinterpret_cast<const InternalRef *
>(BeginByte),
Size);
319 ArrayRef<char> getData()
const {
320 assert(H &&
"Expected valid handle");
321 return ArrayRef(
reinterpret_cast<const char *
>(H) + getDataRelOffset(),
325 static DataRecordHandle create(function_ref<
char *(
size_t Size)>
Alloc,
327 static Expected<DataRecordHandle>
328 createWithError(function_ref<Expected<char *>(
size_t Size)>
Alloc,
330 static DataRecordHandle construct(
char *Mem,
const Input &
I);
332 static DataRecordHandle
get(
const char *Mem) {
333 return DataRecordHandle(
334 *
reinterpret_cast<const DataRecordHandle::Header *
>(Mem));
336 static Expected<DataRecordHandle>
337 getFromDataPool(
const OnDiskDataAllocator &Pool, FileOffset
Offset);
339 explicit operator bool()
const {
return H; }
340 const Header &getHeader()
const {
return *H; }
342 DataRecordHandle() =
default;
343 explicit DataRecordHandle(
const Header &H) : H(&H) {}
346 static DataRecordHandle constructImpl(
char *Mem,
const Input &
I,
348 const Header *H =
nullptr;
352struct OnDiskContent {
353 std::optional<DataRecordHandle> Record;
354 std::optional<ArrayRef<char>> Bytes;
358class StandaloneDataInMemory {
360 OnDiskContent getContent()
const;
362 StandaloneDataInMemory(std::unique_ptr<sys::fs::mapped_file_region> Region,
363 TrieRecord::StorageKind SK)
364 : Region(std::
move(Region)), SK(SK) {
366 bool IsStandalone =
false;
368 case TrieRecord::StorageKind::Standalone:
369 case TrieRecord::StorageKind::StandaloneLeaf:
370 case TrieRecord::StorageKind::StandaloneLeaf0:
381 std::unique_ptr<sys::fs::mapped_file_region> Region;
382 TrieRecord::StorageKind SK;
386template <
size_t NumShards>
class StandaloneDataMap {
387 static_assert(
isPowerOf2_64(NumShards),
"Expected power of 2");
390 uintptr_t insert(ArrayRef<uint8_t> Hash, TrieRecord::StorageKind SK,
391 std::unique_ptr<sys::fs::mapped_file_region> Region);
393 const StandaloneDataInMemory *
lookup(ArrayRef<uint8_t> Hash)
const;
394 bool count(ArrayRef<uint8_t> Hash)
const {
return bool(
lookup(Hash)); }
399 DenseMap<const uint8_t *, std::unique_ptr<StandaloneDataInMemory>> Map;
400 mutable std::mutex Mutex;
402 Shard &getShard(ArrayRef<uint8_t> Hash) {
403 return const_cast<Shard &
>(
404 const_cast<const StandaloneDataMap *
>(
this)->getShard(Hash));
406 const Shard &getShard(ArrayRef<uint8_t> Hash)
const {
407 static_assert(NumShards <= 256,
"Expected only 8 bits of shard");
408 return Shards[Hash[0] % NumShards];
411 Shard Shards[NumShards];
414using StandaloneDataMapTy = StandaloneDataMap<16>;
417class InternalRefVector {
419 void push_back(InternalRef
Ref) {
421 return FullRefs.push_back(
Ref);
423 return SmallRefs.push_back(*Small);
426 FullRefs.reserve(SmallRefs.size() + 1);
427 for (InternalRef4B Small : SmallRefs)
428 FullRefs.push_back(Small);
429 FullRefs.push_back(
Ref);
433 operator InternalRefArrayRef()
const {
434 assert(SmallRefs.empty() || FullRefs.empty());
435 return NeedsFull ? InternalRefArrayRef(FullRefs)
436 : InternalRefArrayRef(SmallRefs);
440 bool NeedsFull =
false;
450 if (Expected<char *> Mem =
Alloc(
L.getTotalSize()))
451 return constructImpl(*Mem,
I, L);
453 return Mem.takeError();
476uintptr_t StandaloneDataMap<N>::insert(
478 std::unique_ptr<sys::fs::mapped_file_region>
Region) {
479 auto &S = getShard(Hash);
480 std::lock_guard<std::mutex> Lock(S.Mutex);
481 auto &V = S.Map[Hash.
data()];
483 V = std::make_unique<StandaloneDataInMemory>(std::move(
Region), SK);
484 return reinterpret_cast<uintptr_t
>(V.get());
488const StandaloneDataInMemory *
490 auto &S = getShard(Hash);
491 std::lock_guard<std::mutex> Lock(S.Mutex);
492 auto I = S.Map.find(Hash.
data());
493 if (
I == S.Map.end())
507 TempFile(
StringRef Name,
int FD) : TmpName(
std::string(Name)), FD(FD) {}
512 TempFile(TempFile &&
Other) { *
this = std::move(
Other); }
513 TempFile &operator=(TempFile &&
Other) {
514 TmpName = std::move(
Other.TmpName);
528 Error keep(
const Twine &Name);
535class MappedTempFile {
537 char *
data()
const {
return Map.
data(); }
538 size_t size()
const {
return Map.
size(); }
541 assert(Map &&
"Map already destroyed");
543 return Temp.discard();
546 Error keep(
const Twine &Name) {
547 assert(Map &&
"Map already destroyed");
549 return Temp.keep(Name);
552 MappedTempFile(TempFile Temp, sys::fs::mapped_file_region Map)
557 sys::fs::mapped_file_region Map;
571 std::error_code RemoveEC;
605 TempFile Ret(ResultPath,
FD);
606 return std::move(Ret);
609bool TrieRecord::compare_exchange_strong(
Data &Existing,
Data New) {
610 uint64_t ExistingPacked = pack(Existing);
612 if (Storage.compare_exchange_strong(ExistingPacked, NewPacked))
614 Existing = unpack(ExistingPacked);
621 auto HeaderData = Pool.
get(
Offset,
sizeof(DataRecordHandle::Header));
623 return HeaderData.takeError();
625 auto Record = DataRecordHandle::get(HeaderData->data());
629 "data record span passed the end of the data pool");
634DataRecordHandle DataRecordHandle::constructImpl(
char *Mem,
const Input &
I,
636 char *
Next = Mem +
sizeof(Header);
639 Header::PackTy Packed = 0;
640 Packed |= LayoutFlags::pack(L.Flags) << Header::LayoutFlagsShift;
643 switch (L.Flags.DataSize) {
644 case DataSizeFlags::Uses1B:
645 assert(
I.Data.size() <= UINT8_MAX);
646 Packed |= (Header::PackTy)
I.Data.size()
647 << ((
sizeof(Packed) - 2) * CHAR_BIT);
649 case DataSizeFlags::Uses2B:
650 assert(
I.Data.size() <= UINT16_MAX);
651 Packed |= (Header::PackTy)
I.Data.size()
652 << ((
sizeof(Packed) - 4) * CHAR_BIT);
654 case DataSizeFlags::Uses4B:
658 case DataSizeFlags::Uses8B:
668 switch (L.Flags.NumRefs) {
669 case NumRefsFlags::Uses0B:
671 case NumRefsFlags::Uses1B:
672 assert(
I.Refs.size() <= UINT8_MAX);
673 Packed |= (Header::PackTy)
I.Refs.size()
674 << ((
sizeof(Packed) - 2) * CHAR_BIT);
676 case NumRefsFlags::Uses2B:
677 assert(
I.Refs.size() <= UINT16_MAX);
678 Packed |= (Header::PackTy)
I.Refs.size()
679 << ((
sizeof(Packed) - 4) * CHAR_BIT);
681 case NumRefsFlags::Uses4B:
685 case NumRefsFlags::Uses8B:
692 if (!
I.Refs.empty()) {
693 assert((
L.Flags.RefKind == RefKindFlags::InternalRef4B) ==
I.Refs.is4B());
694 ArrayRef<uint8_t> RefsBuffer =
I.Refs.getBuffer();
702 Next[
I.Data.size()] = 0;
705 Header *
H =
new (Mem) Header{
Packed};
706 DataRecordHandle Record(*
H);
707 assert(Record.getData() ==
I.Data);
708 assert(Record.getNumRefs() ==
I.Refs.size());
709 assert(Record.getRefs() ==
I.Refs);
710 assert(Record.getLayoutFlags().DataSize ==
L.Flags.DataSize);
711 assert(Record.getLayoutFlags().NumRefs ==
L.Flags.NumRefs);
712 assert(Record.getLayoutFlags().RefKind ==
L.Flags.RefKind);
716DataRecordHandle::Layout::Layout(
const Input &
I) {
718 uint64_t RelOffset =
sizeof(Header);
722 NumRefs =
I.Refs.size();
726 I.Refs.is4B() ? RefKindFlags::InternalRef4B : RefKindFlags::InternalRef;
731 if (
DataSize <= UINT8_MAX && Has1B) {
732 Flags.DataSize = DataSizeFlags::Uses1B;
734 }
else if (
DataSize <= UINT16_MAX && Has2B) {
735 Flags.DataSize = DataSizeFlags::Uses2B;
737 }
else if (
DataSize <= UINT32_MAX) {
738 Flags.DataSize = DataSizeFlags::Uses4B;
741 Flags.DataSize = DataSizeFlags::Uses8B;
747 Flags.NumRefs = NumRefsFlags::Uses0B;
748 }
else if (NumRefs <= UINT8_MAX && Has1B) {
749 Flags.NumRefs = NumRefsFlags::Uses1B;
751 }
else if (NumRefs <= UINT16_MAX && Has2B) {
752 Flags.NumRefs = NumRefsFlags::Uses2B;
755 Flags.NumRefs = NumRefsFlags::Uses4B;
766 auto GrowSizeFieldsBy4B = [&]() {
770 assert(Flags.NumRefs != NumRefsFlags::Uses8B &&
771 "Expected to be able to grow NumRefs8B");
777 if (Flags.DataSize < DataSizeFlags::Uses4B)
778 Flags.DataSize = DataSizeFlags::Uses4B;
779 else if (Flags.DataSize < DataSizeFlags::Uses8B)
780 Flags.DataSize = DataSizeFlags::Uses8B;
781 else if (Flags.NumRefs < NumRefsFlags::Uses4B)
782 Flags.NumRefs = NumRefsFlags::Uses4B;
784 Flags.NumRefs = NumRefsFlags::Uses8B;
788 if (Flags.RefKind == RefKindFlags::InternalRef) {
792 GrowSizeFieldsBy4B();
795 RefsRelOffset = RelOffset;
796 RelOffset += 8 * NumRefs;
804 uint64_t RefListSize = 4 * NumRefs;
806 GrowSizeFieldsBy4B();
807 RefsRelOffset = RelOffset;
808 RelOffset += RefListSize;
812 DataRelOffset = RelOffset;
815uint64_t DataRecordHandle::getDataSize()
const {
816 int64_t RelOffset =
sizeof(Header);
817 auto *DataSizePtr =
reinterpret_cast<const char *
>(
H) + RelOffset;
818 switch (getLayoutFlags().
DataSize) {
819 case DataSizeFlags::Uses1B:
820 return (
H->Packed >> ((
sizeof(Header::PackTy) - 2) * CHAR_BIT)) & UINT8_MAX;
821 case DataSizeFlags::Uses2B:
822 return (
H->Packed >> ((
sizeof(Header::PackTy) - 4) * CHAR_BIT)) &
824 case DataSizeFlags::Uses4B:
826 case DataSizeFlags::Uses8B:
832void DataRecordHandle::skipDataSize(LayoutFlags LF, int64_t &RelOffset)
const {
833 if (LF.DataSize >= DataSizeFlags::Uses4B)
835 if (LF.DataSize >= DataSizeFlags::Uses8B)
839uint32_t DataRecordHandle::getNumRefs()
const {
840 LayoutFlags LF = getLayoutFlags();
841 int64_t RelOffset =
sizeof(Header);
842 skipDataSize(LF, RelOffset);
843 auto *NumRefsPtr =
reinterpret_cast<const char *
>(
H) + RelOffset;
844 switch (LF.NumRefs) {
845 case NumRefsFlags::Uses0B:
847 case NumRefsFlags::Uses1B:
848 return (
H->Packed >> ((
sizeof(Header::PackTy) - 2) * CHAR_BIT)) & UINT8_MAX;
849 case NumRefsFlags::Uses2B:
850 return (
H->Packed >> ((
sizeof(Header::PackTy) - 4) * CHAR_BIT)) &
852 case NumRefsFlags::Uses4B:
854 case NumRefsFlags::Uses8B:
860void DataRecordHandle::skipNumRefs(LayoutFlags LF, int64_t &RelOffset)
const {
861 if (LF.NumRefs >= NumRefsFlags::Uses4B)
863 if (LF.NumRefs >= NumRefsFlags::Uses8B)
867int64_t DataRecordHandle::getRefsRelOffset()
const {
868 LayoutFlags LF = getLayoutFlags();
869 int64_t RelOffset =
sizeof(Header);
870 skipDataSize(LF, RelOffset);
871 skipNumRefs(LF, RelOffset);
875int64_t DataRecordHandle::getDataRelOffset()
const {
876 LayoutFlags LF = getLayoutFlags();
877 int64_t RelOffset =
sizeof(Header);
878 skipDataSize(LF, RelOffset);
879 skipNumRefs(LF, RelOffset);
880 uint32_t RefSize = LF.RefKind == RefKindFlags::InternalRef4B ? 4 : 8;
881 RelOffset += RefSize * getNumRefs();
887 if (
auto E = UpstreamDB->validate(Deep, Hasher))
893 auto formatError = [&](
Twine Msg) {
901 if (
Record.Data.size() !=
sizeof(TrieRecord))
902 return formatError(
"wrong data record size");
904 return formatError(
"wrong data record alignment");
906 auto *R =
reinterpret_cast<const TrieRecord *
>(
Record.Data.data());
907 TrieRecord::Data
D = R->load();
908 std::unique_ptr<MemoryBuffer> FileBuffer;
914 return formatError(
"invalid record kind value");
917 auto I = getIndexProxyFromRef(
Ref);
919 return I.takeError();
922 case TrieRecord::StorageKind::Unknown:
927 case TrieRecord::StorageKind::DataPool:
930 if (
D.Offset.get() <= 0 ||
931 D.Offset.get() +
sizeof(DataRecordHandle::Header) >= DataPool.size())
932 return formatError(
"datapool record out of bound");
934 case TrieRecord::StorageKind::Standalone:
935 case TrieRecord::StorageKind::StandaloneLeaf:
936 case TrieRecord::StorageKind::StandaloneLeaf0:
938 getStandalonePath(TrieRecord::getStandaloneFilePrefix(
D.SK), *
I, Path);
945 return formatError(
"record file \'" + Path +
"\' does not exist");
947 FileBuffer = std::move(*File);
949 return formatError(
"record file \'" + Path +
"\' does not exist");
955 auto dataError = [&](
Twine Msg) {
957 "bad data for digest \'" +
toHex(
I->Hash) +
964 case TrieRecord::StorageKind::Unknown:
966 case TrieRecord::StorageKind::DataPool: {
967 auto DataRecord = DataRecordHandle::getFromDataPool(DataPool,
D.Offset);
969 return dataError(
toString(DataRecord.takeError()));
971 for (
auto InternRef : DataRecord->getRefs()) {
972 auto Index = getIndexProxyFromRef(InternRef);
974 return Index.takeError();
977 StoredData = DataRecord->getData();
980 case TrieRecord::StorageKind::Standalone: {
981 if (FileBuffer->getBufferSize() <
sizeof(DataRecordHandle::Header))
982 return dataError(
"data record is not big enough to read the header");
983 auto DataRecord = DataRecordHandle::get(FileBuffer->getBufferStart());
984 if (DataRecord.getTotalSize() < FileBuffer->getBufferSize())
986 "data record span passed the end of the standalone file");
987 for (
auto InternRef : DataRecord.getRefs()) {
988 auto Index = getIndexProxyFromRef(InternRef);
990 return Index.takeError();
993 StoredData = DataRecord.getData();
996 case TrieRecord::StorageKind::StandaloneLeaf:
997 case TrieRecord::StorageKind::StandaloneLeaf0: {
999 if (
D.SK == TrieRecord::StorageKind::StandaloneLeaf0) {
1000 if (!FileBuffer->getBuffer().ends_with(
'\0'))
1001 return dataError(
"standalone file is not zero terminated");
1009 Hasher(Refs, StoredData, ComputedHash);
1011 return dataError(
"hash mismatch, got \'" +
toHex(ComputedHash) +
1019 OS <<
"on-disk-root-path: " << RootPath <<
"\n";
1031 auto *R =
reinterpret_cast<const TrieRecord *
>(
Data.data());
1032 TrieRecord::Data
D = R->load();
1035 case TrieRecord::StorageKind::Unknown:
1038 case TrieRecord::StorageKind::DataPool:
1042 case TrieRecord::StorageKind::Standalone:
1043 OS <<
"standalone-data ";
1045 case TrieRecord::StorageKind::StandaloneLeaf:
1046 OS <<
"standalone-leaf ";
1048 case TrieRecord::StorageKind::StandaloneLeaf0:
1049 OS <<
"standalone-leaf+0";
1052 OS <<
" Offset=" << (
void *)
D.Offset.get();
1060 Pool, [](PoolInfo LHS, PoolInfo RHS) {
return LHS.Offset < RHS.Offset; });
1061 for (PoolInfo PI : Pool) {
1062 OS <<
"- addr=" << (
void *)PI.Offset <<
" ";
1063 auto D = DataRecordHandle::getFromDataPool(DataPool,
FileOffset(PI.Offset));
1065 OS <<
"error: " <<
toString(
D.takeError());
1069 OS <<
"record refs=" <<
D->getNumRefs() <<
" data=" <<
D->getDataSize()
1070 <<
" size=" <<
D->getTotalSize()
1071 <<
" end=" << (
void *)(PI.Offset +
D->getTotalSize()) <<
"\n";
1077 auto P = Index.insertLazy(
1083 new (TentativeValue.
Data.
data()) TrieRecord();
1086 return P.takeError();
1088 assert(*
P &&
"Expected insertion");
1089 return getIndexProxyFromPointer(*
P);
1096 return IndexProxy{
P.getOffset(),
P->Hash,
1097 *
const_cast<TrieRecord *
>(
1098 reinterpret_cast<const TrieRecord *
>(
P->Data.data()))};
1102 auto I = indexHash(Hash);
1104 return I.takeError();
1105 return getExternalReference(*
I);
1108ObjectID OnDiskGraphDB::getExternalReference(
const IndexProxy &
I) {
1109 return getExternalReference(makeInternalRef(
I.Offset));
1112std::optional<ObjectID>
1114 bool CheckUpstream) {
1116 [&](std::optional<IndexProxy>
I) -> std::optional<ObjectID> {
1117 if (!CheckUpstream || !UpstreamDB)
1118 return std::nullopt;
1119 std::optional<ObjectID> UpstreamID =
1120 UpstreamDB->getExistingReference(Digest);
1122 return std::nullopt;
1125 return std::nullopt;
1128 return getExternalReference(*
I);
1133 return tryUpstream(std::nullopt);
1135 TrieRecord::Data Obj =
I.Ref.load();
1136 if (Obj.SK == TrieRecord::StorageKind::Unknown)
1137 return tryUpstream(
I);
1138 return getExternalReference(makeInternalRef(
I.Offset));
1143 auto P = Index.recoverFromFileOffset(
Ref.getFileOffset());
1145 return P.takeError();
1146 return getIndexProxyFromPointer(*
P);
1150 auto I = getIndexProxyFromRef(
Ref);
1152 return I.takeError();
1166 reinterpret_cast<const StandaloneDataInMemory *
>(
Data & (-1ULL << 1));
1167 return SDIM->getContent();
1172 assert(DataHandle.getData().end()[0] == 0 &&
"Null termination");
1173 return OnDiskContent{DataHandle, std::nullopt};
1179 return *Content.Bytes;
1180 assert(Content.Record &&
"Expected record or bytes");
1181 return Content.Record->getData();
1185 if (std::optional<DataRecordHandle>
Record =
1187 return Record->getRefs();
1188 return std::nullopt;
1194 auto I = getIndexProxyFromRef(
Ref);
1196 return I.takeError();
1197 TrieRecord::Data Object =
I->Ref.load();
1199 if (Object.SK == TrieRecord::StorageKind::Unknown)
1200 return faultInFromUpstream(ExternalRef);
1202 if (Object.SK == TrieRecord::StorageKind::DataPool)
1212 switch (Object.SK) {
1213 case TrieRecord::StorageKind::Unknown:
1214 case TrieRecord::StorageKind::DataPool:
1216 case TrieRecord::StorageKind::Standalone:
1217 case TrieRecord::StorageKind::StandaloneLeaf0:
1218 case TrieRecord::StorageKind::StandaloneLeaf:
1228 getStandalonePath(TrieRecord::getStandaloneFilePrefix(Object.SK), *
I, Path);
1243 auto Region = std::make_unique<sys::fs::mapped_file_region>(
1249 static_cast<StandaloneDataMapTy *
>(StandaloneData)
1250 ->insert(
I->Hash, Object.SK, std::move(
Region)));
1254 auto Presence = getObjectPresence(
Ref,
true);
1256 return Presence.takeError();
1258 switch (*Presence) {
1259 case ObjectPresence::Missing:
1261 case ObjectPresence::InPrimaryDB:
1263 case ObjectPresence::OnlyInUpstreamDB:
1264 if (
auto FaultInResult = faultInFromUpstream(
Ref); !FaultInResult)
1265 return FaultInResult.takeError();
1272OnDiskGraphDB::getObjectPresence(
ObjectID ExternalRef,
1273 bool CheckUpstream)
const {
1275 auto I = getIndexProxyFromRef(
Ref);
1277 return I.takeError();
1279 TrieRecord::Data Object =
I->Ref.load();
1280 if (Object.SK != TrieRecord::StorageKind::Unknown)
1281 return ObjectPresence::InPrimaryDB;
1283 if (!CheckUpstream || !UpstreamDB)
1284 return ObjectPresence::Missing;
1286 std::optional<ObjectID> UpstreamID =
1287 UpstreamDB->getExistingReference(getDigest(*
I));
1288 return UpstreamID.has_value() ? ObjectPresence::OnlyInUpstreamDB
1289 : ObjectPresence::Missing;
1296void OnDiskGraphDB::getStandalonePath(
StringRef Prefix,
const IndexProxy &
I,
1298 Path.assign(RootPath.begin(), RootPath.end());
1303OnDiskContent StandaloneDataInMemory::getContent()
const {
1309 case TrieRecord::StorageKind::Standalone:
1311 case TrieRecord::StorageKind::StandaloneLeaf0:
1312 Leaf = Leaf0 =
true;
1314 case TrieRecord::StorageKind::StandaloneLeaf:
1321 assert(
Data.drop_back(Leaf0).end()[0] == 0 &&
1322 "Standalone node data missing null termination");
1323 return OnDiskContent{std::nullopt,
1327 DataRecordHandle Record = DataRecordHandle::get(
Region->data());
1328 assert(Record.getData().end()[0] == 0 &&
1329 "Standalone object record missing null termination for data");
1330 return OnDiskContent{Record, std::nullopt};
1337 assert(
Size &&
"Unexpected request for an empty temp file");
1340 return File.takeError();
1354 return MappedTempFile(std::move(*File), std::move(Map));
1362Error OnDiskGraphDB::createStandaloneLeaf(IndexProxy &
I, ArrayRef<char>
Data) {
1363 assert(
Data.size() > TrieRecord::MaxEmbeddedSize &&
1364 "Expected a bigger file for external content...");
1367 TrieRecord::StorageKind SK = Leaf0 ? TrieRecord::StorageKind::StandaloneLeaf0
1368 : TrieRecord::StorageKind::StandaloneLeaf;
1370 SmallString<256>
Path;
1371 int64_t FileSize =
Data.size() + Leaf0;
1372 getStandalonePath(TrieRecord::getStandaloneFilePrefix(SK),
I, Path);
1380 return File.takeError();
1390 TrieRecord::Data Existing;
1392 TrieRecord::Data Leaf{SK, FileOffset()};
1393 if (
I.Ref.compare_exchange_strong(Existing, Leaf)) {
1394 recordStandaloneSizeIncrease(FileSize);
1400 if (Existing.SK == TrieRecord::StorageKind::Unknown)
1408 auto I = getIndexProxyFromRef(getInternalRef(
ID));
1410 return I.takeError();
1414 TrieRecord::Data Existing =
I->Ref.load();
1415 if (Existing.SK != TrieRecord::StorageKind::Unknown)
1420 if (Refs.
empty() &&
Data.size() > TrieRecord::MaxEmbeddedSize)
1421 return createStandaloneLeaf(*
I,
Data);
1426 InternalRefVector InternalRefs;
1428 InternalRefs.push_back(getInternalRef(
Ref));
1432 DataRecordHandle::Input
Input{InternalRefs,
Data};
1435 TrieRecord::StorageKind SK = TrieRecord::StorageKind::Unknown;
1438 std::optional<MappedTempFile> File;
1439 std::optional<uint64_t> FileSize;
1441 getStandalonePath(TrieRecord::getStandaloneFilePrefix(
1442 TrieRecord::StorageKind::Standalone),
1445 return std::move(E);
1448 SK = TrieRecord::StorageKind::Standalone;
1449 return File->data();
1452 if (
Size <= TrieRecord::MaxEmbeddedSize) {
1453 SK = TrieRecord::StorageKind::DataPool;
1454 auto P = DataPool.allocate(
Size);
1456 char *NewAlloc =
nullptr;
1458 P.takeError(), [&](std::unique_ptr<StringError> E) ->
Error {
1459 if (E->convertToErrorCode() == std::errc::not_enough_memory)
1460 return AllocStandaloneFile(Size).moveInto(NewAlloc);
1461 return Error(std::move(E));
1465 return std::move(NewE);
1467 PoolOffset =
P->getOffset();
1469 dbgs() <<
"pool-alloc addr=" << (
void *)PoolOffset.
get()
1471 <<
" end=" << (
void *)(PoolOffset.
get() +
Size) <<
"\n";
1473 return (*P)->data();
1475 return AllocStandaloneFile(
Size);
1482 assert(
Record.getData().end()[0] == 0 &&
"Expected null-termination");
1484 assert(SK != TrieRecord::StorageKind::Unknown);
1485 assert(
bool(File) !=
bool(PoolOffset) &&
1486 "Expected either a mapped file or a pooled offset");
1492 TrieRecord::Data Existing =
I->Ref.load();
1494 TrieRecord::Data NewObject{SK, PoolOffset};
1496 if (Existing.SK == TrieRecord::StorageKind::Unknown) {
1498 if (
Error E = File->keep(Path))
1510 if (Existing.SK == TrieRecord::StorageKind::Unknown) {
1511 if (
I->Ref.compare_exchange_strong(Existing, NewObject)) {
1513 recordStandaloneSizeIncrease(*FileSize);
1519 if (Existing.SK == TrieRecord::StorageKind::Unknown)
1526void OnDiskGraphDB::recordStandaloneSizeIncrease(
size_t SizeIncrease) {
1527 standaloneStorageSize().fetch_add(SizeIncrease, std::memory_order_relaxed);
1530std::atomic<uint64_t> &OnDiskGraphDB::standaloneStorageSize()
const {
1532 assert(UserHeader.
size() ==
sizeof(std::atomic<uint64_t>));
1534 return *
reinterpret_cast<std::atomic<uint64_t> *
>(UserHeader.
data());
1537uint64_t OnDiskGraphDB::getStandaloneStorageSize()
const {
1538 return standaloneStorageSize().load(std::memory_order_relaxed);
1542 return Index.size() + DataPool.size() + getStandaloneStorageSize();
1546 unsigned IndexPercent = Index.size() * 100ULL / Index.capacity();
1547 unsigned DataPercent = DataPool.size() * 100ULL / DataPool.capacity();
1548 return std::max(IndexPercent, DataPercent);
1553 unsigned HashByteSize, OnDiskGraphDB *UpstreamDB,
1558 constexpr uint64_t MB = 1024ull * 1024ull;
1559 constexpr uint64_t GB = 1024ull * 1024ull * 1024ull;
1562 uint64_t MaxDataPoolSize = 24 * GB;
1565 MaxIndexSize = 1 * GB;
1566 MaxDataPoolSize = 2 * GB;
1571 return CustomSize.takeError();
1573 MaxIndexSize = MaxDataPoolSize = **CustomSize;
1577 std::optional<OnDiskTrieRawHashMap> Index;
1580 HashByteSize * CHAR_BIT,
1581 sizeof(TrieRecord), MaxIndexSize,
1584 return std::move(E);
1586 uint32_t UserHeaderSize =
sizeof(std::atomic<uint64_t>);
1590 std::optional<OnDiskDataAllocator> DataPool;
1596 MaxDataPoolSize, MB, UserHeaderSize,
1597 [](
void *UserHeaderPtr) {
1598 new (UserHeaderPtr) std::atomic<uint64_t>(0);
1600 .moveInto(DataPool))
1601 return std::move(E);
1602 if (DataPool->getUserHeader().size() != UserHeaderSize)
1604 "unexpected user header in '" + DataPoolPath +
1607 return std::unique_ptr<OnDiskGraphDB>(
new OnDiskGraphDB(
1608 AbsPath, std::move(*Index), std::move(*DataPool), UpstreamDB, Policy));
1615 RootPath(RootPath.str()), UpstreamDB(UpstreamDB), FIPolicy(Policy) {
1625 StandaloneData =
new StandaloneDataMapTy();
1629 delete static_cast<StandaloneDataMapTy *
>(StandaloneData);
1638 struct UpstreamCursor {
1655 auto enqueueNode = [&](
ObjectID PrimaryID, std::optional<ObjectHandle>
Node) {
1664 enqueueNode(PrimaryID, UpstreamNode);
1666 while (!CursorStack.
empty()) {
1667 UpstreamCursor &Cur = CursorStack.
back();
1668 if (Cur.RefI == Cur.RefE) {
1675 assert(PrimaryNodesStack.
size() >= Cur.RefsCount + 1);
1676 ObjectID PrimaryID = *(PrimaryNodesStack.
end() - Cur.RefsCount - 1);
1677 auto PrimaryRefs =
ArrayRef(PrimaryNodesStack)
1678 .slice(PrimaryNodesStack.
size() - Cur.RefsCount);
1683 PrimaryNodesStack.
truncate(PrimaryNodesStack.
size() - Cur.RefsCount);
1688 ObjectID UpstreamID = *(Cur.RefI++);
1689 auto PrimaryID =
getReference(UpstreamDB->getDigest(UpstreamID));
1691 return PrimaryID.takeError();
1696 enqueueNode(*PrimaryID, std::nullopt);
1699 Expected<std::optional<ObjectHandle>> UpstreamNode =
1700 UpstreamDB->load(UpstreamID);
1703 enqueueNode(*PrimaryID, *UpstreamNode);
1718 auto Data = UpstreamDB->getObjectData(UpstreamNode);
1719 auto UpstreamRefs = UpstreamDB->getObjectRefs(UpstreamNode);
1722 for (ObjectID UpstreamRef : UpstreamRefs) {
1725 return Ref.takeError();
1732Expected<std::optional<ObjectHandle>>
1733OnDiskGraphDB::faultInFromUpstream(
ObjectID PrimaryID) {
1735 return std::nullopt;
1737 auto UpstreamID = UpstreamDB->getReference(
getDigest(PrimaryID));
1739 return UpstreamID.takeError();
1741 Expected<std::optional<ObjectHandle>> UpstreamNode =
1742 UpstreamDB->load(*UpstreamID);
1746 return std::nullopt;
1749 ? importSingleNode(PrimaryID, **UpstreamNode)
1750 : importFullTree(PrimaryID, **UpstreamNode))
1751 return std::move(
E);
1752 return load(PrimaryID);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Mark last scratch load
AMDGPU Prepare AGPR Alloc
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_UNLIKELY(EXPR)
This file defines the DenseMap class.
static cl::opt< int > PageSize("imp-null-check-page-size", cl::desc("The page size of the target in bytes"), cl::init(4096), cl::Hidden)
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
This file declares interface for OnDiskDataAllocator, a file backed data pool can be used to allocate...
static constexpr StringLiteral FilePrefixLeaf0
static constexpr StringLiteral DataPoolTableName
static constexpr StringLiteral FilePrefixObject
static constexpr StringLiteral FilePrefixLeaf
static constexpr StringLiteral IndexFilePrefix
static OnDiskContent getContentFromHandle(const OnDiskDataAllocator &DataPool, ObjectHandle OH)
static constexpr StringLiteral DataPoolFilePrefix
static Error createCorruptObjectError(Expected< ArrayRef< uint8_t > > ID)
static size_t getPageSize()
static Expected< MappedTempFile > createTempFile(StringRef FinalPath, uint64_t Size)
static constexpr StringLiteral IndexTableName
This declares OnDiskGraphDB, an ondisk CAS database with a fixed length hash.
This file declares interface for OnDiskTrieRawHashMap, a thread-safe and (mostly) lock-free hash map ...
Provides a library for accessing information about this process and other processes on the operating ...
This file defines the make_scope_exit function, which executes user-defined cleanup logic at scope ex...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
bool empty() const
empty - Check if the array is empty.
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 > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
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.
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...
FileOffset is a wrapper around uint64_t to represent the offset of data from the beginning of the fil...
Handle to a loaded object in a ObjectStore instance.
LLVM_ABI_FOR_TEST Expected< ArrayRef< char > > get(FileOffset Offset, size_t Size) const
Get the data of Size stored at the given Offset.
static LLVM_ABI_FOR_TEST Expected< OnDiskDataAllocator > create(const Twine &Path, const Twine &TableName, uint64_t MaxFileSize, std::optional< uint64_t > NewFileInitialSize, uint32_t UserHeaderSize=0, function_ref< void(void *)> UserHeaderInit=nullptr)
LLVM_ABI_FOR_TEST size_t size() const
OnDiskTrieRawHashMap is a persistent trie data structure used as hash maps.
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 std::optional< InternalRef4B > tryToShrink(InternalRef Ref)
Shrink to 4B reference.
Array of internal node references.
Standard 8 byte reference inside OnDiskGraphDB.
static InternalRef getFromOffset(FileOffset Offset)
Handle for a loaded node object.
static ObjectHandle fromFileOffset(FileOffset Offset)
static ObjectHandle fromMemory(uintptr_t Ptr)
ObjectHandle(uint64_t Opaque)
On-disk CAS nodes database, independent of a particular hashing algorithm.
FaultInPolicy
How to fault-in nodes if an upstream database is used.
@ SingleNode
Copy only the requested node.
void print(raw_ostream &OS) const
LLVM_ABI_FOR_TEST Expected< std::optional< ObjectHandle > > load(ObjectID Ref)
Expected< bool > isMaterialized(ObjectID Ref)
Check whether the object associated with Ref is stored in the CAS.
Error validate(bool Deep, HashingFuncT Hasher) const
Validate the OnDiskGraphDB.
object_refs_range getObjectRefs(ObjectHandle Node) const
unsigned getHardStorageLimitUtilization() const
LLVM_ABI_FOR_TEST Error store(ObjectID ID, ArrayRef< ObjectID > Refs, ArrayRef< char > Data)
Associate data & references with a particular object ID.
ArrayRef< uint8_t > getDigest(ObjectID Ref) const
static LLVM_ABI_FOR_TEST Expected< std::unique_ptr< OnDiskGraphDB > > open(StringRef Path, StringRef HashName, unsigned HashByteSize, OnDiskGraphDB *UpstreamDB=nullptr, FaultInPolicy Policy=FaultInPolicy::FullTree)
Open the on-disk store from a directory.
LLVM_ABI_FOR_TEST size_t getStorageSize() const
bool containsObject(ObjectID Ref, bool CheckUpstream=true) const
Check whether the object associated with Ref is stored in the CAS.
LLVM_ABI_FOR_TEST ~OnDiskGraphDB()
LLVM_ABI_FOR_TEST Expected< ObjectID > getReference(ArrayRef< uint8_t > Hash)
Form a reference for the provided hash.
function_ref< void( ArrayRef< ArrayRef< uint8_t > >, ArrayRef< char >, SmallVectorImpl< uint8_t > &)> HashingFuncT
Hashing function type for validation.
LLVM_ABI_FOR_TEST ArrayRef< char > getObjectData(ObjectHandle Node) const
LLVM_ABI_FOR_TEST std::optional< ObjectID > getExistingReference(ArrayRef< uint8_t > Digest, bool CheckUpstream=true)
Get an existing reference to the object Digest.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
static unsigned getPageSizeEstimate()
Get the process's estimated page size.
LLVM_ABI Error keep(const Twine &Name)
static LLVM_ABI Expected< TempFile > create(const Twine &Model, unsigned Mode=all_read|all_write, OpenFlags ExtraFlags=OF_None)
This creates a temporary file with createUniqueFile and schedules it for deletion with sys::RemoveFil...
Represents the result of a call to sys::fs::status().
This class represents a memory mapped file.
LLVM_ABI size_t size() const
@ readonly
May only access map via const_data as read only.
@ readwrite
May access map via data and modify it. Written to path.
LLVM_ABI char * data() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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...
Expected< size_t > preallocateFileTail(int FD, size_t CurrentSize, size_t NewSize)
Allocate space for the file FD on disk, if the filesystem supports it.
bool useSmallMappingSize(const Twine &Path)
Whether to use a small file mapping for ondisk databases created in Path.
uint64_t getDataSize(const FuncRecordTy *Record)
Return the coverage map data size for the function.
uint64_t read64le(const void *P)
void write64le(void *P, uint64_t V)
void write32le(void *P, uint32_t V)
uint32_t read32le(const void *P)
LLVM_ABI std::error_code closeFile(file_t &F)
Close the file object.
LLVM_ABI std::error_code rename(const Twine &from, const Twine &to)
Rename from to to.
std::error_code resize_file_before_mapping_readwrite(int FD, uint64_t Size)
Resize FD to Size before mapping mapped_file_region::readwrite.
LLVM_ABI bool exists(const basic_file_status &status)
Does file exist?
LLVM_ABI std::error_code createUniqueFile(const Twine &Model, int &ResultFD, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None, unsigned Mode=all_read|all_write)
Create a uniquely named file.
LLVM_ABI std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
LLVM_ABI Expected< file_t > openNativeFileForRead(const Twine &Name, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)
Opens the file with the given name in a read-only mode, returning its open file descriptor.
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 file_t convertFDToNativeFile(int FD)
Converts from a Posix file descriptor number to a native file handle.
LLVM_ABI std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
ScopedSetting scopedDisable()
This is an optimization pass for GlobalISel generic memory operations.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
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.
ArrayRef< CharT > arrayRefFromStringRef(StringRef Input)
Construct a string ref from an array ref of unsigned chars.
std::error_code make_error_code(BitcodeError E)
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
Error handleErrors(Error E, HandlerTs &&... Hs)
Pass the ErrorInfo(s) contained in E to their respective handlers.
FunctionAddr VTableAddr uintptr_t uintptr_t DataSize
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
std::optional< T > expectedToOptional(Expected< T > &&E)
Convert an Expected to an Optional without doing anything.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
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.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
auto make_scope_exit(Callable &&F)
FunctionAddr VTableAddr Next
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
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)
OutputIt copy(R &&Range, OutputIt Out)
void toHex(ArrayRef< uint8_t > Input, bool LowerCase, SmallVectorImpl< char > &Output)
Convert buffer Input to its hexadecimal representation. The returned string is double the size of Inp...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
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.
bool isAddrAligned(Align Lhs, const void *Addr)
Checks that Addr is a multiple of the alignment.
Implement std::hash so that hash_code can be used in STL containers.
Proxy for an on-disk index record.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static constexpr Align Of()
Allow constructions of constexpr Align from types.
Const value proxy to access the records stored in TrieRawHashMap.
Value proxy to access the records stored in TrieRawHashMap.
MutableArrayRef< char > Data