class SampleRecord

Declaration

class SampleRecord { /* full declaration omitted */ };

Description

Representation of a single sample record. A sample record is represented by a positive integer value, which indicates how frequently was the associated line location executed. Additionally, if the associated location contains a function call, the record will hold a list of all the possible called targets. For direct calls, this will be the exact function being invoked. For indirect calls (function pointers, virtual table dispatch), this will be a list of one or more functions.

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:317

Member Variables

private uint64_t NumSamples = 0
private llvm::sampleprof::SampleRecord::CallTargetMap CallTargets

Method Overview

  • public SampleRecord()
  • public static const llvm::sampleprof::SampleRecord::SortedCallTargetSet SortCallTargets(const llvm::sampleprof::SampleRecord::CallTargetMap & Targets)
  • public llvm::sampleprof_error addCalledTarget(llvm::StringRef F, uint64_t S, uint64_t Weight = 1)
  • public llvm::sampleprof_error addSamples(uint64_t S, uint64_t Weight = 1)
  • public static const llvm::sampleprof::SampleRecord::CallTargetMap adjustCallTargets(const llvm::sampleprof::SampleRecord::CallTargetMap & Targets, float DistributionFactor)
  • public void dump() const
  • public uint64_t getCallTargetSum() const
  • public const llvm::sampleprof::SampleRecord::CallTargetMap & getCallTargets() const
  • public uint64_t getSamples() const
  • public const llvm::sampleprof::SampleRecord::SortedCallTargetSet getSortedCallTargets() const
  • public bool hasCalls() const
  • public llvm::sampleprof_error merge(const llvm::sampleprof::SampleRecord & Other, uint64_t Weight = 1)
  • public void print(llvm::raw_ostream & OS, unsigned int Indent) const
  • public uint64_t removeCalledTarget(llvm::StringRef F)
  • public uint64_t removeSamples(uint64_t S)

Methods

SampleRecord()

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:331

static const llvm::sampleprof::SampleRecord::
    SortedCallTargetSet
    SortCallTargets(
        const llvm::sampleprof::SampleRecord::
            CallTargetMap& Targets)

Description

Sort call targets in descending order of call frequency.

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:398

Parameters

const llvm::sampleprof::SampleRecord:: CallTargetMap& Targets

llvm::sampleprof_error addCalledTarget(
    llvm::StringRef F,
    uint64_t S,
    uint64_t Weight = 1)

Description

Add called function \p F with samples \p S. Optionally scale sample count \p S by \p Weight. Sample counts accumulate using saturating arithmetic, to avoid wrapping around unsigned integers.

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:359

Parameters

llvm::StringRef F
uint64_t S
uint64_t Weight = 1

llvm::sampleprof_error addSamples(
    uint64_t S,
    uint64_t Weight = 1)

Description

Increment the number of samples for this record by \p S. Optionally scale sample count \p S by \p Weight. Sample counts accumulate using saturating arithmetic, to avoid wrapping around unsigned integers.

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:338

Parameters

uint64_t S
uint64_t Weight = 1

static const llvm::sampleprof::SampleRecord::
    CallTargetMap
    adjustCallTargets(
        const llvm::sampleprof::SampleRecord::
            CallTargetMap& Targets,
        float DistributionFactor)

Description

Prorate call targets by a distribution factor.

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:407

Parameters

const llvm::sampleprof::SampleRecord:: CallTargetMap& Targets
float DistributionFactor

void dump() const

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:420

uint64_t getCallTargetSum() const

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:390

const llvm::sampleprof::SampleRecord::
    CallTargetMap&
    getCallTargets() const

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:385

uint64_t getSamples() const

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:384

const llvm::sampleprof::SampleRecord::
    SortedCallTargetSet
    getSortedCallTargets() const

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:386

bool hasCalls() const

Description

Return true if this sample record contains function calls.

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:382

llvm::sampleprof_error merge(
    const llvm::sampleprof::SampleRecord& Other,
    uint64_t Weight = 1)

Description

Merge the samples in \p Other into this record. Optionally scale sample counts by \p Weight.

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:418

Parameters

const llvm::sampleprof::SampleRecord& Other
uint64_t Weight = 1

void print(llvm::raw_ostream& OS,
           unsigned int Indent) const

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:419

Parameters

llvm::raw_ostream& OS
unsigned int Indent

uint64_t removeCalledTarget(llvm::StringRef F)

Description

Remove called function from the call target map. Return the target sample count of the called function.

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:371

Parameters

llvm::StringRef F

uint64_t removeSamples(uint64_t S)

Description

Decrease the number of samples for this record by \p S. Return the amout of samples actually decreased.

Declared at: llvm/include/llvm/ProfileData/SampleProf.h:347

Parameters

uint64_t S