class FunctionSamples
Declaration
class FunctionSamples { /* full declaration omitted */ };
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.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:710
Member Variables
- public DenseMap<uint64_t, llvm::StringRef>* GUIDToFuncNameMap = nullptr
- GUIDToFuncNameMap saves the mapping from GUID to the symbol name, for all the function symbols defined or declared in current module.
- private uint64_t FunctionHash = 0
- CFG hash value for the function.
- private llvm::sampleprof::SampleContext Context
- Calling context for function profile
- private uint64_t TotalSamples = 0
- Samples are cumulative, they include all the samples collected inside this function and all its inlined callees.
- private uint64_t TotalHeadSamples = 0
- Total number of samples collected at the head of the function. This is an approximation of the number of calls made to this function at runtime.
- private llvm::sampleprof::BodySampleMap BodySamples
- Each entry in this map contains the number of samples collected at the corresponding line offset. All line locations are an offset from the start of the function.
- private llvm::sampleprof::CallsiteSampleMap CallsiteSamples
- If the bar() and baz() calls were inlined inside foo(), this map will contain two entries. One for all the samples collected in the call to bar() at line offset 1, the other for all the samples collected in the call to baz() at line offset 8.
- public static const char* const LLVMSuffix = ".llvm."
- Name suffixes which canonicalization should handle to avoid profile mismatch.
- public static const char* const PartSuffix = ".part."
- public static const char* const UniqSuffix = ".__uniq."
- public static bool ProfileIsProbeBased
- public static bool ProfileIsCS
- public static bool ProfileIsPreInlined
- public static bool UseMD5
- Whether the profile uses MD5 to represent string.
- public static bool HasUniqSuffix
- Whether the profile contains any ".__uniq." suffix in a name.
- public static bool ProfileIsFS
- If this profile uses flow sensitive discriminators.
Method Overview
- public FunctionSamples()
- public void SetContextSynthetic()
- public llvm::sampleprof_error addBodySamples(uint32_t LineOffset, uint32_t Discriminator, uint64_t Num, uint64_t Weight = 1)
- public llvm::sampleprof_error addBodySamplesForProbe(uint32_t Index, uint64_t Num, uint64_t Weight = 1)
- public llvm::sampleprof_error addCalledTargetSamples(uint32_t LineOffset, uint32_t Discriminator, llvm::StringRef FName, uint64_t Num, uint64_t Weight = 1)
- public llvm::sampleprof_error addHeadSamples(uint64_t Num, uint64_t Weight = 1)
- public llvm::sampleprof_error addTotalSamples(uint64_t Num, uint64_t Weight = 1)
- public void dump() const
- public bool empty() const
- public void findAllNames(DenseSet<llvm::StringRef> & NameSet) const
- public ErrorOr<SampleRecord::CallTargetMap> findCallTargetMapAt(uint32_t LineOffset, uint32_t Discriminator) const
- public ErrorOr<SampleRecord::CallTargetMap> findCallTargetMapAt(const llvm::sampleprof::LineLocation & CallSite) const
- public const llvm::sampleprof::FunctionSamples * findFunctionSamples(const llvm::DILocation * DIL, llvm::sampleprof::SampleProfileReaderItaniumRemapper * Remapper = nullptr) const
- public const llvm::sampleprof::FunctionSamples * findFunctionSamplesAt(const llvm::sampleprof::LineLocation & Loc, llvm::StringRef CalleeName, llvm::sampleprof::SampleProfileReaderItaniumRemapper * Remapper) const
- public const llvm::sampleprof::FunctionSamplesMap * findFunctionSamplesMapAt(const llvm::sampleprof::LineLocation & Loc) const
- public void findInlinedFunctions(DenseSet<GlobalValue::GUID> & S, const StringMap<llvm::Function *> & SymbolMap, uint64_t Threshold) const
- public ErrorOr<uint64_t> findSamplesAt(uint32_t LineOffset, uint32_t Discriminator) const
- public llvm::sampleprof::FunctionSamplesMap & functionSamplesAt(const llvm::sampleprof::LineLocation & Loc)
- public const llvm::sampleprof::BodySampleMap & getBodySamples() const
- public static uint64_t getCallSiteHash(llvm::StringRef CalleeName, const llvm::sampleprof::LineLocation & Callsite)
- public static llvm::sampleprof::LineLocation getCallSiteIdentifier(const llvm::DILocation * DIL, bool ProfileIsFS = false)
- public const llvm::sampleprof::CallsiteSampleMap & getCallsiteSamples() const
- public static llvm::StringRef getCanonicalFnName(const llvm::Function & F)
- public static llvm::StringRef getCanonicalFnName(llvm::StringRef FnName, llvm::StringRef Attr = "selected")
- public llvm::sampleprof::SampleContext & getContext() const
- public llvm::StringRef getFuncName() const
- public llvm::StringRef getFuncName(llvm::StringRef Name) const
- public uint64_t getFunctionHash() const
- public static uint64_t getGUID(llvm::StringRef Name)
- public uint64_t getHeadSamples() const
- public uint64_t getHeadSamplesEstimate() const
- public uint64_t getMaxCountInside() const
- public llvm::StringRef getName() const
- public static unsigned int getOffset(const llvm::DILocation * DIL)
- public uint64_t getTotalSamples() const
- public llvm::sampleprof_error merge(const llvm::sampleprof::FunctionSamples & Other, uint64_t Weight = 1)
- public void print(llvm::raw_ostream & OS = dbgs(), unsigned int Indent = 0) const
- public uint64_t removeCalledTargetAndBodySample(uint32_t LineOffset, uint32_t Discriminator, llvm::StringRef FName)
- public void removeTotalSamples(uint64_t Num)
- public void setContext(const llvm::sampleprof::SampleContext & FContext)
- public void setFunctionHash(uint64_t Hash)
- public void setName(llvm::StringRef FunctionName)
- public void setTotalSamples(uint64_t Num)
- public void updateCallsiteSamples()
- public void updateTotalSamples()
Methods
¶FunctionSamples()
FunctionSamples()
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:712
¶void SetContextSynthetic()
void SetContextSynthetic()
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:807
¶llvm::sampleprof_error addBodySamples(
uint32_t LineOffset,
uint32_t Discriminator,
uint64_t Num,
uint64_t Weight = 1)
llvm::sampleprof_error addBodySamples(
uint32_t LineOffset,
uint32_t Discriminator,
uint64_t Num,
uint64_t Weight = 1)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:742
Parameters
- uint32_t LineOffset
- uint32_t Discriminator
- uint64_t Num
- uint64_t Weight = 1
¶llvm::sampleprof_error addBodySamplesForProbe(
uint32_t Index,
uint64_t Num,
uint64_t Weight = 1)
llvm::sampleprof_error addBodySamplesForProbe(
uint32_t Index,
uint64_t Num,
uint64_t Weight = 1)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:772
Parameters
- uint32_t Index
- uint64_t Num
- uint64_t Weight = 1
¶llvm::sampleprof_error addCalledTargetSamples(
uint32_t LineOffset,
uint32_t Discriminator,
llvm::StringRef FName,
uint64_t Num,
uint64_t Weight = 1)
llvm::sampleprof_error addCalledTargetSamples(
uint32_t LineOffset,
uint32_t Discriminator,
llvm::StringRef FName,
uint64_t Num,
uint64_t Weight = 1)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:748
Parameters
- uint32_t LineOffset
- uint32_t Discriminator
- llvm::StringRef FName
- uint64_t Num
- uint64_t Weight = 1
¶llvm::sampleprof_error addHeadSamples(
uint64_t Num,
uint64_t Weight = 1)
llvm::sampleprof_error addHeadSamples(
uint64_t Num,
uint64_t Weight = 1)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:734
Parameters
- uint64_t Num
- uint64_t Weight = 1
¶llvm::sampleprof_error addTotalSamples(
uint64_t Num,
uint64_t Weight = 1)
llvm::sampleprof_error addTotalSamples(
uint64_t Num,
uint64_t Weight = 1)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:717
Parameters
- uint64_t Num
- uint64_t Weight = 1
¶void dump() const
void dump() const
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:715
¶bool empty() const
bool empty() const
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:872
¶void findAllNames(
DenseSet<llvm::StringRef>& NameSet) const
void findAllNames(
DenseSet<llvm::StringRef>& NameSet) const
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1138
Parameters
- DenseSet<llvm::StringRef>& NameSet
¶ErrorOr<SampleRecord::CallTargetMap>
findCallTargetMapAt(uint32_t LineOffset,
uint32_t Discriminator) const
ErrorOr<SampleRecord::CallTargetMap>
findCallTargetMapAt(uint32_t LineOffset,
uint32_t Discriminator) const
Description
Returns the call target map collected at a given location. Each location is specified by \p LineOffset and \p Discriminator. If the location is not found in profile, return error.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:831
Parameters
- uint32_t LineOffset
- uint32_t Discriminator
¶ErrorOr<SampleRecord::CallTargetMap>
findCallTargetMapAt(
const llvm::sampleprof::LineLocation&
CallSite) const
ErrorOr<SampleRecord::CallTargetMap>
findCallTargetMapAt(
const llvm::sampleprof::LineLocation&
CallSite) const
Description
Returns the call target map collected at a given location specified by \p CallSite. If the location is not found in profile, return error.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:841
Parameters
- const llvm::sampleprof::LineLocation& CallSite
¶const llvm::sampleprof::FunctionSamples*
findFunctionSamples(
const llvm::DILocation* DIL,
llvm::sampleprof::
SampleProfileReaderItaniumRemapper*
Remapper = nullptr) const
const llvm::sampleprof::FunctionSamples*
findFunctionSamples(
const llvm::DILocation* DIL,
llvm::sampleprof::
SampleProfileReaderItaniumRemapper*
Remapper = nullptr) const
Description
Get the FunctionSamples of the inline instance where DIL originates from. The FunctionSamples of the instruction (Machine or IR) associated to\p 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.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1102
Parameters
- const llvm::DILocation* DIL
- llvm::sampleprof:: SampleProfileReaderItaniumRemapper* Remapper = nullptr
Returns
the FunctionSamples pointer to the inlined instance. If \p Remapper is not nullptr, it will be used to find matching FunctionSamples with not exactly the same but equivalent name.
¶const llvm::sampleprof::FunctionSamples*
findFunctionSamplesAt(
const llvm::sampleprof::LineLocation& Loc,
llvm::StringRef CalleeName,
llvm::sampleprof::
SampleProfileReaderItaniumRemapper*
Remapper) const
const llvm::sampleprof::FunctionSamples*
findFunctionSamplesAt(
const llvm::sampleprof::LineLocation& Loc,
llvm::StringRef CalleeName,
llvm::sampleprof::
SampleProfileReaderItaniumRemapper*
Remapper) const
Description
Returns a pointer to FunctionSamples at the given callsite location\p Loc with callee \p CalleeName. If no callsite can be found, relax the restriction to return the FunctionSamples at callsite location\p Loc with the maximum total sample count. If \p Remapper is not nullptr, use \p Remapper to find FunctionSamples with equivalent name as \p CalleeName.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:869
Parameters
- const llvm::sampleprof::LineLocation& Loc
- llvm::StringRef CalleeName
- llvm::sampleprof:: SampleProfileReaderItaniumRemapper* Remapper
¶const llvm::sampleprof::FunctionSamplesMap*
findFunctionSamplesMapAt(
const llvm::sampleprof::LineLocation& Loc)
const
const llvm::sampleprof::FunctionSamplesMap*
findFunctionSamplesMapAt(
const llvm::sampleprof::LineLocation& Loc)
const
Description
Returns the FunctionSamplesMap at the given \p Loc.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:855
Parameters
- const llvm::sampleprof::LineLocation& Loc
¶void findInlinedFunctions(
DenseSet<GlobalValue::GUID>& S,
const StringMap<llvm::Function*>& SymbolMap,
uint64_t Threshold) const
void findInlinedFunctions(
DenseSet<GlobalValue::GUID>& S,
const StringMap<llvm::Function*>& SymbolMap,
uint64_t Threshold) const
Description
Recursively traverses all children, if the total sample count of the corresponding function is no less than \p Threshold, add its corresponding GUID to \p S. Also traverse the BodySamples to add hot CallTarget's GUID to \p S.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:975
Parameters
¶ErrorOr<uint64_t> findSamplesAt(
uint32_t LineOffset,
uint32_t Discriminator) const
ErrorOr<uint64_t> findSamplesAt(
uint32_t LineOffset,
uint32_t Discriminator) const
Description
Return the number of samples collected at the given location. Each location is specified by \p LineOffset and \p Discriminator. If the location is not found in profile, return error.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:819
Parameters
- uint32_t LineOffset
- uint32_t Discriminator
¶llvm::sampleprof::FunctionSamplesMap&
functionSamplesAt(
const llvm::sampleprof::LineLocation& Loc)
llvm::sampleprof::FunctionSamplesMap&
functionSamplesAt(
const llvm::sampleprof::LineLocation& Loc)
Description
Return the function samples at the given callsite location.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:849
Parameters
- const llvm::sampleprof::LineLocation& Loc
¶const llvm::sampleprof::BodySampleMap&
getBodySamples() const
const llvm::sampleprof::BodySampleMap&
getBodySamples() const
Description
Return all the samples collected in the body of the function.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:914
¶static uint64_t getCallSiteHash(
llvm::StringRef CalleeName,
const llvm::sampleprof::LineLocation&
Callsite)
static uint64_t getCallSiteHash(
llvm::StringRef CalleeName,
const llvm::sampleprof::LineLocation&
Callsite)
Description
Returns a unique hash code for a combination of a callsite location and the callee function name.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1088
Parameters
- llvm::StringRef CalleeName
- const llvm::sampleprof::LineLocation& Callsite
¶static llvm::sampleprof::LineLocation
getCallSiteIdentifier(const llvm::DILocation* DIL,
bool ProfileIsFS = false)
static llvm::sampleprof::LineLocation
getCallSiteIdentifier(const llvm::DILocation* DIL,
bool ProfileIsFS = false)
Description
Returns a unique call site identifier for a given debug location of a call instruction. This is wrapper of two scenarios, the probe-based profile and regular profile, to hide implementation details from the sample loader and the context tracker.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1083
Parameters
- const llvm::DILocation* DIL
- bool ProfileIsFS = false
¶const llvm::sampleprof::CallsiteSampleMap&
getCallsiteSamples() const
const llvm::sampleprof::CallsiteSampleMap&
getCallsiteSamples() const
Description
Return all the callsite samples collected in the body of the function.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:917
¶static llvm::StringRef getCanonicalFnName(
const llvm::Function& F)
static llvm::StringRef getCanonicalFnName(
const llvm::Function& F)
Description
Return the canonical name for a function, taking into account suffix elision policy attributes.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1016
Parameters
- const llvm::Function& F
¶static llvm::StringRef getCanonicalFnName(
llvm::StringRef FnName,
llvm::StringRef Attr = "selected")
static llvm::StringRef getCanonicalFnName(
llvm::StringRef FnName,
llvm::StringRef Attr = "selected")
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1028
Parameters
- llvm::StringRef FnName
- llvm::StringRef Attr = "selected"
¶llvm::sampleprof::SampleContext& getContext()
const
llvm::sampleprof::SampleContext& getContext()
const
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1112
¶llvm::StringRef getFuncName() const
llvm::StringRef getFuncName() const
Description
Return the original function name.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1008
¶llvm::StringRef getFuncName(
llvm::StringRef Name) const
llvm::StringRef getFuncName(
llvm::StringRef Name) const
Description
Translate \p Name into its original name. When profile doesn't use MD5, \p Name needs no translation. When profile uses MD5, \p Name in current FunctionSamples is actually GUID of the original function name. getFuncName will translate \p Name in current FunctionSamples into its original name by looking up in the function map GUIDToFuncNameMap. If the original name doesn't exist in the map, return empty StringRef.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1067
Parameters
- llvm::StringRef Name
¶uint64_t getFunctionHash() const
uint64_t getFunctionHash() const
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1012
¶static uint64_t getGUID(llvm::StringRef Name)
static uint64_t getGUID(llvm::StringRef Name)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1132
Parameters
- llvm::StringRef Name
¶uint64_t getHeadSamples() const
uint64_t getHeadSamples() const
Description
For top-level functions, return the total number of branch samples that have the function as the branch target (or 0 otherwise). This is the raw data fetched from the profile. 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.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:883
¶uint64_t getHeadSamplesEstimate() const
uint64_t getHeadSamplesEstimate() const
Description
Return an estimate of the sample count of the function entry basic block. The function can be either a standalone symbol or an inlined function. For Context-Sensitive profiles, this will prefer returning the head samples (i.e. getHeadSamples()), if non-zero. Otherwise it estimates from the function body's samples or callsite samples.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:890
¶uint64_t getMaxCountInside() const
uint64_t getMaxCountInside() const
Description
Return the maximum of sample counts in a function body including functions inlined in it.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:923
¶llvm::StringRef getName() const
llvm::StringRef getName() const
Description
Return the function name.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1005
¶static unsigned int getOffset(
const llvm::DILocation* DIL)
static unsigned int getOffset(
const llvm::DILocation* DIL)
Description
Returns the line offset to the start line of the subprogram. We assume that a single function will not exceed 65535 LOC.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1077
Parameters
- const llvm::DILocation* DIL
¶uint64_t getTotalSamples() const
uint64_t getTotalSamples() const
Description
Return the total number of samples collected inside the function.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:875
¶llvm::sampleprof_error merge(
const llvm::sampleprof::FunctionSamples&
Other,
uint64_t Weight = 1)
llvm::sampleprof_error merge(
const llvm::sampleprof::FunctionSamples&
Other,
uint64_t Weight = 1)
Description
Merge the samples in \p Other into this one. Optionally scale samples by \p Weight.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:935
Parameters
- const llvm::sampleprof::FunctionSamples& Other
- uint64_t Weight = 1
¶void print(llvm::raw_ostream& OS = dbgs(),
unsigned int Indent = 0) const
void print(llvm::raw_ostream& OS = dbgs(),
unsigned int Indent = 0) const
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:714
Parameters
- llvm::raw_ostream& OS = dbgs()
- unsigned int Indent = 0
¶uint64_t removeCalledTargetAndBodySample(
uint32_t LineOffset,
uint32_t Discriminator,
llvm::StringRef FName)
uint64_t removeCalledTargetAndBodySample(
uint32_t LineOffset,
uint32_t Discriminator,
llvm::StringRef FName)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:758
Parameters
- uint32_t LineOffset
- uint32_t Discriminator
- llvm::StringRef FName
¶void removeTotalSamples(uint64_t Num)
void removeTotalSamples(uint64_t Num)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:725
Parameters
- uint64_t Num
¶void setContext(
const llvm::sampleprof::SampleContext&
FContext)
void setContext(
const llvm::sampleprof::SampleContext&
FContext)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1114
Parameters
- const llvm::sampleprof::SampleContext& FContext
¶void setFunctionHash(uint64_t Hash)
void setFunctionHash(uint64_t Hash)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1010
Parameters
- uint64_t Hash
¶void setName(llvm::StringRef FunctionName)
void setName(llvm::StringRef FunctionName)
Description
Set the name of the function.
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:1002
Parameters
- llvm::StringRef FunctionName
¶void setTotalSamples(uint64_t Num)
void setTotalSamples(uint64_t Num)
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:732
Parameters
- uint64_t Num
¶void updateCallsiteSamples()
void updateCallsiteSamples()
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:780
¶void updateTotalSamples()
void updateTotalSamples()
Declared at: llvm/include/llvm/ProfileData/SampleProf.h:793