LLVM  10.0.0svn
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 "llvm/ProfileData/SampleProfWriter.h"

Inheritance diagram for llvm::sampleprof::SampleProfileWriter:
Inheritance graph
Collaboration diagram for llvm::sampleprof::SampleProfileWriter:
Collaboration graph

Public Member Functions

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

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...
virtual std::error_code writeFuncProfiles (const StringMap< FunctionSamples > &ProfileMap)
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...
SampleProfileFormat Format
 Profile format. More...

Detailed Description

Sample-based profile writer. Base class.

Definition at line 32 of file SampleProfWriter.h.

Constructor & Destructor Documentation

◆ ~SampleProfileWriter()

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

◆ SampleProfileWriter()

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

Definition at line 62 of file SampleProfWriter.h.

References writeFuncProfiles(), and writeHeader().

Member Function Documentation

◆ computeSummary()

void SampleProfileWriter::computeSummary ( const StringMap< FunctionSamples > &  ProfileMap)

◆ create() [1/2]

ErrorOr< std::unique_ptr< SampleProfileWriter > > SampleProfileWriter::create ( StringRef  Filename,
SampleProfileFormat  Format 

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.

FilenameThe file to create.
FormatEncoding format for the profile file.
an error code indicating the status of the created writer.

Definition at line 469 of file SampleProfWriter.cpp.

References llvm::sys::fs::OF_None, llvm::sys::fs::OF_Text, llvm::sampleprof::SPF_Binary, llvm::sampleprof::SPF_Compact_Binary, and llvm::sampleprof::SPF_Ext_Binary.

Referenced by getOutputStream(), and llvm::sampleprof::SampleProfileWriterText::writeHeader().

◆ create() [2/2]

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

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

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

For testing.

OSThe output stream to store the profile data to.
FormatEncoding format for the profile file.
an error code indicating the status of the created writer.

Definition at line 491 of file SampleProfWriter.cpp.

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

◆ getOutputStream()

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

Definition at line 46 of file SampleProfWriter.h.

References create(), Format, and OutputStream.

◆ setProfileSymbolList()

virtual void llvm::sampleprof::SampleProfileWriter::setProfileSymbolList ( ProfileSymbolList PSL)

Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinary.

Definition at line 59 of file SampleProfWriter.h.

◆ write()

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

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

status code of the file update operation.

Reimplemented in llvm::sampleprof::SampleProfileWriterCompactBinary, and llvm::sampleprof::SampleProfileWriterExtBinaryBase.

Definition at line 65 of file SampleProfWriter.cpp.

References llvm::success, writeFuncProfiles(), and writeHeader().

Referenced by llvm::sampleprof::SampleProfileWriterCompactBinary::write().

◆ writeFuncProfiles()

std::error_code SampleProfileWriter::writeFuncProfiles ( const StringMap< FunctionSamples > &  ProfileMap)

◆ writeHeader()

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

◆ writeSample()

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

Member Data Documentation

◆ Format

SampleProfileFormat llvm::sampleprof::SampleProfileWriter::Format

◆ OutputStream

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

◆ Summary

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

Profile summary.

Definition at line 77 of file SampleProfWriter.h.

Referenced by computeSummary(), and llvm::sampleprof::SampleProfileWriterBinary::writeSummary().

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