9#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H
10#define LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H
43 template <
typename Range>
45 std::vector<LocallyHashedType> Hashes;
46 Hashes.reserve(std::distance(std::begin(Records), std::end(Records)));
47 for (
const auto &R : Records)
53 static std::vector<LocallyHashedType>
55 std::vector<LocallyHashedType> Hashes;
87 ::memcpy(
Hash.data(),
H.data(), 8);
89 std::array<uint8_t, 8>
Hash;
95 return L.Hash == R.Hash;
100 return !(L.Hash == R.Hash);
119 return hashType(
Type.RecordData, PreviousTypes, PreviousIds);
124 template <
typename Range>
126 std::vector<GloballyHashedType> Hashes;
127 bool UnresolvedRecords =
false;
128 for (
const auto &R : Records) {
131 UnresolvedRecords =
true;
140 while (UnresolvedRecords) {
141 UnresolvedRecords =
false;
142 auto HashIt = Hashes.begin();
143 for (
const auto &R : Records) {
144 if (HashIt->empty()) {
147 UnresolvedRecords =
true;
160 template <
typename Range>
161 static std::vector<GloballyHashedType>
163 std::vector<GloballyHashedType> IdHashes;
164 for (
const auto &R : Records)
165 IdHashes.push_back(
hashType(R, TypeHashes, IdHashes));
170 static std::vector<GloballyHashedType>
172 std::vector<GloballyHashedType> Hashes;
174 Hashes.push_back(
hashType(
Type.RecordData, Hashes, Hashes));
179static_assert(std::is_trivially_copyable<GloballyHashedType>::value,
180 "GloballyHashedType must be trivially copyable so that we can "
181 "reinterpret_cast arrays of hash data to arrays of "
182 "GloballyHashedType");
201 return LHS.RecordData ==
RHS.RecordData;
214 return *
reinterpret_cast<const unsigned *
>(Val.
Hash.data());
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),...
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.
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)
static LLVM_ABI codeview::GloballyHashedType Empty
static codeview::GloballyHashedType getEmptyKey()
static codeview::GloballyHashedType getTombstoneKey()
static bool isEqual(codeview::GloballyHashedType LHS, codeview::GloballyHashedType RHS)
static LLVM_ABI codeview::GloballyHashedType Tombstone
static codeview::LocallyHashedType getEmptyKey()
static codeview::LocallyHashedType getTombstoneKey()
static LLVM_ABI codeview::LocallyHashedType Empty
static unsigned getHashValue(codeview::LocallyHashedType Val)
static bool isEqual(codeview::LocallyHashedType LHS, codeview::LocallyHashedType RHS)
static LLVM_ABI codeview::LocallyHashedType Tombstone
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 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
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 LLVM_ABI 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.