LLVM 20.0.0git
|
This class represents a function that is read from a sample profile. More...
#include "llvm/ProfileData/FunctionId.h"
Public Member Functions | |
FunctionId ()=default | |
FunctionId (StringRef Str) | |
Constructor from a StringRef. | |
FunctionId (uint64_t HashCode) | |
Constructor from a hash code. | |
bool | equals (const FunctionId &Other) const |
Check for equality. | |
int | compare (const FunctionId &Other) const |
Total order comparison. | |
std::string | str () const |
Convert to a string, usually for output purpose. | |
StringRef | stringRef () const |
Convert to StringRef. | |
uint64_t | getHashCode () const |
Get hash code of this object. | |
bool | empty () const |
bool | isStringRef () const |
Check if this object represents a StringRef, or a hash code. | |
Friends | |
raw_ostream & | operator<< (raw_ostream &OS, const FunctionId &Obj) |
This class represents a function that is read from a sample profile.
It comes with two forms: a string or a hash code. The latter form is the 64-bit MD5 of the function name for efficient storage supported by ExtBinary profile format, and when reading the profile, this class can represent it without converting it to a string first. When representing a hash code, we utilize the LengthOrHashCode field to store it, and Name is set to null. When representing a string, it is same as StringRef.
Definition at line 36 of file FunctionId.h.
|
default |
|
inlineexplicit |
|
inlineexplicit |
|
inline |
Total order comparison.
If both FunctionId are StringRef, this is the same as StringRef::compare. If one of them is StringRef, it is considered greater than the hash code FunctionId. Otherwise this is the the same as comparing their int values.
Definition at line 85 of file FunctionId.h.
References llvm::Other.
|
inline |
Definition at line 129 of file FunctionId.h.
Referenced by llvm::ContextTrieNode::getChildContext(), llvm::sampleprof::FunctionSamples::merge(), and llvm::SampleContextTracker::promoteMergeContextSamplesTree().
|
inline |
Check for equality.
Similar to StringRef::equals, but will also cover for the case where one or both are hash codes. Comparing their int values are sufficient. A hash code FunctionId is considered not equal to a StringRef FunctionId regardless of actual contents.
Definition at line 76 of file FunctionId.h.
References llvm::Other.
|
inline |
Get hash code of this object.
Returns this object's hash code if it is already representing one, otherwise returns the MD5 of its string content. Note that it is not the same as std::hash because we want to keep the consistency that the same sample profile function in string form or MD5 form has the same hash code.
Definition at line 123 of file FunctionId.h.
References llvm::sampleprof::MD5Hash().
Referenced by llvm::sampleprof::FunctionSamples::getGUID(), llvm::sampleprof::SampleContextFrame::getHashCode(), llvm::sampleprof::SampleContext::getHashCode(), llvm::DenseMapInfo< sampleprof::FunctionId, void >::getHashValue(), llvm::sampleprof::hash_value(), llvm::sampleprof::MD5Hash(), std::hash< llvm::sampleprof::FunctionId >::operator()(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncProfiles(), and llvm::sampleprof::SampleProfileReaderBinary::readNameTable().
|
inline |
Check if this object represents a StringRef, or a hash code.
Definition at line 132 of file FunctionId.h.
|
inline |
Convert to a string, usually for output purpose.
Use caution on return value's lifetime when converting to StringRef.
Definition at line 97 of file FunctionId.h.
Referenced by dumpFunctionProfileJson(), llvm::sampleprof::SampleContext::toString(), and llvm::sampleprof::SampleContextFrame::toString().
|
inline |
Convert to StringRef.
This is only allowed when it is known this object is representing a StringRef, not a hash code. Calling this function on a hash code is considered an error.
Definition at line 108 of file FunctionId.h.
References assert().
Referenced by llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncProfiles().
|
friend |
Definition at line 159 of file FunctionId.h.