LLVM
15.0.0git
|
Representation of a single sample record. More...
#include "llvm/ProfileData/SampleProf.h"
Classes | |
struct | CallTargetComparator |
Public Types | |
using | CallTarget = std::pair< StringRef, uint64_t > |
using | SortedCallTargetSet = std::set< CallTarget, CallTargetComparator > |
using | CallTargetMap = StringMap< uint64_t > |
Public Member Functions | |
SampleRecord ()=default | |
sampleprof_error | addSamples (uint64_t S, uint64_t Weight=1) |
Increment the number of samples for this record by S . More... | |
uint64_t | removeSamples (uint64_t S) |
Decrease the number of samples for this record by S . More... | |
sampleprof_error | addCalledTarget (StringRef F, uint64_t S, uint64_t Weight=1) |
Add called function F with samples S . More... | |
uint64_t | removeCalledTarget (StringRef F) |
Remove called function from the call target map. More... | |
bool | hasCalls () const |
Return true if this sample record contains function calls. More... | |
uint64_t | getSamples () const |
const CallTargetMap & | getCallTargets () const |
const SortedCallTargetSet | getSortedCallTargets () const |
uint64_t | getCallTargetSum () const |
sampleprof_error | merge (const SampleRecord &Other, uint64_t Weight=1) |
Merge the samples in Other into this record. More... | |
void | print (raw_ostream &OS, unsigned Indent) const |
Print the sample record to the stream OS indented by Indent . More... | |
void | dump () const |
Static Public Member Functions | |
static const SortedCallTargetSet | SortCallTargets (const CallTargetMap &Targets) |
Sort call targets in descending order of call frequency. More... | |
static const CallTargetMap | adjustCallTargets (const CallTargetMap &Targets, float DistributionFactor) |
Prorate call targets by a distribution factor. More... | |
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.
Definition at line 317 of file SampleProf.h.
using llvm::sampleprof::SampleRecord::CallTarget = std::pair<StringRef, uint64_t> |
Definition at line 319 of file SampleProf.h.
Definition at line 330 of file SampleProf.h.
using llvm::sampleprof::SampleRecord::SortedCallTargetSet = std::set<CallTarget, CallTargetComparator> |
Definition at line 329 of file SampleProf.h.
|
default |
|
inline |
Add called function F
with samples S
.
Optionally scale sample count S
by Weight
.
Sample counts accumulate using saturating arithmetic, to avoid wrapping around unsigned integers.
Definition at line 359 of file SampleProf.h.
References llvm::counter_overflow, F, S, llvm::SaturatingMultiplyAdd(), and llvm::success.
Referenced by merge().
|
inline |
Increment the number of samples for this record by S
.
Optionally scale sample count S
by Weight
.
Sample counts accumulate using saturating arithmetic, to avoid wrapping around unsigned integers.
Definition at line 338 of file SampleProf.h.
References llvm::counter_overflow, S, llvm::SaturatingMultiplyAdd(), and llvm::success.
Referenced by merge().
|
inlinestatic |
Prorate call targets by a distribution factor.
Definition at line 407 of file SampleProf.h.
References I.
LLVM_DUMP_METHOD void SampleRecord::dump | ( | ) | const |
Definition at line 147 of file SampleProf.cpp.
References llvm::dbgs(), and print().
|
inline |
Definition at line 385 of file SampleProf.h.
|
inline |
Definition at line 390 of file SampleProf.h.
References I.
|
inline |
Definition at line 384 of file SampleProf.h.
|
inline |
|
inline |
Return true if this sample record contains function calls.
Definition at line 382 of file SampleProf.h.
References llvm::StringMapImpl::empty().
Referenced by print().
sampleprof_error SampleRecord::merge | ( | const SampleRecord & | Other, |
uint64_t | Weight = 1 |
||
) |
Merge the samples in Other
into this record.
Optionally scale sample counts by Weight
.
Definition at line 121 of file SampleProf.cpp.
References addCalledTarget(), addSamples(), I, llvm::MergeResult(), and Other.
void SampleRecord::print | ( | raw_ostream & | OS, |
unsigned | Indent | ||
) | const |
Print the sample record to the stream OS
indented by Indent
.
Definition at line 136 of file SampleProf.cpp.
References getSortedCallTargets(), hasCalls(), and I.
Referenced by dump().
Remove called function from the call target map.
Return the target sample count of the called function.
Definition at line 371 of file SampleProf.h.
References llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::StringMap< ValueTy, AllocatorTy >::erase(), F, llvm::StringMap< ValueTy, AllocatorTy >::find(), and I.
Decrease the number of samples for this record by S
.
Return the amout of samples actually decreased.
Definition at line 347 of file SampleProf.h.
References S.
|
inlinestatic |
Sort call targets in descending order of call frequency.
Definition at line 398 of file SampleProf.h.
References I.
Referenced by getSortedCallTargets(), and GetSortedValueDataFromCallTargets().