LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
llvm::codeview::GloballyHashedType Struct Reference

A globally hashed type represents a hash value that is sufficient to uniquely identify a record across multiple type streams or type sequences. More...

#include "llvm/DebugInfo/CodeView/TypeHashing.h"

Public Member Functions

 GloballyHashedType ()=default
 
 GloballyHashedType (StringRef H)
 
 GloballyHashedType (ArrayRef< uint8_t > H)
 
bool empty () const
 

Static Public Member Functions

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.
 
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.
 
template<typename Range >
static std::vector< GloballyHashedTypehashTypes (Range &&Records)
 Given a sequence of combined type and ID records, compute global hashes for each of them, returning the results in a vector of hashed types.
 
template<typename Range >
static std::vector< GloballyHashedTypehashIds (Range &&Records, ArrayRef< GloballyHashedType > TypeHashes)
 Given a sequence of combined type and ID records, compute global hashes for each of them, returning the results in a vector of hashed types.
 
static std::vector< GloballyHashedTypehashTypeCollection (TypeCollection &Types)
 

Public Attributes

std::array< uint8_t, 8 > Hash
 

Friends

bool operator== (const GloballyHashedType &L, const GloballyHashedType &R)
 
bool operator!= (const GloballyHashedType &L, const GloballyHashedType &R)
 

Detailed Description

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.

Definition at line 80 of file TypeHashing.h.

Constructor & Destructor Documentation

◆ GloballyHashedType() [1/3]

llvm::codeview::GloballyHashedType::GloballyHashedType ( )
default

◆ GloballyHashedType() [2/3]

llvm::codeview::GloballyHashedType::GloballyHashedType ( StringRef  H)
inline

Definition at line 82 of file TypeHashing.h.

◆ GloballyHashedType() [3/3]

llvm::codeview::GloballyHashedType::GloballyHashedType ( ArrayRef< uint8_t >  H)
inline

Definition at line 84 of file TypeHashing.h.

References assert(), H, and Hash.

Member Function Documentation

◆ empty()

bool llvm::codeview::GloballyHashedType::empty ( ) const
inline

Definition at line 90 of file TypeHashing.h.

References Hash.

◆ hashIds()

template<typename Range >
static std::vector< GloballyHashedType > llvm::codeview::GloballyHashedType::hashIds ( Range &&  Records,
ArrayRef< GloballyHashedType TypeHashes 
)
inlinestatic

Given a sequence of combined type and ID records, compute global hashes for each of them, returning the results in a vector of hashed types.

Definition at line 160 of file TypeHashing.h.

References hashType().

◆ hashType() [1/2]

GloballyHashedType GloballyHashedType::hashType ( ArrayRef< uint8_t >  RecordData,
ArrayRef< GloballyHashedType PreviousTypes,
ArrayRef< GloballyHashedType PreviousIds 
)
static

Given a sequence of bytes representing a record, compute a global hash for this record.

Due to the nature of global hashes incorporating the hashes of referenced records, this function requires a list of types and ids that RecordData might reference, indexable by TypeIndex.

Definition at line 33 of file TypeHashing.cpp.

References llvm::codeview::discoverTypeIndices(), llvm::ArrayRef< T >::drop_front(), llvm::TruncatedBLAKE3< NumBytes >::final(), llvm::codeview::IndexRef, llvm::BLAKE3::init(), llvm::Ref, llvm::ArrayRef< T >::slice(), llvm::ArrayRef< T >::take_front(), and llvm::BLAKE3::update().

Referenced by hashIds(), hashType(), hashTypeCollection(), hashTypes(), llvm::codeview::GlobalTypeTableBuilder::insertRecordBytes(), and llvm::codeview::GlobalTypeTableBuilder::replaceType().

◆ hashType() [2/2]

static GloballyHashedType llvm::codeview::GloballyHashedType::hashType ( CVType  Type,
ArrayRef< GloballyHashedType PreviousTypes,
ArrayRef< GloballyHashedType PreviousIds 
)
inlinestatic

Given a sequence of bytes representing a record, compute a global hash for this record.

Due to the nature of global hashes incorporating the hashes of referenced records, this function requires a list of types and ids that RecordData might reference, indexable by TypeIndex.

Definition at line 114 of file TypeHashing.h.

References hashType().

◆ hashTypeCollection()

static std::vector< GloballyHashedType > llvm::codeview::GloballyHashedType::hashTypeCollection ( TypeCollection Types)
inlinestatic

Definition at line 169 of file TypeHashing.h.

References hashType().

◆ hashTypes()

template<typename Range >
static std::vector< GloballyHashedType > llvm::codeview::GloballyHashedType::hashTypes ( Range &&  Records)
inlinestatic

Given a sequence of combined type and ID records, compute global hashes for each of them, returning the results in a vector of hashed types.

Definition at line 123 of file TypeHashing.h.

References H, and hashType().

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const GloballyHashedType L,
const GloballyHashedType R 
)
friend

Definition at line 97 of file TypeHashing.h.

◆ operator==

bool operator== ( const GloballyHashedType L,
const GloballyHashedType R 
)
friend

Definition at line 92 of file TypeHashing.h.

Member Data Documentation

◆ Hash

std::array<uint8_t, 8> llvm::codeview::GloballyHashedType::Hash

The documentation for this struct was generated from the following files: