LLVM: lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

10

17

18using namespace llvm;

23

26

28

29

30

31

32

33

34 return static_cast<uint16_t>(Table->getIdForString(S));

35}

36

40

42 return Table->insert(S);

43}

44

46 return Strings.insert(S);

47}

48

50 return Strings.getIdForString(S);

51}

52

54 return Strings.getStringForId(Id);

55}

56

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73 static const std::pair<uint32_t, uint32_t> StringsToBuckets[] = {

74 {0, 1},

75 {1, 2},

76 {2, 4},

77 {4, 7},

78 {6, 11},

79 {9, 17},

80 {13, 26},

81 {20, 40},

82 {31, 61},

83 {46, 92},

84 {70, 139},

85 {105, 209},

86 {157, 314},

87 {236, 472},

88 {355, 709},

89 {532, 1064},

90 {799, 1597},

91 {1198, 2396},

92 {1798, 3595},

93 {2697, 5393},

94 {4045, 8090},

95 {6068, 12136},

96 {9103, 18205},

97 {13654, 27308},

98 {20482, 40963},

99 {30723, 61445},

100 {46084, 92168},

101 {69127, 138253},

102 {103690, 207380},

103 {155536, 311071},

104 {233304, 466607},

105 {349956, 699911},

106 {524934, 1049867},

107 {787401, 1574801},

108 {1181101, 2362202},

109 {1771652, 3543304},

110 {2657479, 5314957},

111 {3986218, 7972436},

112 {5979328, 11958655},

113 {8968992, 17937983},

114 {13453488, 26906975},

115 {20180232, 40360463},

116 {30270348, 60540695},

117 {45405522, 90811043},

118 {68108283, 136216565},

119 {102162424, 204324848},

120 {153243637, 306487273},

121 {229865455, 459730910},

122 {344798183, 689596366},

123 {517197275, 1034394550},

124 {775795913, 1551591826},

125 {1163693870, 2327387740}};

127 StringsToBuckets, std::make_pair(NumStrings, 0U), llvm::less_first());

128 assert(Entry != std::end(StringsToBuckets));

129 return Entry->second;

130}

131

132uint32_t PDBStringTableBuilder::calculateHashTableSize() const {

133 uint32_t Size = sizeof(uint32_t);

135

137}

138

142 Size += Strings.calculateSerializedSize();

143 Size += calculateHashTableSize();

144 Size += sizeof(uint32_t);

146}

147

150 this->Strings = Strings;

151}

152

154

157 H.HashVersion = 1;

159 if (auto EC = Writer.writeObject(H))

160 return EC;

163}

164

167 return EC;

168

171}

172

174

176 if (auto EC = Writer.writeInteger(BucketCount))

177 return EC;

178 std::vector<ulittle32_t> Buckets(BucketCount);

179

180 for (const auto &Pair : Strings) {

184

185 for (uint32_t I = 0; I != BucketCount; ++I) {

187 if (Buckets[Slot] != 0)

188 continue;

190 break;

191 }

192 }

193

195 return EC;

196

199}

200

201Error PDBStringTableBuilder::writeEpilogue(BinaryStreamWriter &Writer) const {

202 if (auto EC = Writer.writeInteger<uint32_t>(Strings.size()))

203 return EC;

206}

207

211

213 if (auto EC = writeHeader(SectionWriter))

214 return EC;

215

216 std::tie(SectionWriter, Writer) =

217 Writer.split(Strings.calculateSerializedSize());

218 if (auto EC = writeStrings(SectionWriter))

219 return EC;

220

221 std::tie(SectionWriter, Writer) = Writer.split(calculateHashTableSize());

222 if (auto EC = writeHashTable(SectionWriter))

223 return EC;

224

226 if (auto EC = writeEpilogue(SectionWriter))

227 return EC;

228

230}

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

static uint32_t computeBucketCount(uint32_t NumStrings)

Definition PDBStringTableBuilder.cpp:57

Provides write only access to a subclass of WritableBinaryStream.

Error writeArray(ArrayRef< T > Array)

Writes an array of objects of type T to the underlying stream, as if by using memcpy.

Error writeInteger(T Value)

Write the integer Value to the underlying stream in the specified endianness.

uint64_t bytesRemaining() const

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

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

The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.

Represents a read-write view of a CodeView string table.

uint32_t calculateSerializedSize() const override

Error commit(BinaryStreamWriter &Writer) const override

LLVM_ABI uint32_t insert(StringRef S)

Definition PDBStringTableBuilder.cpp:45

LLVM_ABI uint32_t calculateSerializedSize() const

Definition PDBStringTableBuilder.cpp:139

LLVM_ABI void setStrings(const codeview::DebugStringTableSubsection &Strings)

Definition PDBStringTableBuilder.cpp:148

LLVM_ABI Error commit(BinaryStreamWriter &Writer) const

Definition PDBStringTableBuilder.cpp:208

LLVM_ABI StringRef getStringForId(uint32_t Id) const

Definition PDBStringTableBuilder.cpp:53

LLVM_ABI uint32_t getIdForString(StringRef S) const

Definition PDBStringTableBuilder.cpp:49

LLVM_ABI uint32_t hashStringV1(StringRef Str)

const uint32_t PDBStringTableSignature

This is an optimization pass for GlobalISel generic memory operations.

auto lower_bound(R &&Range, T &&Value)

Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...

ArrayRef(const T &OneElt) -> ArrayRef< T >

Function object to check whether the first component of a container supported by std::get (like std::...

LLVM_ABI uint32_t hashLookupKey(StringRef S) const

Definition PDBStringTableBuilder.cpp:27

LLVM_ABI StringRef storageKeyToLookupKey(uint32_t Offset) const

Definition PDBStringTableBuilder.cpp:37

PDBStringTableBuilder * Table

LLVM_ABI StringTableHashTraits(PDBStringTableBuilder &Table)

Definition PDBStringTableBuilder.cpp:24

LLVM_ABI uint32_t lookupKeyToStorageKey(StringRef S)

Definition PDBStringTableBuilder.cpp:41

Adapter to write values to a stream in a particular byte order.