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

enum  ProfKind { PF_Unknown = 0, PF_FE, PF_IRLevel, PF_IRLevelWithCS }
using ProfilingData = SmallDenseMap< uint64_t, InstrProfRecord >

Public Member Functions

 InstrProfWriter (bool Sparse=false, bool InstrEntryBBEnabled=false)
 ~InstrProfWriter ()
StringMap< ProfilingData > & getProfileData ()
void addRecord (NamedInstrProfRecord &&I, uint64_t Weight, function_ref< void(Error)> Warn)
 Add function counts for the given function. More...
void addRecord (NamedInstrProfRecord &&I, function_ref< void(Error)> Warn)
void mergeRecordsFromWriter (InstrProfWriter &&IPW, function_ref< void(Error)> Warn)
 Merge existing function counts from the given writer. More...
Error write (raw_fd_ostream &OS)
 Write the profile to OS. More...
Error writeText (raw_fd_ostream &OS)
 Write the profile in text format to OS. More...
Error validateRecord (const InstrProfRecord &Func)
std::unique_ptr< MemoryBufferwriteBuffer ()
 Write the profile, returning the raw data. For testing. More...
Error setIsIRLevelProfile (bool IsIRLevel, bool WithCS)
 Set the ProfileKind. More...
void setInstrEntryBBEnabled (bool Enabled)
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. More...

Detailed Description

Definition at line 33 of file InstrProfWriter.h.

Member Typedef Documentation

◆ ProfilingData

Definition at line 35 of file InstrProfWriter.h.

Member Enumeration Documentation

◆ ProfKind


Definition at line 37 of file InstrProfWriter.h.

Constructor & Destructor Documentation

◆ InstrProfWriter()

InstrProfWriter::InstrProfWriter ( bool  Sparse = false,
bool  InstrEntryBBEnabled = false 

Definition at line 168 of file InstrProfWriter.cpp.

◆ ~InstrProfWriter()

InstrProfWriter::~InstrProfWriter ( )

Definition at line 172 of file InstrProfWriter.cpp.

Member Function Documentation

◆ addRecord() [1/2]

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

Definition at line 58 of file InstrProfWriter.h.

References addRecord(), I, and move.

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

References I, and move.

Referenced by addRecord(), and mergeRecordsFromWriter().

◆ getProfileData()

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

Definition at line 51 of file InstrProfWriter.h.

◆ mergeRecordsFromWriter()

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

Merge existing function counts from the given writer.

Definition at line 252 of file InstrProfWriter.cpp.

References addRecord(), I, and move.

◆ overlapRecord()

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

◆ setInstrEntryBBEnabled()

void llvm::InstrProfWriter::setInstrEntryBBEnabled ( bool  Enabled)

Definition at line 105 of file InstrProfWriter.h.

References Enabled.

◆ setIsIRLevelProfile()

Error llvm::InstrProfWriter::setIsIRLevelProfile ( bool  IsIRLevel,
bool  WithCS 

Set the ProfileKind.

Report error if mixing FE and IR level profiles. WithCS indicates if this is for contenxt sensitive instrumentation.

Definition at line 84 of file InstrProfWriter.h.

References PF_FE, PF_IRLevel, PF_IRLevelWithCS, PF_Unknown, llvm::Error::success(), and llvm::unsupported_version.

◆ setOutputSparse()

void InstrProfWriter::setOutputSparse ( bool  Sparse)

Definition at line 180 of file InstrProfWriter.cpp.

◆ setValueProfDataEndianness()

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

◆ validateRecord()

Error InstrProfWriter::validateRecord ( const InstrProfRecord Func)

Definition at line 409 of file InstrProfWriter.cpp.

References I, llvm::invalid_prof, S, and llvm::Error::success().

Referenced by writeText().

◆ write()

Error InstrProfWriter::write ( raw_fd_ostream OS)

Write the profile to OS.

Definition at line 387 of file InstrProfWriter.cpp.

◆ writeBuffer()

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

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

Definition at line 393 of file InstrProfWriter.cpp.

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

◆ writeRecordInText()

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

Write Record in text format to OS.

Definition at line 430 of file InstrProfWriter.cpp.

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

Referenced by writeText().

◆ writeText()

Error InstrProfWriter::writeText ( raw_fd_ostream OS)

Write the profile in text format to OS.

Definition at line 471 of file InstrProfWriter.cpp.

References llvm::InstrProfSymtab::addFuncName(), B, E, I, PF_IRLevel, PF_IRLevelWithCS, llvm::sort(), llvm::Error::success(), validateRecord(), and writeRecordInText().

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