LLVM  4.0.0
Public Member Functions | List of all members
llvm::sampleprof::FunctionSamples Class Reference

Representation of the samples collected for a function. More...

#include <SampleProf.h>

Public Member Functions

 FunctionSamples ()
 
void print (raw_ostream &OS=dbgs(), unsigned Indent=0) const
 Print the samples collected for a function on stream OS. More...
 
void dump () const
 
sampleprof_error addTotalSamples (uint64_t Num, uint64_t Weight=1)
 
sampleprof_error addHeadSamples (uint64_t Num, uint64_t Weight=1)
 
sampleprof_error addBodySamples (uint32_t LineOffset, uint32_t Discriminator, uint64_t Num, uint64_t Weight=1)
 
sampleprof_error addCalledTargetSamples (uint32_t LineOffset, uint32_t Discriminator, const std::string &FName, uint64_t Num, uint64_t Weight=1)
 
ErrorOr< uint64_t > findSamplesAt (uint32_t LineOffset, uint32_t Discriminator) const
 Return the number of samples collected at the given location. More...
 
ErrorOr< uint64_t > findCallSamplesAt (uint32_t LineOffset, uint32_t Discriminator) const
 Return the total number of call target samples collected at a given location. More...
 
FunctionSamplesfunctionSamplesAt (const LineLocation &Loc)
 Return the function samples at the given callsite location. More...
 
const FunctionSamplesfindFunctionSamplesAt (const LineLocation &Loc) const
 Return a pointer to function samples at the given callsite location. More...
 
bool empty () const
 
uint64_t getTotalSamples () const
 Return the total number of samples collected inside the function. More...
 
uint64_t getHeadSamples () const
 Return the total number of samples collected at the head of the function. More...
 
const BodySampleMapgetBodySamples () const
 Return all the samples collected in the body of the function. More...
 
const CallsiteSampleMapgetCallsiteSamples () const
 Return all the callsite samples collected in the body of the function. More...
 
sampleprof_error merge (const FunctionSamples &Other, uint64_t Weight=1)
 Merge the samples in Other into this one. More...
 
void setName (StringRef FunctionName)
 Set the name of the function. More...
 
const StringRefgetName () const
 Return the function name. More...
 

Detailed Description

Representation of the samples collected for a function.

This data structure contains all the collected samples for the body of a function. Each sample corresponds to a LineLocation instance within the body of the function.

Definition at line 181 of file SampleProf.h.

Constructor & Destructor Documentation

llvm::sampleprof::FunctionSamples::FunctionSamples ( )
inline

Definition at line 183 of file SampleProf.h.

Member Function Documentation

sampleprof_error llvm::sampleprof::FunctionSamples::addBodySamples ( uint32_t  LineOffset,
uint32_t  Discriminator,
uint64_t  Num,
uint64_t  Weight = 1 
)
inline
sampleprof_error llvm::sampleprof::FunctionSamples::addCalledTargetSamples ( uint32_t  LineOffset,
uint32_t  Discriminator,
const std::string &  FName,
uint64_t  Num,
uint64_t  Weight = 1 
)
inline
sampleprof_error llvm::sampleprof::FunctionSamples::addHeadSamples ( uint64_t  Num,
uint64_t  Weight = 1 
)
inline
sampleprof_error llvm::sampleprof::FunctionSamples::addTotalSamples ( uint64_t  Num,
uint64_t  Weight = 1 
)
inline
void FunctionSamples::dump ( void  ) const

Definition at line 139 of file SampleProf.cpp.

References llvm::dbgs().

bool llvm::sampleprof::FunctionSamples::empty ( ) const
inline

Definition at line 255 of file SampleProf.h.

ErrorOr<uint64_t> llvm::sampleprof::FunctionSamples::findCallSamplesAt ( uint32_t  LineOffset,
uint32_t  Discriminator 
) const
inline

Return the total number of call target samples collected at a given location.

Each location is specified by LineOffset and Discriminator. If the location is not found in profile, return error.

Definition at line 228 of file SampleProf.h.

References T.

const FunctionSamples* llvm::sampleprof::FunctionSamples::findFunctionSamplesAt ( const LineLocation Loc) const
inline

Return a pointer to function samples at the given callsite location.

Definition at line 246 of file SampleProf.h.

ErrorOr<uint64_t> llvm::sampleprof::FunctionSamples::findSamplesAt ( uint32_t  LineOffset,
uint32_t  Discriminator 
) const
inline

Return the number of samples collected at the given location.

Each location is specified by LineOffset and Discriminator. If the location is not found in profile, return error.

Definition at line 216 of file SampleProf.h.

FunctionSamples& llvm::sampleprof::FunctionSamples::functionSamplesAt ( const LineLocation Loc)
inline

Return the function samples at the given callsite location.

Definition at line 241 of file SampleProf.h.

Referenced by merge(), llvm::sampleprof::SampleProfileReaderGCC::readOneFunctionProfile(), and llvm::sampleprof::SampleProfileReaderBinary::readProfile().

const BodySampleMap& llvm::sampleprof::FunctionSamples::getBodySamples ( ) const
inline

Return all the samples collected in the body of the function.

Definition at line 265 of file SampleProf.h.

Referenced by llvm::SampleProfileSummaryBuilder::addRecord(), merge(), llvm::sampleprof::SampleProfileWriterText::write(), and llvm::sampleprof::SampleProfileWriterBinary::writeBody().

const CallsiteSampleMap& llvm::sampleprof::FunctionSamples::getCallsiteSamples ( ) const
inline

Return all the callsite samples collected in the body of the function.

Definition at line 268 of file SampleProf.h.

Referenced by merge(), llvm::sampleprof::SampleProfileWriterText::write(), and llvm::sampleprof::SampleProfileWriterBinary::writeBody().

uint64_t llvm::sampleprof::FunctionSamples::getHeadSamples ( ) const
inline

Return the total number of samples collected at the head of the function.

Definition at line 262 of file SampleProf.h.

Referenced by llvm::SampleProfileSummaryBuilder::addRecord(), merge(), llvm::sampleprof::SampleProfileWriterText::write(), and llvm::sampleprof::SampleProfileWriterBinary::write().

const StringRef& llvm::sampleprof::FunctionSamples::getName ( ) const
inline
uint64_t llvm::sampleprof::FunctionSamples::getTotalSamples ( ) const
inline
sampleprof_error llvm::sampleprof::FunctionSamples::merge ( const FunctionSamples Other,
uint64_t  Weight = 1 
)
inline

Merge the samples in Other into this one.

Optionally scale samples by Weight.

Definition at line 274 of file SampleProf.h.

References addHeadSamples(), addTotalSamples(), functionSamplesAt(), getBodySamples(), getCallsiteSamples(), getHeadSamples(), getName(), getTotalSamples(), I, llvm::MergeResult(), and llvm::success.

void FunctionSamples::print ( raw_ostream OS = dbgs(),
unsigned  Indent = 0 
) const

Print the samples collected for a function on stream OS.

Definition at line 99 of file SampleProf.cpp.

References llvm::sampleprof::SampleSorter< LocationT, SampleT >::get(), llvm::raw_ostream::indent(), and SI.

Referenced by llvm::sampleprof::operator<<().

void llvm::sampleprof::FunctionSamples::setName ( StringRef  FunctionName)
inline

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