LLVM: lib/CAS/DatabaseFile.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

14

15using namespace llvm;

18

22 Path + "[" + TableName + "]: " + Msg);

23}

24

30 "mismatched " + Label +

32 ", observed: " + Twine(Observed) + ")");

33}

34

38

40 if (Alloc.capacity() <

43 Path.str(), "datafile",

44 "Allocator too small for header");

46 DatabaseFile DB(Alloc);

47 return NewDBConstructor(DB);

48 };

49

50

53 NewFileConstructor)

54 .moveInto(Alloc))

55 return std::move(E);

56

57 return DatabaseFile::get(

58 std::make_unique(std::move(Alloc)));

59}

60

64 int64_t ExistingRootOffset = 0;

65 const int64_t NewOffset =

67 if (H->RootTableOffset.compare_exchange_strong(ExistingRootOffset, NewOffset))

69

70

71 if (ExistingRootOffset == NewOffset)

73

74

79 "collision with existing table of the same name '" + Table.getName() +

80 "'");

81

83 "cannot add new table '" + Table.getName() +

84 "'"

85 " to existing root '" +

87}

88

90 int64_t RootTableOffset = H->RootTableOffset.load();

91 if (!RootTableOffset)

92 return std::nullopt;

93

95 if (Root.getName() == Name)

96 return Root;

97

98 return std::nullopt;

99}

100

102 if (Region.size() < sizeof(Header))

104 "database: missing header");

105

106

107 auto *H = reinterpret_cast<Header *>(Region.data());

110 "database: bad magic");

113 "database: wrong version");

114

116 sizeof(Header));

117

118 if (MFH->BumpPtr.load() < (int64_t)sizeof(Header))

120 "database: corrupt bump-ptr");

121

123}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file declares the common interface for a DatabaseFile that is used to implement OnDiskCAS.

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.

StringRef - Represent a constant reference to a string, i.e.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

Allocator for an owned mapped file region that supports thread-safe and process-safe bump pointer all...

static LLVM_ABI_FOR_TEST Expected< MappedFileRegionArena > create(const Twine &Path, uint64_t Capacity, uint64_t HeaderOffset, function_ref< Error(MappedFileRegionArena &)> NewFileConstructor)

Create a MappedFileRegionArena.

static Expected< DatabaseFile > create(const Twine &Path, uint64_t Capacity, function_ref< Error(DatabaseFile &)> NewDBConstructor)

Create the DatabaseFile at Path with Capacity.

Definition DatabaseFile.cpp:36

std::optional< TableHandle > findTable(StringRef Name)

Find a table. May return null.

Definition DatabaseFile.cpp:89

static constexpr uint32_t getVersion()

static constexpr uint32_t getMagic()

MappedFileRegion & getRegion()

Error addTable(TableHandle Table)

Add a table.

Definition DatabaseFile.cpp:61

Generic handle for a table.

const Header & getHeader() const

StringRef getName() const

MappedFileRegion & getRegion() const

An efficient, type-erasing, non-owning reference to a callable.

LLVM_ABI char * data() const

Error createTableConfigError(std::errc ErrC, StringRef Path, StringRef TableName, const Twine &Msg)

Definition DatabaseFile.cpp:19

MappedFileRegionArena::RegionT MappedFileRegion

Error checkTable(StringRef Label, size_t Expected, size_t Observed, StringRef Path, StringRef TrieName)

Definition DatabaseFile.cpp:25

This is an optimization pass for GlobalISel generic memory operations.

std::error_code make_error_code(BitcodeError E)

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.