LLVM  6.0.0svn
Functions
SampleProfReader.cpp File Reference
#include "llvm/ProfileData/SampleProfReader.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/ProfileSummary.h"
#include "llvm/ProfileData/ProfileCommon.h"
#include "llvm/ProfileData/SampleProf.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <memory>
#include <system_error>
#include <vector>
Include dependency graph for SampleProfReader.cpp:

Go to the source code of this file.

Functions

static bool ParseHead (const StringRef &Input, StringRef &FName, uint64_t &NumSamples, uint64_t &NumHeadSamples)
 Parse Input as function head. More...
 
static bool isOffsetLegal (unsigned L)
 Returns true if line offset L is legal (only has 16 bits). More...
 
static bool ParseLine (const StringRef &Input, bool &IsCallsite, uint32_t &Depth, uint64_t &NumSamples, uint32_t &LineOffset, uint32_t &Discriminator, StringRef &CalleeName, DenseMap< StringRef, uint64_t > &TargetCountMap)
 Parse Input as line sample. More...
 
static ErrorOr< std::unique_ptr< MemoryBuffer > > setupMemoryBuffer (const Twine &Filename)
 Prepare a memory buffer for the contents of Filename. More...
 

Function Documentation

◆ isOffsetLegal()

static bool isOffsetLegal ( unsigned  L)
static

Returns true if line offset L is legal (only has 16 bits).

Definition at line 83 of file SampleProfReader.cpp.

Referenced by ParseLine(), and llvm::sampleprof::SampleProfileReaderBinary::readProfile().

◆ ParseHead()

static bool ParseHead ( const StringRef Input,
StringRef FName,
uint64_t &  NumSamples,
uint64_t &  NumHeadSamples 
)
static

Parse Input as function head.

Parse one line of Input, and update function name in FName, function's total sample count in NumSamples, function's entry count in NumHeadSamples.

Returns
true if parsing is successful.

Definition at line 68 of file SampleProfReader.cpp.

References llvm::StringRef::getAsInteger(), llvm::StringRef::rfind(), and llvm::StringRef::substr().

Referenced by llvm::sampleprof::SampleProfileReaderText::hasFormat(), and llvm::sampleprof::SampleProfileReaderText::read().

◆ ParseLine()

static bool ParseLine ( const StringRef Input,
bool IsCallsite,
uint32_t Depth,
uint64_t &  NumSamples,
uint32_t LineOffset,
uint32_t Discriminator,
StringRef CalleeName,
DenseMap< StringRef, uint64_t > &  TargetCountMap 
)
static

Parse Input as line sample.

Parameters
Inputinput line.
IsCallsitetrue if the line represents an inlined callsite.
Depththe depth of the inline stack.
NumSamplestotal samples of the line/inlined callsite.
LineOffsetline offset to the start of the function.
Discriminatordiscriminator of the line.
TargetCountMapmap from indirect call target to count.

returns true if parsing is successful.

Definition at line 96 of file SampleProfReader.cpp.

References llvm::count(), llvm::Depth, llvm::StringRef::find(), llvm::StringRef::find_first_not_of(), llvm::StringRef::find_last_of(), llvm::StringRef::getAsInteger(), isOffsetLegal(), llvm::StringRef::npos, and llvm::StringRef::substr().

Referenced by llvm::sampleprof::SampleProfileReaderText::read().

◆ setupMemoryBuffer()

static ErrorOr<std::unique_ptr<MemoryBuffer> > setupMemoryBuffer ( const Twine Filename)
static

Prepare a memory buffer for the contents of Filename.

Returns
an error code indicating the status of the buffer.

Definition at line 745 of file SampleProfReader.cpp.

References llvm::sampleprof::SampleProfileReader::Buffer, llvm::MemoryBuffer::getFileOrSTDIN(), llvm::max(), and llvm::too_large.

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