|
LLVM
7.0.0
|
Representation of the samples collected for a function. More...
#include "llvm/ProfileData/SampleProf.h"
Public Member Functions | |
| FunctionSamples ()=default | |
| 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, StringRef 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< SampleRecord::CallTargetMap > | findCallTargetMapAt (uint32_t LineOffset, uint32_t Discriminator) const |
| Returns the call target map collected at a given location. More... | |
| FunctionSamplesMap & | functionSamplesAt (const LineLocation &Loc) |
| Return the function samples at the given callsite location. More... | |
| const FunctionSamplesMap * | findFunctionSamplesMapAt (const LineLocation &Loc) const |
Returns the FunctionSamplesMap at the given Loc. More... | |
| const FunctionSamples * | findFunctionSamplesAt (const LineLocation &Loc, StringRef CalleeName) const |
Returns a pointer to FunctionSamples at the given callsite location Loc with callee CalleeName. 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 branch samples that have the function as the branch target. More... | |
| uint64_t | getEntrySamples () const |
| Return the sample count of the first instruction of the function. More... | |
| const BodySampleMap & | getBodySamples () const |
| Return all the samples collected in the body of the function. More... | |
| const CallsiteSampleMap & | getCallsiteSamples () 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 | findInlinedFunctions (DenseSet< GlobalValue::GUID > &S, const Module *M, uint64_t Threshold, bool isCompact) const |
Recursively traverses all children, if the total sample count of the corresponding function is no less than Threshold, add its corresponding GUID to S. More... | |
| void | setName (StringRef FunctionName) |
| Set the name of the function. More... | |
| const StringRef & | getName () const |
| Return the function name. More... | |
| const FunctionSamples * | findFunctionSamples (const DILocation *DIL) const |
| Get the FunctionSamples of the inline instance where DIL originates from. More... | |
Static Public Member Functions | |
| static unsigned | getOffset (const DILocation *DIL) |
| Returns the line offset to the start line of the subprogram. More... | |
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 216 of file SampleProf.h.
|
default |
|
inline |
Definition at line 239 of file SampleProf.h.
Referenced by llvm::sampleprof::SampleProfileReaderText::read(), llvm::sampleprof::SampleProfileReaderGCC::readOneFunctionProfile(), and llvm::sampleprof::SampleProfileReaderBinary::readProfile().
|
inline |
Definition at line 245 of file SampleProf.h.
Referenced by llvm::sampleprof::SampleProfileReaderText::read(), llvm::sampleprof::SampleProfileReaderGCC::readOneFunctionProfile(), and llvm::sampleprof::SampleProfileReaderBinary::readProfile().
|
inline |
Definition at line 231 of file SampleProf.h.
References llvm::counter_overflow, llvm::SaturatingMultiplyAdd(), and llvm::success.
Referenced by llvm::sampleprof::SampleProfileReaderText::read(), llvm::sampleprof::SampleProfileReaderBinary::read(), and llvm::sampleprof::SampleProfileReaderGCC::readOneFunctionProfile().
|
inline |
Definition at line 223 of file SampleProf.h.
References llvm::counter_overflow, llvm::SaturatingMultiplyAdd(), and llvm::success.
Referenced by llvm::sampleprof::SampleProfileReaderText::read(), and llvm::sampleprof::SampleProfileReaderBinary::readProfile().
| LLVM_DUMP_METHOD void FunctionSamples::dump | ( | ) | const |
Definition at line 182 of file SampleProf.cpp.
References llvm::dbgs(), and print().
|
inline |
Definition at line 314 of file SampleProf.h.
|
inline |
Returns the call target map 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 269 of file SampleProf.h.
Referenced by callsiteIsHot(), and SortCallTargets().
| const FunctionSamples * FunctionSamples::findFunctionSamples | ( | const DILocation * | DIL | ) | const |
Get the FunctionSamples of the inline instance where DIL originates from.
The FunctionSamples of the instruction (Machine or IR) associated to DIL is the inlined instance in which that instruction is coming from. We traverse the inline stack of that instruction, and match it with the tree nodes in the profile.
Definition at line 161 of file SampleProf.cpp.
References assert(), findFunctionSamplesAt(), first, llvm::DILocation::getBaseDiscriminator(), llvm::getOffset(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), second, and llvm::SmallVectorBase::size().
|
inline |
Returns a pointer to FunctionSamples at the given callsite location Loc with callee CalleeName.
If no callsite can be found, relax the restriction to return the FunctionSamples at callsite location Loc with the maximum total sample count.
Definition at line 294 of file SampleProf.h.
References for().
Referenced by callsiteIsHot(), and findFunctionSamples().
|
inline |
Returns the FunctionSamplesMap at the given Loc.
Definition at line 283 of file SampleProf.h.
Referenced by callsiteIsHot().
|
inline |
Recursively traverses all children, if the total sample count of the corresponding function is no less than Threshold, add its corresponding GUID to S.
Also traverse the BodySamples to add hot CallTarget's GUID to S.
Definition at line 379 of file SampleProf.h.
References Callee, llvm::Module::getFunction(), llvm::GlobalValue::getGUID(), llvm::Function::getSubprogram(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), and Threshold.
Referenced by callsiteIsHot().
|
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 256 of file SampleProf.h.
Referenced by callsiteIsHot().
|
inline |
Return the function samples at the given callsite location.
Definition at line 277 of file SampleProf.h.
Referenced by llvm::sampleprof::SampleProfileReaderGCC::readOneFunctionProfile(), and llvm::sampleprof::SampleProfileReaderBinary::readProfile().
|
inline |
Return all the samples collected in the body of the function.
Definition at line 347 of file SampleProf.h.
Referenced by llvm::SampleProfileSummaryBuilder::addRecord(), callsiteIsHot(), merge(), llvm::sampleprof::SampleProfileWriterText::write(), llvm::sampleprof::SampleProfileWriterBinary::writeBody(), and llvm::sampleprof::SampleProfileWriterBinary::writeNameIdx().
|
inline |
Return all the callsite samples collected in the body of the function.
Definition at line 350 of file SampleProf.h.
Referenced by callsiteIsHot(), merge(), llvm::sampleprof::SampleProfileWriterText::write(), llvm::sampleprof::SampleProfileWriterBinary::writeBody(), and llvm::sampleprof::SampleProfileWriterBinary::writeNameIdx().
|
inline |
Return the sample count of the first instruction of the function.
The function can be either a standalone symbol or an inlined function.
Definition at line 328 of file SampleProf.h.
References T.
Referenced by callsiteIsHot().
|
inline |
Return the total number of branch samples that have the function as the branch target.
This should be equivalent to the sample of the first instruction of the symbol. But as we directly get this info for raw profile without referring to potentially inaccurate debug info, this gives more accurate profile data and is preferred for standalone symbols.
Definition at line 324 of file SampleProf.h.
Referenced by llvm::SampleProfileSummaryBuilder::addRecord(), merge(), llvm::sampleprof::SampleProfileWriterText::write(), and llvm::sampleprof::SampleProfileWriterBinary::write().
Return the function name.
Definition at line 403 of file SampleProf.h.
References llvm::getOffset(), and llvm::operator<<().
Referenced by callsiteIsHot(), merge(), llvm::sampleprof::SampleProfileWriterText::write(), llvm::sampleprof::SampleProfileWriterBinary::writeBody(), and llvm::sampleprof::SampleProfileWriterBinary::writeNameIdx().
|
static |
Returns the line offset to the start line of the subprogram.
We assume that a single function will not exceed 65535 LOC.
Definition at line 155 of file SampleProf.cpp.
Referenced by callsiteIsHot(), and SortCallTargets().
|
inline |
Return the total number of samples collected inside the function.
Definition at line 317 of file SampleProf.h.
Referenced by callsiteIsHot(), merge(), llvm::sampleprof::SampleProfileReaderGCC::readOneFunctionProfile(), llvm::sampleprof::SampleProfileWriterText::write(), and llvm::sampleprof::SampleProfileWriterBinary::writeBody().
|
inline |
Merge the samples in Other into this one.
Optionally scale samples by Weight.
Definition at line 356 of file SampleProf.h.
References getBodySamples(), getCallsiteSamples(), getHeadSamples(), getName(), getTotalSamples(), I, llvm::MergeResult(), Result, 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 113 of file SampleProf.cpp.
References llvm::sampleprof::SampleSorter< LocationT, SampleT >::get(), llvm::raw_ostream::indent(), and SI.
Referenced by llvm::sampleprof::operator<<().
|
inline |
Set the name of the function.
Definition at line 400 of file SampleProf.h.
Referenced by llvm::sampleprof::SampleProfileReaderText::read(), llvm::sampleprof::SampleProfileReaderBinary::read(), llvm::sampleprof::SampleProfileReaderGCC::readOneFunctionProfile(), and llvm::sampleprof::SampleProfileReaderBinary::readProfile().
1.8.13