9 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H 10 #define LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H 21 #include <type_traits> 40 template <
typename Range>
41 static std::vector<LocallyHashedType>
hashTypes(Range &&Records) {
42 std::vector<LocallyHashedType> Hashes;
44 for (
const auto &R : Records)
50 static std::vector<LocallyHashedType>
52 std::vector<LocallyHashedType> Hashes;
85 std::array<uint8_t, 8>
Hash;
87 bool empty()
const {
return *(
const uint64_t*)Hash.data() == 0; }
109 template <
typename Range>
110 static std::vector<GloballyHashedType>
hashTypes(Range &&Records) {
111 std::vector<GloballyHashedType> Hashes;
112 bool UnresolvedRecords =
false;
113 for (
const auto &R : Records) {
116 UnresolvedRecords =
true;
125 while (UnresolvedRecords) {
126 UnresolvedRecords =
false;
127 auto HashIt = Hashes.begin();
128 for (
const auto &R : Records) {
129 if (HashIt->empty()) {
132 UnresolvedRecords =
true;
145 template <
typename Range>
146 static std::vector<GloballyHashedType>
148 std::vector<GloballyHashedType> IdHashes;
149 for (
const auto &R : Records)
150 IdHashes.push_back(
hashType(R, TypeHashes, IdHashes));
155 static std::vector<GloballyHashedType>
157 std::vector<GloballyHashedType> Hashes;
164 #if defined(_MSC_VER) 168 static_assert(std::is_trivially_copyable<GloballyHashedType>::value,
169 "GloballyHashedType must be trivially copyable so that we can " 170 "reinterpret_cast arrays of hash data to arrays of " 171 "GloballyHashedType");
204 return *
reinterpret_cast<const unsigned *
>(Val.
Hash.data());
225 for (uint8_t
B : V.
Hash) {
const_iterator end(StringRef path)
Get end iterator over path.
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.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
A locally hashed type represents a straightforward hash code of a serialized record.
static bool isEqual(codeview::LocallyHashedType LHS, codeview::LocallyHashedType RHS)
static codeview::GloballyHashedType getTombstoneKey()
static bool isEqual(codeview::GloballyHashedType LHS, codeview::GloballyHashedType RHS)
A class that wrap the SHA1 algorithm.
static codeview::LocallyHashedType Tombstone
static std::vector< GloballyHashedType > hashTypes(Range &&Records)
Given a sequence of combined type and ID records, compute global hashes for each of them...
static LocallyHashedType hashType(ArrayRef< uint8_t > RecordData)
Given a type, compute its local hash.
static std::vector< LocallyHashedType > hashTypes(Range &&Records)
Given a sequence of types, compute all of the local hashes.
static codeview::LocallyHashedType getEmptyKey()
static std::vector< LocallyHashedType > hashTypeCollection(TypeCollection &Types)
A globally hashed type represents a hash value that is sufficient to uniquely identify a record acros...
static codeview::LocallyHashedType Empty
static std::vector< GloballyHashedType > hashTypeCollection(TypeCollection &Types)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void ForEachRecord(TFunc Func)
The instances of the Type class are immutable: once they are created, they are never changed...
size_t size() const
size - Get the array size.
std::array< uint8_t, 8 > Hash
GloballyHashedType(ArrayRef< uint8_t > H)
static codeview::GloballyHashedType Empty
static codeview::GloballyHashedType getEmptyKey()
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 unsigned getHashValue(codeview::LocallyHashedType Val)
An opaque object representing a hash code.
void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, Optional< size_t > Width=None)
ArrayRef< uint8_t > RecordData
static unsigned getHashValue(codeview::GloballyHashedType Val)
GloballyHashedType(StringRef H)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static codeview::GloballyHashedType Tombstone
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
ArrayRef< uint8_t > RecordData
static codeview::LocallyHashedType getTombstoneKey()