LLVM 22.0.0git
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

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::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, Ptr, and llvm::support::endian::readNext().

◆ empty()

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

Definition at line 188 of file DataAccessProf.h.

Referenced by getProfileRecord().

◆ getKnownColdHashes()

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

Definition at line 185 of file DataAccessProf.h.

◆ 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(), llvm::memprof::getCanonicalName(), and llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key.

◆ 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.

◆ 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.

◆ 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(), llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, llvm::Error::success(), llvm::ProfOStream::write(), llvm::ProfOStream::write32(), and llvm::ProfOStream::writeByte().

◆ 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::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, llvm::invalid_argument, llvm::make_error(), 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: