LLVM 22.0.0git
Public Types | Public Member Functions | List of all members
llvm::memprof::DataAccessProfData Class Reference

Encapsulates the data access profile data and the methods to operate on it. More...

#include "llvm/ProfileData/DataAccessProf.h"

Public Types

using StringToIndexMap = llvm::MapVector< StringRef, uint64_t >
 

Public Member Functions

 DataAccessProfData ()
 
LLVM_ABI Error serialize (ProfOStream &OS) const
 Serialize profile data to the output stream.
 
LLVM_ABI Error deserialize (const unsigned char *&Ptr)
 Deserialize this class from the given buffer.
 
LLVM_ABI std::optional< DataAccessProfRecordgetProfileRecord (const SymbolHandleRef SymID) const
 Returns a profile record for SymbolID, or std::nullopt if there isn't a record.
 
LLVM_ABI bool isKnownColdSymbol (const SymbolHandleRef SymID) const
 Returns true if SymID is seen in profiled binaries and cold.
 
LLVM_ABI Error setDataAccessProfile (SymbolHandleRef SymbolID, uint64_t AccessCount)
 Methods to set symbolized data access profile.
 
LLVM_ABI Error setDataAccessProfile (SymbolHandleRef SymbolID, uint64_t AccessCount, ArrayRef< SourceLocation > Locations)
 Similar to the method above, for records with Locations representing the filename:line where this symbol shows up.
 
LLVM_ABI Error addKnownSymbolWithoutSamples (SymbolHandleRef SymbolID)
 Add a symbol that's seen in the profiled binary without samples.
 
ArrayRef< StringToIndexMap::value_typegetStrToIndexMapRef () const
 The following methods return array reference for various internal data structures.
 
ArrayRef< MapVector< SymbolHandleRef, internal::DataAccessProfRecordRef >::value_type > getRecords () const
 
ArrayRef< StringRefgetKnownColdSymbols () const
 
ArrayRef< uint64_tgetKnownColdHashes () const
 
bool empty () const
 

Detailed Description

Encapsulates the data access profile data and the methods to operate on it.

This class provides profile look-up, serialization and deserialization.

Definition at line 129 of file DataAccessProf.h.

Member Typedef Documentation

◆ StringToIndexMap

Definition at line 133 of file DataAccessProf.h.

Constructor & Destructor Documentation

◆ DataAccessProfData()

llvm::memprof::DataAccessProfData::DataAccessProfData ( )
inline

Definition at line 135 of file DataAccessProf.h.

Member Function Documentation

◆ addKnownSymbolWithoutSamples()

Error llvm::memprof::DataAccessProfData::addKnownSymbolWithoutSamples ( SymbolHandleRef  SymbolID)

Add a symbol that's seen in the profiled binary without samples.

Definition at line 104 of file DataAccessProf.cpp.

References llvm::memprof::getCanonicalName(), llvm::SetVector< T, Vector, Set, N >::insert(), llvm::memprof::saveStringToMap(), and llvm::Error::success().

◆ deserialize()

Error llvm::memprof::DataAccessProfData::deserialize ( const unsigned char *&  Ptr)

Deserialize this class from the given buffer.

Definition at line 118 of file DataAccessProf.cpp.

References E, I, llvm::SetVector< T, Vector, Set, N >::insert(), and Ptr.

◆ empty()

bool llvm::memprof::DataAccessProfData::empty ( ) const
inline

Definition at line 188 of file DataAccessProf.h.

References llvm::SetVector< T, Vector, Set, N >::empty().

Referenced by getProfileRecord().

◆ getKnownColdHashes()

ArrayRef< uint64_t > llvm::memprof::DataAccessProfData::getKnownColdHashes ( ) const
inline

◆ getKnownColdSymbols()

ArrayRef< StringRef > llvm::memprof::DataAccessProfData::getKnownColdSymbols ( ) const
inline

Definition at line 182 of file DataAccessProf.h.

◆ getProfileRecord()

std::optional< DataAccessProfRecord > llvm::memprof::DataAccessProfData::getProfileRecord ( const SymbolHandleRef  SymID) const

Returns a profile record for SymbolID, or std::nullopt if there isn't a record.

Internally, this function will canonicalize the symbol name before the lookup.

Definition at line 33 of file DataAccessProf.cpp.

References assert(), empty(), and llvm::memprof::getCanonicalName().

◆ getRecords()

ArrayRef< MapVector< SymbolHandleRef, internal::DataAccessProfRecordRef >::value_type > llvm::memprof::DataAccessProfData::getRecords ( ) const
inline

Definition at line 179 of file DataAccessProf.h.

◆ getStrToIndexMapRef()

ArrayRef< StringToIndexMap::value_type > llvm::memprof::DataAccessProfData::getStrToIndexMapRef ( ) const
inline

The following methods return array reference for various internal data structures.

Definition at line 174 of file DataAccessProf.h.

References llvm::MapVector< KeyT, ValueT, MapType, VectorType >::getArrayRef().

◆ isKnownColdSymbol()

bool llvm::memprof::DataAccessProfData::isKnownColdSymbol ( const SymbolHandleRef  SymID) const

Returns true if SymID is seen in profiled binaries and cold.

Definition at line 56 of file DataAccessProf.cpp.

References llvm::SetVector< T, Vector, Set, N >::contains().

◆ serialize()

Error llvm::memprof::DataAccessProfData::serialize ( ProfOStream OS) const

Serialize profile data to the output stream.

Storage layout:

  • Serialized strings.
  • The encoded hashes.
  • Records.

Definition at line 177 of file DataAccessProf.cpp.

References E, OS, llvm::SetVector< T, Vector, Set, N >::size(), and llvm::Error::success().

◆ setDataAccessProfile() [1/2]

Error llvm::memprof::DataAccessProfData::setDataAccessProfile ( SymbolHandleRef  SymbolID,
uint64_t  AccessCount 
)

Methods to set symbolized data access profile.

Returns error if duplicated symbol names or content hashes are seen. The user of this class should aggregate counters that correspond to the same symbol name or with the same string literal hash before calling 'set*' methods.

Definition at line 62 of file DataAccessProf.cpp.

References llvm::memprof::getCanonicalName(), llvm::invalid_argument, llvm::memprof::saveStringToMap(), and llvm::Error::success().

Referenced by setDataAccessProfile().

◆ setDataAccessProfile() [2/2]

Error llvm::memprof::DataAccessProfData::setDataAccessProfile ( SymbolHandleRef  SymbolID,
uint64_t  AccessCount,
ArrayRef< SourceLocation Locations 
)

Similar to the method above, for records with Locations representing the filename:line where this symbol shows up.

Note because of linker's merge of identical symbols (e.g., unnamed_addr string literals), one symbol is likely to have multiple locations.

Definition at line 89 of file DataAccessProf.cpp.

References E, llvm::memprof::saveStringToMap(), setDataAccessProfile(), and llvm::Error::success().


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