LLVM 17.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

 InstrProfWriter (bool Sparse=false)
 
 ~InstrProfWriter ()
 
StringMap< ProfilingData > & getProfileData ()
 
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 addMemProfRecord (const GlobalValue::GUID Id, const memprof::IndexedMemProfRecord &Record)
 Add a memprof record for a function identified by its Id.
 
bool addMemProfFrame (const memprof::FrameId, const memprof::Frame &F, function_ref< void(Error)> Warn)
 Add a memprof frame identified by the hash of the contents of the frame in FrameId.
 
void addBinaryIds (ArrayRef< llvm::object::BuildID > BIs)
 
void mergeRecordsFromWriter (InstrProfWriter &&IPW, function_ref< void(Error)> Warn)
 Merge existing function counts from the given writer.
 
Error write (raw_fd_ostream &OS)
 Write the profile to OS.
 
Error writeText (raw_fd_ostream &OS)
 Write the profile in text format to OS.
 
Error validateRecord (const InstrProfRecord &Func)
 
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
 
void setValueProfDataEndianness (support::endianness Endianness)
 
void setOutputSparse (bool Sparse)
 
void overlapRecord (NamedInstrProfRecord &&Other, OverlapStats &Overlap, OverlapStats &FuncLevelOverlap, const OverlapFuncFilters &FuncFilter)
 

Static Public Member Functions

static 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 37 of file InstrProfWriter.h.

Member Typedef Documentation

◆ ProfilingData

Definition at line 39 of file InstrProfWriter.h.

Constructor & Destructor Documentation

◆ InstrProfWriter()

InstrProfWriter::InstrProfWriter ( bool  Sparse = false)

Definition at line 174 of file InstrProfWriter.cpp.

◆ ~InstrProfWriter()

InstrProfWriter::~InstrProfWriter ( )

Definition at line 177 of file InstrProfWriter.cpp.

Member Function Documentation

◆ addBinaryIds()

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

Definition at line 284 of file InstrProfWriter.cpp.

References llvm::append_range().

Referenced by mergeRecordsFromWriter().

◆ addMemProfFrame()

bool InstrProfWriter::addMemProfFrame ( const memprof::FrameId  Id,
const memprof::Frame F,
function_ref< void(Error)>  Warn 
)

Add a memprof frame identified by the hash of the contents of the frame in FrameId.

Definition at line 268 of file InstrProfWriter.cpp.

References llvm::malformed.

Referenced by mergeRecordsFromWriter().

◆ addMemProfRecord()

void InstrProfWriter::addMemProfRecord ( const GlobalValue::GUID  Id,
const memprof::IndexedMemProfRecord Record 
)

Add a memprof record for a function identified by its Id.

Definition at line 257 of file InstrProfWriter.cpp.

References llvm::memprof::IndexedMemProfRecord::merge().

Referenced by mergeRecordsFromWriter().

◆ addRecord() [1/2]

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

Definition at line 73 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 189 of file InstrProfWriter.cpp.

References addRecord(), I, and Name.

Referenced by addRecord(), and mergeRecordsFromWriter().

◆ getProfileData()

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

Definition at line 66 of file InstrProfWriter.h.

◆ getProfileKind()

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

Definition at line 146 of file InstrProfWriter.h.

◆ 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 111 of file InstrProfWriter.h.

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

◆ mergeRecordsFromWriter()

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

Merge existing function counts from the given writer.

Definition at line 288 of file InstrProfWriter.cpp.

References addBinaryIds(), addMemProfFrame(), addMemProfRecord(), addRecord(), and I.

◆ overlapRecord()

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

◆ setOutputSparse()

void InstrProfWriter::setOutputSparse ( bool  Sparse)

Definition at line 185 of file InstrProfWriter.cpp.

◆ setValueProfDataEndianness()

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

◆ validateRecord()

Error InstrProfWriter::validateRecord ( const InstrProfRecord Func)

◆ write()

Error InstrProfWriter::write ( raw_fd_ostream OS)

Write the profile to OS.

Definition at line 561 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 567 of file InstrProfWriter.cpp.

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

◆ 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 601 of file InstrProfWriter.cpp.

References llvm::InstrProfSymtab::getFuncNameOrExternalSymbol(), I, Name, OS, and ValueProfKindStr.

Referenced by writeText().

◆ writeText()

Error InstrProfWriter::writeText ( raw_fd_ostream OS)

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