LLVM  3.7.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::sampleprof::SampleProfileReaderBinary Class Reference

#include <SampleProfReader.h>

Inheritance diagram for llvm::sampleprof::SampleProfileReaderBinary:
[legend]
Collaboration diagram for llvm::sampleprof::SampleProfileReaderBinary:
[legend]

Public Member Functions

 SampleProfileReaderBinary (std::unique_ptr< MemoryBuffer > B, LLVMContext &C)
 
std::error_code readHeader () override
 Read and validate the file header. More...
 
std::error_code read () override
 Read sample profiles from the associated file. More...
 
- Public Member Functions inherited from llvm::sampleprof::SampleProfileReader
 SampleProfileReader (std::unique_ptr< MemoryBuffer > B, LLVMContext &C)
 
virtual ~SampleProfileReader ()
 
void dumpFunctionProfile (StringRef FName, raw_ostream &OS=dbgs())
 Print the profile for FName on stream OS. More...
 
void dump (raw_ostream &OS=dbgs())
 Print all the profiles on stream OS. More...
 
FunctionSamplesgetSamplesFor (const Function &F)
 Return the samples collected for function F. More...
 
StringMap< FunctionSamples > & getProfiles ()
 Return all the profiles. More...
 
void reportParseError (int64_t LineNumber, Twine Msg) const
 Report a parse error message. More...
 

Static Public Member Functions

static bool hasFormat (const MemoryBuffer &Buffer)
 Return true if Buffer is in the format supported by this class. More...
 
- Static Public Member Functions inherited from llvm::sampleprof::SampleProfileReader
static ErrorOr
< std::unique_ptr
< SampleProfileReader > > 
create (StringRef Filename, LLVMContext &C)
 Create a sample profile reader appropriate to the file format. More...
 

Protected Member Functions

template<typename T >
ErrorOr< TreadNumber ()
 Read a numeric value of type T from the profile. More...
 
ErrorOr< StringRefreadString ()
 Read a string from the profile. More...
 
bool at_eof () const
 Return true if we've reached the end of file. More...
 

Protected Attributes

const uint8_t * Data
 Points to the current location in the buffer. More...
 
const uint8_t * End
 Points to the end of the buffer. More...
 
- Protected Attributes inherited from llvm::sampleprof::SampleProfileReader
StringMap< FunctionSamplesProfiles
 Map every function to its associated profile. More...
 
LLVMContextCtx
 LLVM context used to emit diagnostics. More...
 
std::unique_ptr< MemoryBufferBuffer
 Memory buffer holding the profile file. More...
 

Detailed Description

Definition at line 125 of file SampleProfReader.h.

Constructor & Destructor Documentation

llvm::sampleprof::SampleProfileReaderBinary::SampleProfileReaderBinary ( std::unique_ptr< MemoryBuffer B,
LLVMContext C 
)
inline

Definition at line 127 of file SampleProfReader.h.

Member Function Documentation

bool llvm::sampleprof::SampleProfileReaderBinary::at_eof ( ) const
inlineprotected

Return true if we've reached the end of file.

Definition at line 157 of file SampleProfReader.h.

References Data, and End.

bool SampleProfileReaderBinary::hasFormat ( const MemoryBuffer Buffer)
static

Return true if Buffer is in the format supported by this class.

Definition at line 349 of file SampleProfReader.cpp.

References llvm::Data, llvm::decodeULEB128(), llvm::MemoryBuffer::getBufferStart(), Magic, and llvm::sampleprof::SPMagic().

Referenced by llvm::sampleprof::SampleProfileReader::create().

std::error_code SampleProfileReaderBinary::read ( )
overridevirtual
std::error_code SampleProfileReaderBinary::readHeader ( )
overridevirtual
template<typename T >
ErrorOr< T > SampleProfileReaderBinary::readNumber ( )
protected

Read a numeric value of type T from the profile.

If an error occurs during decoding, a diagnostic message is emitted and EC is set.

Returns
the read value.

Definition at line 233 of file SampleProfReader.cpp.

References llvm::Data, llvm::decodeULEB128(), llvm::malformed, llvm::success, and llvm::truncated.

ErrorOr< StringRef > SampleProfileReaderBinary::readString ( )
protected

Read a string from the profile.

If an error occurs during decoding, a diagnostic message is emitted and EC is set.

Returns
the read value.

Definition at line 254 of file SampleProfReader.cpp.

References llvm::Data, llvm::StringRef::size(), and llvm::truncated.

Member Data Documentation

const uint8_t* llvm::sampleprof::SampleProfileReaderBinary::Data
protected

Points to the current location in the buffer.

Definition at line 160 of file SampleProfReader.h.

Referenced by at_eof().

const uint8_t* llvm::sampleprof::SampleProfileReaderBinary::End
protected

Points to the end of the buffer.

Definition at line 163 of file SampleProfReader.h.

Referenced by at_eof().


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