LLVM  4.0.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::sampleprof::SampleProfileWriter Class Referenceabstract

Sample-based profile writer. Base class. More...

#include <SampleProfWriter.h>

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

Public Member Functions

virtual ~SampleProfileWriter ()
 
virtual std::error_code write (const FunctionSamples &S)=0
 Write sample profiles in S. More...
 
std::error_code write (const StringMap< FunctionSamples > &ProfileMap)
 Write all the sample profiles in the given map of samples. More...
 
raw_ostreamgetOutputStream ()
 

Static Public Member Functions

static ErrorOr
< std::unique_ptr
< SampleProfileWriter > > 
create (StringRef Filename, SampleProfileFormat Format)
 Profile writer factory. More...
 
static ErrorOr
< std::unique_ptr
< SampleProfileWriter > > 
create (std::unique_ptr< raw_ostream > &OS, SampleProfileFormat Format)
 Create a new stream writer based on the value of Format. More...
 

Protected Member Functions

 SampleProfileWriter (std::unique_ptr< raw_ostream > &OS)
 
virtual std::error_code writeHeader (const StringMap< FunctionSamples > &ProfileMap)=0
 Write a file header for the profile file. More...
 
void computeSummary (const StringMap< FunctionSamples > &ProfileMap)
 Compute summary for this profile. More...
 

Protected Attributes

std::unique_ptr< raw_ostreamOutputStream
 Output stream where to emit the profile to. More...
 
std::unique_ptr< ProfileSummarySummary
 Profile summary. More...
 

Detailed Description

Sample-based profile writer. Base class.

Definition at line 31 of file SampleProfWriter.h.

Constructor & Destructor Documentation

virtual llvm::sampleprof::SampleProfileWriter::~SampleProfileWriter ( )
inlinevirtual

Definition at line 33 of file SampleProfWriter.h.

llvm::sampleprof::SampleProfileWriter::SampleProfileWriter ( std::unique_ptr< raw_ostream > &  OS)
inlineprotected

Definition at line 68 of file SampleProfWriter.h.

Member Function Documentation

void SampleProfileWriter::computeSummary ( const StringMap< FunctionSamples > &  ProfileMap)
protected
ErrorOr< std::unique_ptr< SampleProfileWriter > > SampleProfileWriter::create ( StringRef  Filename,
SampleProfileFormat  Format 
)
static

Profile writer factory.

Create a sample profile file writer based on the specified format.

Create a new file writer based on the value of Format.

Parameters
FilenameThe file to create.
WriterThe writer to instantiate according to the specified format.
FormatEncoding format for the profile file.
Returns
an error code indicating the status of the created writer.

Definition at line 213 of file SampleProfWriter.cpp.

References llvm::sys::fs::F_None, llvm::sys::fs::F_Text, and llvm::sampleprof::SPF_Binary.

ErrorOr< std::unique_ptr< SampleProfileWriter > > SampleProfileWriter::create ( std::unique_ptr< raw_ostream > &  OS,
SampleProfileFormat  Format 
)
static

Create a new stream writer based on the value of Format.

Create a sample profile stream writer based on the specified format.

For testing.

Parameters
OSThe output stream to store the profile data to.
WriterThe writer to instantiate according to the specified format.
FormatEncoding format for the profile file.
Returns
an error code indicating the status of the created writer.

Definition at line 236 of file SampleProfWriter.cpp.

References llvm::sampleprof::SPF_Binary, llvm::sampleprof::SPF_GCC, llvm::sampleprof::SPF_Text, llvm::unrecognized_format, and llvm::unsupported_writing_format.

raw_ostream& llvm::sampleprof::SampleProfileWriter::getOutputStream ( )
inline

Definition at line 54 of file SampleProfWriter.h.

References OutputStream.

virtual std::error_code llvm::sampleprof::SampleProfileWriter::write ( const FunctionSamples S)
pure virtual

Write sample profiles in S.

Returns
status code of the file update operation.

Implemented in llvm::sampleprof::SampleProfileWriterBinary, and llvm::sampleprof::SampleProfileWriterText.

Referenced by write().

std::error_code llvm::sampleprof::SampleProfileWriter::write ( const StringMap< FunctionSamples > &  ProfileMap)
inline

Write all the sample profiles in the given map of samples.

Returns
status code of the file update operation.

Definition at line 43 of file SampleProfWriter.h.

References I, llvm::success, write(), and writeHeader().

virtual std::error_code llvm::sampleprof::SampleProfileWriter::writeHeader ( const StringMap< FunctionSamples > &  ProfileMap)
protectedpure virtual

Write a file header for the profile file.

Implemented in llvm::sampleprof::SampleProfileWriterBinary, and llvm::sampleprof::SampleProfileWriterText.

Referenced by write().

Member Data Documentation

std::unique_ptr<raw_ostream> llvm::sampleprof::SampleProfileWriter::OutputStream
protected

Output stream where to emit the profile to.

Definition at line 76 of file SampleProfWriter.h.

Referenced by getOutputStream().

std::unique_ptr<ProfileSummary> llvm::sampleprof::SampleProfileWriter::Summary
protected

Profile summary.

Definition at line 79 of file SampleProfWriter.h.


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