LLVM  8.0.1
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...
 
InstrProfIterator begin ()
 Iterator over profile data. More...
 
InstrProfIterator end ()
 
virtual bool isIRLevelProfile () const =0
 
virtual InstrProfSymtabgetSymtab ()=0
 Return the PGO symtab. 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)
 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 62 of file InstrProfReader.h.

Constructor & Destructor Documentation

◆ InstrProfReader()

llvm::InstrProfReader::InstrProfReader ( )
default

◆ ~InstrProfReader()

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

Member Function Documentation

◆ begin()

InstrProfIterator llvm::InstrProfReader::begin ( )
inline

Iterator over profile data.

Definition at line 76 of file InstrProfReader.h.

References llvm::InstrProfIterator::InstrProfIterator().

◆ 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, and setupMemoryBuffer().

◆ 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 77 of file InstrProfReader.h.

References llvm::InstrProfIterator::InstrProfIterator().

◆ error() [1/2]

Error llvm::InstrProfReader::error ( instrprof_error  Err)
inlineprotected

◆ error() [2/2]

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

Definition at line 104 of file InstrProfReader.h.

References E, error(), and llvm::InstrProfError::take().

Referenced by error().

◆ getError()

Error llvm::InstrProfReader::getError ( )
inline

Get the current error.

Definition at line 117 of file InstrProfReader.h.

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

◆ hasError()

bool llvm::InstrProfReader::hasError ( )
inline

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

Definition at line 114 of file InstrProfReader.h.

References llvm::success.

◆ isEOF()

bool llvm::InstrProfReader::isEOF ( )
inline

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

Definition at line 111 of file InstrProfReader.h.

References llvm::eof.

◆ isIRLevelProfile()

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

◆ readHeader()

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

◆ readNextRecord()

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

◆ success()

Error llvm::InstrProfReader::success ( )
inlineprotected

Member Data Documentation

◆ Symtab

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

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