//===- TypeHashing.h ---------------------------------------------*- C++-*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H #define LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Hashing.h" #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/TypeCollection.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/Support/FormatProviders.h" #include <type_traits> namespace llvm { class raw_ostream; namespace codeview { /// A locally hashed type represents a straightforward hash code of a serialized /// record. The record is simply serialized, and then the bytes are hashed by /// a standard algorithm. This is sufficient for the case of de-duplicating /// records within a single sequence of types, because if two records both have /// a back-reference to the same type in the same stream, they will both have /// the same numeric value for the TypeIndex of the back reference. struct LocallyHashedType { … }; enum class GlobalTypeHashAlg : uint16_t { … }; /// A globally hashed type represents a hash value that is sufficient to /// uniquely identify a record across multiple type streams or type sequences. /// This works by, for any given record A which references B, replacing the /// TypeIndex that refers to B with a previously-computed global hash for B. As /// this is a recursive algorithm (e.g. the global hash of B also depends on the /// global hashes of the types that B refers to), a global hash can uniquely /// identify that A occurs in another stream that has a completely /// different graph structure. Although the hash itself is slower to compute, /// probing is much faster with a globally hashed type, because the hash itself /// is considered "as good as" the original type. Since type records can be /// quite large, this makes the equality comparison of the hash much faster than /// equality comparison of a full record. struct GloballyHashedType { … }; static_assert …; } // namespace codeview template <> struct DenseMapInfo<codeview::LocallyHashedType> { … }; template <> struct DenseMapInfo<codeview::GloballyHashedType> { … }; template <> struct format_provider<codeview::LocallyHashedType> { … }; template <> struct format_provider<codeview::GloballyHashedType> { … }; } // namespace llvm #endif