LLVM  4.0.0
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 <InstrProfReader.h>

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

Public Member Functions

 InstrProfReader ()
 
virtual ~InstrProfReader ()
 
virtual Error readHeader ()=0
 Read the header. Required before reading first record. More...
 
virtual Error readNextRecord (InstrProfRecord &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 InstrProfRecords.

Definition at line 52 of file InstrProfReader.h.

Constructor & Destructor Documentation

llvm::InstrProfReader::InstrProfReader ( )
inline

Definition at line 56 of file InstrProfReader.h.

virtual llvm::InstrProfReader::~InstrProfReader ( )
inlinevirtual

Definition at line 57 of file InstrProfReader.h.

Member Function Documentation

InstrProfIterator llvm::InstrProfReader::begin ( )
inline

Iterator over profile data.

Definition at line 64 of file InstrProfReader.h.

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 35 of file InstrProfReader.cpp.

References E, and setupMemoryBuffer().

Expected< std::unique_ptr< InstrProfReader > > InstrProfReader::create ( std::unique_ptr< MemoryBuffer Buffer)
static
InstrProfIterator llvm::InstrProfReader::end ( )
inline

Definition at line 65 of file InstrProfReader.h.

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

Set the current error and return same.

Definition at line 83 of file InstrProfReader.h.

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

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

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

Definition at line 89 of file InstrProfReader.h.

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

Referenced by error().

Error llvm::InstrProfReader::getError ( )
inline

Get the current error.

Definition at line 100 of file InstrProfReader.h.

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

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.

bool llvm::InstrProfReader::hasError ( )
inline

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

Definition at line 98 of file InstrProfReader.h.

References isEOF(), and llvm::success.

Referenced by getError().

bool llvm::InstrProfReader::isEOF ( )
inline

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

Definition at line 96 of file InstrProfReader.h.

References llvm::eof.

Referenced by hasError().

virtual bool llvm::InstrProfReader::isIRLevelProfile ( ) const
pure virtual
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().

virtual Error llvm::InstrProfReader::readNextRecord ( InstrProfRecord Record)
pure virtual
Error llvm::InstrProfReader::success ( )
inlineprotected

Clear the current error and return a successful one.

Definition at line 92 of file InstrProfReader.h.

References error(), and llvm::success.

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

Member Data Documentation

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

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