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

#include "llvm/ProfileData/InstrProfWriter.h"

Public Types

using ProfilingData = SmallDenseMap< uint64_t, InstrProfRecord >
 

Public Member Functions

LLVM_ABI InstrProfWriter (bool Sparse=false, uint64_t TemporalProfTraceReservoirSize=0, uint64_t MaxTemporalProfTraceLength=0, bool WritePrevVersion=false, memprof::IndexedVersion MemProfVersionRequested=static_cast< memprof::IndexedVersion >(memprof::MinimumSupportedVersion), bool MemProfFullSchema=false, bool MemprofGenerateRandomHotness=false, unsigned MemprofGenerateRandomHotnessSeed=0)
 
LLVM_ABI ~InstrProfWriter ()
 
StringMap< ProfilingData > & getProfileData ()
 
LLVM_ABI void addRecord (NamedInstrProfRecord &&I, uint64_t Weight, function_ref< void(Error)> Warn)
 Add function counts for the given function.
 
void addRecord (NamedInstrProfRecord &&I, function_ref< void(Error)> Warn)
 
void addVTableName (StringRef VTableName)
 
LLVM_ABI void addTemporalProfileTraces (SmallVectorImpl< TemporalProfTraceTy > &SrcTraces, uint64_t SrcStreamSize)
 Add SrcTraces using reservoir sampling where SrcStreamSize is the total number of temporal profiling traces the source has seen.
 
LLVM_ABI bool addMemProfData (memprof::IndexedMemProfData Incoming, function_ref< void(Error)> Warn)
 Add the entire MemProfData Incoming to the writer context.
 
LLVM_ABI void addBinaryIds (ArrayRef< llvm::object::BuildID > BIs)
 
LLVM_ABI void addDataAccessProfData (std::unique_ptr< memprof::DataAccessProfData > DataAccessProfile)
 
LLVM_ABI void mergeRecordsFromWriter (InstrProfWriter &&IPW, function_ref< void(Error)> Warn)
 Merge existing function counts from the given writer.
 
LLVM_ABI Error write (raw_fd_ostream &OS)
 Write the profile to OS.
 
LLVM_ABI Error write (raw_string_ostream &OS)
 Write the profile to a string output stream OS.
 
LLVM_ABI Error writeText (raw_fd_ostream &OS)
 Write the profile in text format to OS.
 
LLVM_ABI void writeTextTemporalProfTraceData (raw_fd_ostream &OS, InstrProfSymtab &Symtab)
 Write temporal profile trace data to the header in text format to OS.
 
LLVM_ABI Error validateRecord (const InstrProfRecord &Func)
 
LLVM_ABI std::unique_ptr< MemoryBufferwriteBuffer ()
 Write the profile, returning the raw data. For testing.
 
Error mergeProfileKind (const InstrProfKind Other)
 Update the attributes of the current profile from the attributes specified.
 
InstrProfKind getProfileKind () const
 
bool hasSingleByteCoverage () const
 
LLVM_ABI void setValueProfDataEndianness (llvm::endianness Endianness)
 
LLVM_ABI void setOutputSparse (bool Sparse)
 
void setMemProfVersionRequested (memprof::IndexedVersion Version)
 
void setMemProfFullSchema (bool Full)
 
LLVM_ABI void overlapRecord (NamedInstrProfRecord &&Other, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap, const OverlapFuncFilters &FuncFilter)
 

Static Public Member Functions

static LLVM_ABI void writeRecordInText (StringRef Name, uint64_t Hash, const InstrProfRecord &Counters, InstrProfSymtab &Symtab, raw_fd_ostream &OS)
 Write Record in text format to OS.
 

Detailed Description

Definition at line 40 of file InstrProfWriter.h.

Member Typedef Documentation

◆ ProfilingData

Definition at line 42 of file InstrProfWriter.h.

Constructor & Destructor Documentation

◆ InstrProfWriter()

InstrProfWriter::InstrProfWriter ( bool  Sparse = false,
uint64_t  TemporalProfTraceReservoirSize = 0,
uint64_t  MaxTemporalProfTraceLength = 0,
bool  WritePrevVersion = false,
memprof::IndexedVersion  MemProfVersionRequested = static_cast<memprof::IndexedVersion>(                                   memprof::MinimumSupportedVersion),
bool  MemProfFullSchema = false,
bool  MemprofGenerateRandomHotness = false,
unsigned  MemprofGenerateRandomHotnessSeed = 0 
)

Definition at line 123 of file InstrProfWriter.cpp.

References llvm::errs().

◆ ~InstrProfWriter()

InstrProfWriter::~InstrProfWriter ( )

Definition at line 146 of file InstrProfWriter.cpp.

Member Function Documentation

◆ addBinaryIds()

void InstrProfWriter::addBinaryIds ( ArrayRef< llvm::object::BuildID BIs)

Definition at line 324 of file InstrProfWriter.cpp.

References llvm::append_range().

Referenced by mergeRecordsFromWriter().

◆ addDataAccessProfData()

void InstrProfWriter::addDataAccessProfData ( std::unique_ptr< memprof::DataAccessProfData DataAccessProfile)

Definition at line 328 of file InstrProfWriter.cpp.

◆ addMemProfData()

bool InstrProfWriter::addMemProfData ( memprof::IndexedMemProfData  Incoming,
function_ref< void(Error)>  Warn 
)

◆ addRecord() [1/2]

void llvm::InstrProfWriter::addRecord ( NamedInstrProfRecord &&  I,
function_ref< void(Error)>  Warn 
)
inline

Definition at line 117 of file InstrProfWriter.h.

References addRecord(), and I.

◆ addRecord() [2/2]

void InstrProfWriter::addRecord ( NamedInstrProfRecord &&  I,
uint64_t  Weight,
function_ref< void(Error)>  Warn 
)

Add function counts for the given function.

If there are already counts for this function and the hash and number of counts match, each counter is summed. Optionally scale counts by Weight.

Definition at line 155 of file InstrProfWriter.cpp.

References addRecord(), I, and Name.

Referenced by addRecord(), and mergeRecordsFromWriter().

◆ addTemporalProfileTraces()

void InstrProfWriter::addTemporalProfileTraces ( SmallVectorImpl< TemporalProfTraceTy > &  SrcTraces,
uint64_t  SrcStreamSize 
)

Add SrcTraces using reservoir sampling where SrcStreamSize is the total number of temporal profiling traces the source has seen.

Definition at line 333 of file InstrProfWriter.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorBase< Size_T >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::erase_if(), I, llvm::shuffle(), and llvm::Trace::size().

Referenced by mergeRecordsFromWriter().

◆ addVTableName()

void llvm::InstrProfWriter::addVTableName ( StringRef  VTableName)
inline

Definition at line 120 of file InstrProfWriter.h.

References llvm::StringSet< AllocatorTy >::insert().

◆ getProfileData()

StringMap< ProfilingData > & llvm::InstrProfWriter::getProfileData ( )
inline

Definition at line 110 of file InstrProfWriter.h.

◆ getProfileKind()

InstrProfKind llvm::InstrProfWriter::getProfileKind ( ) const
inline

Definition at line 205 of file InstrProfWriter.h.

◆ hasSingleByteCoverage()

bool llvm::InstrProfWriter::hasSingleByteCoverage ( ) const
inline

Definition at line 207 of file InstrProfWriter.h.

References llvm::SingleByteCoverage.

◆ mergeProfileKind()

Error llvm::InstrProfWriter::mergeProfileKind ( const InstrProfKind  Other)
inline

Update the attributes of the current profile from the attributes specified.

An error is returned if IR and FE profiles are mixed.

Definition at line 168 of file InstrProfWriter.h.

References A, B, llvm::FrontendInstrumentation, llvm::FunctionEntryInstrumentation, llvm::FunctionEntryOnly, llvm::LoopEntriesInstrumentation, llvm::Other, llvm::Error::success(), llvm::Unknown, and llvm::unsupported_version.

◆ mergeRecordsFromWriter()

void InstrProfWriter::mergeRecordsFromWriter ( InstrProfWriter &&  IPW,
function_ref< void(Error)>  Warn 
)

◆ overlapRecord()

void InstrProfWriter::overlapRecord ( NamedInstrProfRecord &&  Other,
OverlapStats Overlap,
OverlapStats FuncLevelOverlap,
const OverlapFuncFilters FuncFilter 
)

◆ setMemProfFullSchema()

void llvm::InstrProfWriter::setMemProfFullSchema ( bool  Full)
inline

Definition at line 217 of file InstrProfWriter.h.

References llvm::Full.

◆ setMemProfVersionRequested()

void llvm::InstrProfWriter::setMemProfVersionRequested ( memprof::IndexedVersion  Version)
inline

Definition at line 214 of file InstrProfWriter.h.

References llvm::Version.

◆ setOutputSparse()

void InstrProfWriter::setOutputSparse ( bool  Sparse)

Definition at line 153 of file InstrProfWriter.cpp.

◆ setValueProfDataEndianness()

void InstrProfWriter::setValueProfDataEndianness ( llvm::endianness  Endianness)

◆ validateRecord()

Error InstrProfWriter::validateRecord ( const InstrProfRecord Func)

◆ write() [1/2]

Error InstrProfWriter::write ( raw_fd_ostream OS)

Write the profile to OS.

Definition at line 666 of file InstrProfWriter.cpp.

References OS.

Referenced by writeBuffer().

◆ write() [2/2]

Error InstrProfWriter::write ( raw_string_ostream OS)

Write the profile to a string output stream OS.

Definition at line 672 of file InstrProfWriter.cpp.

References OS.

◆ writeBuffer()

std::unique_ptr< MemoryBuffer > InstrProfWriter::writeBuffer ( )

Write the profile, returning the raw data. For testing.

Definition at line 677 of file InstrProfWriter.cpp.

References llvm::Data, llvm::MemoryBuffer::getMemBufferCopy(), OS, and write().

◆ writeRecordInText()

void InstrProfWriter::writeRecordInText ( StringRef  Name,
uint64_t  Hash,
const InstrProfRecord Counters,
InstrProfSymtab Symtab,
raw_fd_ostream OS 
)
static

Write Record in text format to OS.

Definition at line 708 of file InstrProfWriter.cpp.

References llvm::InstrProfSymtab::getFuncOrVarNameIfDefined(), Name, OS, ValueProfKindStr, and llvm::raw_ostream::write_hex().

Referenced by writeText().

◆ writeText()

Error InstrProfWriter::writeText ( raw_fd_ostream OS)

◆ writeTextTemporalProfTraceData()

void InstrProfWriter::writeTextTemporalProfTraceData ( raw_fd_ostream OS,
InstrProfSymtab Symtab 
)

Write temporal profile trace data to the header in text format to OS.

Definition at line 817 of file InstrProfWriter.cpp.

References llvm::InstrProfSymtab::getFuncOrVarName(), OS, and llvm::Trace::size().

Referenced by writeText().


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