LLVM  14.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::InstrProfReader Class Referenceabstract

Base class and interface for reading profiling data of any known instrprof format. More...

#include "llvm/ProfileData/InstrProfReader.h"

Inheritance diagram for llvm::InstrProfReader:
Inheritance graph
[legend]
Collaboration diagram for llvm::InstrProfReader:
Collaboration graph
[legend]

Public Member Functions

 InstrProfReader ()=default
 
virtual ~InstrProfReader ()=default
 
virtual Error readHeader ()=0
 Read the header. Required before reading first record. More...
 
virtual Error readNextRecord (NamedInstrProfRecord &Record)=0
 Read a single record. More...
 
virtual Error printBinaryIds (raw_ostream &OS)
 Print binary ids on stream OS. More...
 
InstrProfIterator begin ()
 Iterator over profile data. More...
 
InstrProfIterator end ()
 
virtual bool isIRLevelProfile () const =0
 
virtual bool hasCSIRLevelProfile () const =0
 
virtual bool instrEntryBBEnabled () const =0
 
virtual InstrProfSymtabgetSymtab ()=0
 Return the PGO symtab. More...
 
void accumulateCounts (CountSumOrPercent &Sum, bool IsCS)
 Compute the sum of counts and return in Sum. More...
 
bool isEOF ()
 Return true if the reader has finished reading the profile data. More...
 
bool hasError ()
 Return true if the reader encountered an error reading profiling data. More...
 
Error getError ()
 Get the current error. More...
 

Static Public Member Functions

static Expected< std::unique_ptr< InstrProfReader > > create (const Twine &Path)
 Factory method to create an appropriately typed reader for the given instrprof file. More...
 
static Expected< std::unique_ptr< InstrProfReader > > create (std::unique_ptr< MemoryBuffer > Buffer)
 

Protected Member Functions

Error error (instrprof_error Err, const std::string &ErrMsg="")
 Set the current error and return same. More...
 
Error error (Error &&E)
 
Error success ()
 Clear the current error and return a successful one. More...
 

Protected Attributes

std::unique_ptr< InstrProfSymtabSymtab
 

Detailed Description

Base class and interface for reading profiling data of any known instrprof format.

Provides an iterator over NamedInstrProfRecords.

Definition at line 72 of file InstrProfReader.h.

Constructor & Destructor Documentation

◆ InstrProfReader()

llvm::InstrProfReader::InstrProfReader ( )
default

◆ ~InstrProfReader()

virtual llvm::InstrProfReader::~InstrProfReader ( )
virtualdefault

Member Function Documentation

◆ accumulateCounts()

void InstrProfReader::accumulateCounts ( CountSumOrPercent Sum,
bool  IsCS 
)

Compute the sum of counts and return in Sum.

Definition at line 1015 of file InstrProfReader.cpp.

References llvm::NamedInstrProfRecord::hasCSFlagInHash(), and llvm::CountSumOrPercent::NumEntries.

◆ begin()

InstrProfIterator llvm::InstrProfReader::begin ( )
inline

Iterator over profile data.

Definition at line 90 of file InstrProfReader.h.

◆ create() [1/2]

Expected< std::unique_ptr< InstrProfReader > > InstrProfReader::create ( const Twine Path)
static

Factory method to create an appropriately typed reader for the given instrprof file.

Definition at line 55 of file InstrProfReader.cpp.

References E, move, and setupMemoryBuffer().

Referenced by llvm::OverlapStats::accumulateCounts().

◆ create() [2/2]

Expected< std::unique_ptr< InstrProfReader > > InstrProfReader::create ( std::unique_ptr< MemoryBuffer Buffer)
static

◆ end()

InstrProfIterator llvm::InstrProfReader::end ( )
inline

Definition at line 91 of file InstrProfReader.h.

◆ error() [1/2]

Error llvm::InstrProfReader::error ( Error &&  E)
inlineprotected

◆ error() [2/2]

Error llvm::InstrProfReader::error ( instrprof_error  Err,
const std::string &  ErrMsg = "" 
)
inlineprotected

Set the current error and return same.

Definition at line 118 of file InstrProfReader.h.

Referenced by llvm::TextInstrProfReader::readHeader(), llvm::TextInstrProfReader::readNextRecord(), and success().

◆ getError()

Error llvm::InstrProfReader::getError ( )
inline

Get the current error.

Definition at line 145 of file InstrProfReader.h.

References hasError(), and llvm::Error::success().

◆ getSymtab()

virtual InstrProfSymtab& llvm::InstrProfReader::getSymtab ( )
pure virtual

Return the PGO symtab.

There are three different readers: Raw, Text, and Indexed profile readers. The first two types of readers are used only by llvm-profdata tool, while the indexed profile reader is also used by llvm-cov tool and the compiler ( backend or frontend). Since creating PGO symtab can create significant runtime and memory overhead (as it touches data for the whole program), InstrProfSymtab for the indexed profile reader should be created on demand and it is recommended to be only used for dumping purpose with llvm-proftool, not with the compiler.

Implemented in llvm::IndexedInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::TextInstrProfReader.

◆ hasCSIRLevelProfile()

virtual bool llvm::InstrProfReader::hasCSIRLevelProfile ( ) const
pure virtual

◆ hasError()

bool llvm::InstrProfReader::hasError ( )
inline

Return true if the reader encountered an error reading profiling data.

Definition at line 142 of file InstrProfReader.h.

References isEOF(), and llvm::success.

Referenced by getError().

◆ instrEntryBBEnabled()

virtual bool llvm::InstrProfReader::instrEntryBBEnabled ( ) const
pure virtual

◆ isEOF()

bool llvm::InstrProfReader::isEOF ( )
inline

Return true if the reader has finished reading the profile data.

Definition at line 139 of file InstrProfReader.h.

References llvm::eof.

Referenced by hasError().

◆ isIRLevelProfile()

virtual bool llvm::InstrProfReader::isIRLevelProfile ( ) const
pure virtual

◆ printBinaryIds()

virtual Error llvm::InstrProfReader::printBinaryIds ( raw_ostream OS)
inlinevirtual

Print binary ids on stream OS.

Reimplemented in llvm::RawInstrProfReader< IntPtrT >.

Definition at line 87 of file InstrProfReader.h.

References success().

◆ readHeader()

virtual Error llvm::InstrProfReader::readHeader ( )
pure virtual

Read the header. Required before reading first record.

Implemented in llvm::IndexedInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::TextInstrProfReader.

Referenced by initializeReader().

◆ readNextRecord()

virtual Error llvm::InstrProfReader::readNextRecord ( NamedInstrProfRecord Record)
pure virtual

◆ success()

Error llvm::InstrProfReader::success ( )
inlineprotected

Clear the current error and return a successful one.

Definition at line 135 of file InstrProfReader.h.

References error(), and llvm::success.

Referenced by printBinaryIds(), llvm::TextInstrProfReader::readHeader(), and llvm::TextInstrProfReader::readNextRecord().

Member Data Documentation

◆ Symtab

std::unique_ptr<InstrProfSymtab> llvm::InstrProfReader::Symtab
protected

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