LLVM  7.0.0svn
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::sampleprof::SampleProfileReaderBinary Class Referenceabstract

#include "llvm/ProfileData/SampleProfReader.h"

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

Public Member Functions

 SampleProfileReaderBinary (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None)
 
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, SampleProfileFormat Format=SPF_None)
 
virtual ~SampleProfileReader ()=default
 
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 reportError (int64_t LineNumber, Twine Msg) const
 Report a parse error message. More...
 
ProfileSummarygetSummary ()
 Return the profile summary. More...
 
SampleProfileFormat getFormat ()
 Return the profile 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...
 
template<typename T >
ErrorOr< uint32_treadStringIndex (T &Table)
 Read the string index and check whether it overflows the table. More...
 
bool at_eof () const
 Return true if we've reached the end of file. More...
 
std::error_code readProfile (FunctionSamples &FProfile)
 Read the contents of the given profile instance. More...
 
- Protected Member Functions inherited from llvm::sampleprof::SampleProfileReader
void computeSummary ()
 Compute summary for this profile. More...
 

Protected Attributes

const uint8_t * Data = nullptr
 Points to the current location in the buffer. More...
 
const uint8_t * End = nullptr
 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...
 
std::unique_ptr< ProfileSummarySummary
 Profile summary information. More...
 
SampleProfileFormat Format = SPF_None
 The format of sample. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::sampleprof::SampleProfileReader
static ErrorOr< std::unique_ptr< SampleProfileReader > > create (const Twine &Filename, LLVMContext &C)
 Create a sample profile reader appropriate to the file format. More...
 
static ErrorOr< std::unique_ptr< SampleProfileReader > > create (std::unique_ptr< MemoryBuffer > &B, LLVMContext &C)
 Create a sample profile reader from the supplied memory buffer. More...
 

Detailed Description

Definition at line 360 of file SampleProfReader.h.

Constructor & Destructor Documentation

◆ SampleProfileReaderBinary()

llvm::sampleprof::SampleProfileReaderBinary::SampleProfileReaderBinary ( std::unique_ptr< MemoryBuffer B,
LLVMContext C,
SampleProfileFormat  Format = SPF_None 
)
inline

Member Function Documentation

◆ at_eof()

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

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

Definition at line 393 of file SampleProfReader.h.

References llvm::Data.

◆ read()

std::error_code SampleProfileReaderBinary::read ( )
overridevirtual

◆ readHeader()

std::error_code SampleProfileReaderBinary::readHeader ( )
overridevirtual

Read and validate the file header.

Implements llvm::sampleprof::SampleProfileReader.

Definition at line 491 of file SampleProfReader.cpp.

References llvm::sampleprof::SampleProfileReader::Buffer, and llvm::Data.

◆ readNumber()

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 288 of file SampleProfReader.cpp.

References llvm::Data, llvm::decodeULEB128(), llvm::malformed, and llvm::max().

◆ readProfile()

std::error_code SampleProfileReaderBinary::readProfile ( FunctionSamples FProfile)
protected

◆ readString()

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 309 of file SampleProfReader.cpp.

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

◆ readStringIndex()

template<typename T >
ErrorOr< uint32_t > SampleProfileReaderBinary::readStringIndex ( T Table)
inlineprotected

Read the string index and check whether it overflows the table.

Definition at line 323 of file SampleProfReader.cpp.

References llvm::truncated_name_table.

Member Data Documentation

◆ Data

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

Points to the current location in the buffer.

Definition at line 399 of file SampleProfReader.h.

◆ End

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

Points to the end of the buffer.

Definition at line 402 of file SampleProfReader.h.


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