9#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H
10#define LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H
42 template <
typename Range>
44 std::vector<LocallyHashedType> Hashes;
45 Hashes.reserve(std::distance(std::begin(Records), std::end(Records)));
46 for (
const auto &R : Records)
52 static std::vector<LocallyHashedType>
54 std::vector<LocallyHashedType> Hashes;
86 ::memcpy(
Hash.data(),
H.data(), 8);
88 std::array<uint8_t, 8>
Hash;
94 return L.Hash == R.Hash;
99 return !(L.Hash == R.Hash);
117 return hashType(
Type.RecordData, PreviousTypes, PreviousIds);
122 template <
typename Range>
124 std::vector<GloballyHashedType> Hashes;
125 bool UnresolvedRecords =
false;
126 for (
const auto &R : Records) {
129 UnresolvedRecords =
true;
138 while (UnresolvedRecords) {
139 UnresolvedRecords =
false;
140 auto HashIt = Hashes.begin();
141 for (
const auto &R : Records) {
142 if (HashIt->empty()) {
145 UnresolvedRecords =
true;
158 template <
typename Range>
159 static std::vector<GloballyHashedType>
161 std::vector<GloballyHashedType> IdHashes;
162 for (
const auto &R : Records)
163 IdHashes.push_back(
hashType(R, TypeHashes, IdHashes));
168 static std::vector<GloballyHashedType>
170 std::vector<GloballyHashedType> Hashes;
172 Hashes.push_back(
hashType(
Type.RecordData, Hashes, Hashes));
177static_assert(std::is_trivially_copyable<GloballyHashedType>::value,
178 "GloballyHashedType must be trivially copyable so that we can "
179 "reinterpret_cast arrays of hash data to arrays of "
180 "GloballyHashedType");
199 return LHS.RecordData ==
RHS.RecordData;
212 return *
reinterpret_cast<const unsigned *
>(Val.
Hash.data());
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
A class that wrap the SHA1 algorithm.
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.
This is an optimization pass for GlobalISel generic memory operations.
void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, std::optional< size_t > Width=std::nullopt)
static unsigned getHashValue(codeview::GloballyHashedType Val)
static codeview::GloballyHashedType getEmptyKey()
static codeview::GloballyHashedType getTombstoneKey()
static bool isEqual(codeview::GloballyHashedType LHS, codeview::GloballyHashedType RHS)
static codeview::GloballyHashedType Empty
static codeview::GloballyHashedType Tombstone
static codeview::LocallyHashedType getEmptyKey()
static codeview::LocallyHashedType getTombstoneKey()
static codeview::LocallyHashedType Empty
static codeview::LocallyHashedType Tombstone
static unsigned getHashValue(codeview::LocallyHashedType Val)
static bool isEqual(codeview::LocallyHashedType LHS, codeview::LocallyHashedType RHS)
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...
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.
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,...
static std::vector< GloballyHashedType > hashTypes(Range &&Records)
Given a sequence of combined type and ID records, compute global hashes for each of them,...
GloballyHashedType(StringRef H)
static std::vector< GloballyHashedType > hashTypeCollection(TypeCollection &Types)
GloballyHashedType()=default
GloballyHashedType(ArrayRef< uint8_t > H)
friend bool operator==(const GloballyHashedType &L, const GloballyHashedType &R)
static 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
friend bool operator!=(const GloballyHashedType &L, const GloballyHashedType &R)
A locally hashed type represents a straightforward hash code of a serialized record.
static std::vector< LocallyHashedType > hashTypeCollection(TypeCollection &Types)
static LocallyHashedType hashType(ArrayRef< uint8_t > RecordData)
Given a type, compute its local hash.
ArrayRef< uint8_t > RecordData
static std::vector< LocallyHashedType > hashTypes(Range &&Records)
Given a sequence of types, compute all of the local hashes.