LLVM: include/llvm/DebugInfo/CodeView/TypeHashing.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H
10#define LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H
11
16
20
22
23#include <type_traits>
24
25namespace llvm {
28
29
30
31
32
33
34
38
39
41
42
43 template
44 static std::vector hashTypes(Range &&Records) {
45 std::vector Hashes;
46 Hashes.reserve(std::distance(std::begin(Records), std::end(Records)));
47 for (const auto &R : Records)
48 Hashes.push_back(hashType(R));
49
50 return Hashes;
51 }
52
53 static std::vector
55 std::vector Hashes;
58 });
59 return Hashes;
60 }
61};
62
68
69
70
71
72
73
74
75
76
77
78
79
80
87 ::memcpy(Hash.data(), H.data(), 8);
88 }
89 std::array<uint8_t, 8> Hash;
90
92
95 return L.Hash == R.Hash;
96 }
97
100 return !(L.Hash == R.Hash);
101 }
102
103
104
105
106
111
112
113
114
115
119 return hashType(Type.RecordData, PreviousTypes, PreviousIds);
120 }
121
122
123
124 template
125 static std::vector hashTypes(Range &&Records) {
126 std::vector Hashes;
127 bool UnresolvedRecords = false;
128 for (const auto &R : Records) {
130 if (H.empty())
131 UnresolvedRecords = true;
132 Hashes.push_back(H);
133 }
134
135
136
137
138
139
140 while (UnresolvedRecords) {
141 UnresolvedRecords = false;
142 auto HashIt = Hashes.begin();
143 for (const auto &R : Records) {
144 if (HashIt->empty()) {
146 if (H.empty())
147 UnresolvedRecords = true;
148 else
149 *HashIt = H;
150 }
151 ++HashIt;
152 }
153 }
154
155 return Hashes;
156 }
157
158
159
160 template
161 static std::vector
163 std::vector IdHashes;
164 for (const auto &R : Records)
165 IdHashes.push_back(hashType(R, TypeHashes, IdHashes));
166
167 return IdHashes;
168 }
169
170 static std::vector
172 std::vector Hashes;
174 Hashes.push_back(hashType(Type.RecordData, Hashes, Hashes));
175 });
176 return Hashes;
177 }
178};
179static_assert(std::is_trivially_copyable::value,
180 "GloballyHashedType must be trivially copyable so that we can "
181 "reinterpret_cast arrays of hash data to arrays of "
182 "GloballyHashedType");
183}
184
188
190
192
194 return Val.Hash;
195 }
196
200 return false;
201 return LHS.RecordData == RHS.RecordData;
202 }
203};
204
208
210
212
214 return *reinterpret_cast<const unsigned *>(Val.Hash.data());
215 }
216
221};
222
230
240
241}
242
243#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
GlobalTypeHashAlg
Definition TypeHashing.h:63
@ BLAKE3
Definition TypeHashing.h:66
@ SHA1_8
Definition TypeHashing.h:65
CVRecord< TypeLeafKind > CVType
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, std::optional< size_t > Width=std::nullopt)
static unsigned getHashValue(codeview::GloballyHashedType Val)
Definition TypeHashing.h:213
static LLVM_ABI codeview::GloballyHashedType Empty
Definition TypeHashing.h:206
static codeview::GloballyHashedType getEmptyKey()
Definition TypeHashing.h:209
static codeview::GloballyHashedType getTombstoneKey()
Definition TypeHashing.h:211
static bool isEqual(codeview::GloballyHashedType LHS, codeview::GloballyHashedType RHS)
Definition TypeHashing.h:217
static LLVM_ABI codeview::GloballyHashedType Tombstone
Definition TypeHashing.h:207
static codeview::LocallyHashedType getEmptyKey()
Definition TypeHashing.h:189
static codeview::LocallyHashedType getTombstoneKey()
Definition TypeHashing.h:191
static LLVM_ABI codeview::LocallyHashedType Empty
Definition TypeHashing.h:186
static unsigned getHashValue(codeview::LocallyHashedType Val)
Definition TypeHashing.h:193
static bool isEqual(codeview::LocallyHashedType LHS, codeview::LocallyHashedType RHS)
Definition TypeHashing.h:197
static LLVM_ABI codeview::LocallyHashedType Tombstone
Definition TypeHashing.h:187
An information struct used to provide DenseMap with the various necessary components for a given valu...
A globally hashed type represents a hash value that is sufficient to uniquely identify a record acros...
Definition TypeHashing.h:81
static GloballyHashedType hashType(CVType Type, ArrayRef< GloballyHashedType > PreviousTypes, ArrayRef< GloballyHashedType > PreviousIds)
Given a sequence of bytes representing a record, compute a global hash for this record.
Definition TypeHashing.h:116
static std::vector< GloballyHashedType > hashIds(Range &&Records, ArrayRef< GloballyHashedType > TypeHashes)
Given a sequence of combined type and ID records, compute global hashes for each of them,...
Definition TypeHashing.h:162
static std::vector< GloballyHashedType > hashTypes(Range &&Records)
Given a sequence of combined type and ID records, compute global hashes for each of them,...
Definition TypeHashing.h:125
GloballyHashedType(StringRef H)
Definition TypeHashing.h:83
static std::vector< GloballyHashedType > hashTypeCollection(TypeCollection &Types)
Definition TypeHashing.h:171
GloballyHashedType()=default
bool empty() const
Definition TypeHashing.h:91
GloballyHashedType(ArrayRef< uint8_t > H)
Definition TypeHashing.h:85
friend bool operator==(const GloballyHashedType &L, const GloballyHashedType &R)
Definition TypeHashing.h:93
static LLVM_ABI GloballyHashedType hashType(ArrayRef< uint8_t > RecordData, ArrayRef< GloballyHashedType > PreviousTypes, ArrayRef< GloballyHashedType > PreviousIds)
Given a sequence of bytes representing a record, compute a global hash for this record.
std::array< uint8_t, 8 > Hash
Definition TypeHashing.h:89
friend bool operator!=(const GloballyHashedType &L, const GloballyHashedType &R)
Definition TypeHashing.h:98
A locally hashed type represents a straightforward hash code of a serialized record.
Definition TypeHashing.h:35
static std::vector< LocallyHashedType > hashTypeCollection(TypeCollection &Types)
Definition TypeHashing.h:54
hash_code Hash
Definition TypeHashing.h:36
static LLVM_ABI LocallyHashedType hashType(ArrayRef< uint8_t > RecordData)
Given a type, compute its local hash.
ArrayRef< uint8_t > RecordData
Definition TypeHashing.h:37
static std::vector< LocallyHashedType > hashTypes(Range &&Records)
Given a sequence of types, compute all of the local hashes.
Definition TypeHashing.h:44
static void format(const codeview::GloballyHashedType &V, llvm::raw_ostream &Stream, StringRef Style)
Definition TypeHashing.h:233
static void format(const codeview::LocallyHashedType &V, llvm::raw_ostream &Stream, StringRef Style)
Definition TypeHashing.h:225