14#ifndef LLVM_PROFILEDATA_SAMPLEPROF_H
15#define LLVM_PROFILEDATA_SAMPLEPROF_H
35#include <system_error>
36#include <unordered_map>
83struct is_error_code_enum<
llvm::sampleprof_error> : std::true_type {};
115 std::string &GUIDBuf) {
116 if (
Name.empty() || !UseMD5)
143 return "InvalidSection";
145 return "ProfileSummarySection";
147 return "NameTableSection";
149 return "ProfileSymbolListSection";
151 return "FuncOffsetTableSection";
153 return "FunctionMetadata";
155 return "CSNameTableSection";
157 return "LBRProfileSection";
159 return "UnknownSection";
229template <
class SecFlagType>
232 if (std::is_same<SecCommonFlags, SecFlagType>())
236 bool IsFlagLegal =
false;
239 IsFlagLegal = std::is_same<SecNameTableFlags, SecFlagType>();
242 IsFlagLegal = std::is_same<SecProfSummaryFlags, SecFlagType>();
245 IsFlagLegal = std::is_same<SecFuncMetadataFlags, SecFlagType>();
249 IsFlagLegal = std::is_same<SecFuncOffsetFlags, SecFlagType>();
256template <
class SecFlagType>
259 auto FVal =
static_cast<uint64_t>(Flag);
260 bool IsCommon = std::is_same<SecCommonFlags, SecFlagType>();
261 Entry.Flags |= IsCommon ? FVal : (FVal << 32);
264template <
class SecFlagType>
267 auto FVal =
static_cast<uint64_t>(Flag);
268 bool IsCommon = std::is_same<SecCommonFlags, SecFlagType>();
269 Entry.Flags &= ~(IsCommon ? FVal : (FVal << 32));
272template <
class SecFlagType>
275 auto FVal =
static_cast<uint64_t>(Flag);
276 bool IsCommon = std::is_same<SecCommonFlags, SecFlagType>();
277 return Entry.Flags & (IsCommon ? FVal : (FVal << 32));
336 if (
LHS.second !=
RHS.second)
337 return LHS.second >
RHS.second;
339 return LHS.first <
RHS.first;
375 uint64_t &TargetSamples = CallTargets[
F];
387 auto I = CallTargets.
find(
F);
388 if (
I != CallTargets.
end()) {
406 for (
const auto &
I : CallTargets)
415 SortedTargets.emplace(
Target, Frequency);
417 return SortedTargets;
422 float DistributionFactor) {
425 AdjustedTargets[
Target] = Frequency * DistributionFactor;
427 return AdjustedTargets;
437 return NumSamples ==
Other.NumSamples && CallTargets ==
Other.CallTargets;
441 return !(*
this ==
Other);
484 return !(*
this == That);
487 std::string
toString(
bool OutputLineLocation)
const {
488 std::ostringstream OContextStr;
490 if (OutputLineLocation) {
495 return OContextStr.str();
541 std::list<SampleContextFrameVector> &CSNameTable,
552 CSNameTable.emplace_back();
564 ContextStr = ContextStr.
substr(1, ContextStr.
size() - 2);
568 while (!ContextRemain.
empty()) {
569 auto ContextSplit = ContextRemain.
split(
" @ ");
570 ChildContext = ContextSplit.first;
571 ContextRemain = ContextSplit.second;
574 Context.emplace_back(CalleeName, CallSiteLoc);
583 auto EntrySplit = ContextStr.
split(
':');
584 FName = EntrySplit.first;
587 if (!EntrySplit.second.empty()) {
591 auto LocSplit = EntrySplit.second.split(
'.');
592 LocSplit.first.getAsInteger(10, LineOffset);
596 if (!LocSplit.second.empty())
615 bool IncludeLeafLineLocation =
false) {
616 std::ostringstream OContextStr;
618 if (OContextStr.str().size()) {
619 OContextStr <<
" @ ";
622 IncludeLeafLineLocation);
624 return OContextStr.str();
649 Name =
Context.back().FuncName;
654 return State == That.State && Name == That.Name &&
655 FullContext == That.FullContext;
661 if (State != That.State)
662 return State < That.State;
665 return Name < That.Name;
669 while (
I < std::min(FullContext.
size(), That.FullContext.
size())) {
670 auto &Context1 = FullContext[
I];
671 auto &Context2 = That.FullContext[
I];
672 auto V = Context1.FuncName.compare(Context2.FuncName);
675 if (Context1.Location != Context2.Location)
676 return Context1.Location < Context2.Location;
680 return FullContext.
size() < That.FullContext.
size();
690 auto ThisContext = FullContext;
691 auto ThatContext = That.FullContext;
692 if (ThatContext.size() < ThisContext.size())
694 ThatContext = ThatContext.
take_front(ThisContext.size());
696 if (ThisContext.back().FuncName != ThatContext.back().FuncName)
727 std::unordered_map<LineLocation, LineLocation, LineLocationHash>;
750 if (TotalSamples < Num)
770 return BodySamples[
LineLocation(LineOffset, Discriminator)].addSamples(
778 return BodySamples[
LineLocation(LineOffset, Discriminator)].addCalledTarget(
784 return BodySamples[Location].merge(
SampleRecord, Weight);
793 auto I = BodySamples.find(
LineLocation(LineOffset, Discriminator));
794 if (
I != BodySamples.end()) {
795 Count =
I->second.removeCalledTarget(FName);
796 Count =
I->second.removeSamples(Count);
797 if (!
I->second.getSamples())
798 BodySamples.erase(
I);
805 for (
auto &
I : BodySamples) {
806 uint64_t TargetSamples =
I.second.getCallTargetSum();
811 if (TargetSamples >
I.second.getSamples())
812 I.second.addSamples(TargetSamples -
I.second.getSamples());
819 for (
const auto &
I : BodySamples)
822 for (
auto &
I : CallsiteSamples) {
823 for (
auto &CS :
I.second) {
824 CS.second.updateTotalSamples();
833 for (
auto &
I : CallsiteSamples) {
834 for (
auto &CS :
I.second) {
835 CS.second.SetContextSynthetic();
844 if (!IRToProfileLocationMap)
846 const auto &ProfileLoc = IRToProfileLocationMap->find(IRLoc);
847 if (ProfileLoc != IRToProfileLocationMap->end())
848 return ProfileLoc->second;
858 const auto &ret = BodySamples.find(
860 if (ret == BodySamples.end())
861 return std::error_code();
862 return ret->second.getSamples();
870 const auto &ret = BodySamples.find(
872 if (ret == BodySamples.end())
873 return std::error_code();
874 return ret->second.getCallTargets();
882 if (Ret == BodySamples.end())
883 return std::error_code();
884 return Ret->second.getCallTargets();
896 if (iter == CallsiteSamples.end())
898 return &iter->second;
911 bool empty()
const {
return TotalSamples == 0; }
938 if (!BodySamples.empty() &&
939 (CallsiteSamples.empty() ||
940 BodySamples.begin()->first < CallsiteSamples.begin()->first))
941 Count = BodySamples.begin()->second.getSamples();
942 else if (!CallsiteSamples.empty()) {
945 for (
const auto &N_FS : CallsiteSamples.begin()->second)
946 Count += N_FS.second.getHeadSamplesEstimate();
949 return Count ? Count : TotalSamples > 0;
957 return CallsiteSamples;
969 MaxCount = std::max(MaxCount, L.second.getSamples());
973 for (
const FunctionSamplesMap::value_type &
F :
C.second)
974 MaxCount = std::max(MaxCount,
F.second.getMaxCountInside());
985 Context =
Other.getContext();
986 if (FunctionHash == 0) {
988 FunctionHash =
Other.getFunctionHash();
989 }
else if (FunctionHash !=
Other.getFunctionHash()) {
1002 for (
const auto &
I :
Other.getBodySamples()) {
1007 for (
const auto &
I :
Other.getCallsiteSamples()) {
1010 for (
const auto &Rec :
I.second)
1011 MergeResult(Result, FSMap[Rec.first].merge(Rec.second, Weight));
1023 if (TotalSamples <= Threshold)
1025 auto isDeclaration = [](
const Function *
F) {
1026 return !
F ||
F->isDeclaration();
1034 for (
const auto &BS : BodySamples)
1035 for (
const auto &TS : BS.second.getCallTargets())
1036 if (TS.getValue() > Threshold) {
1038 if (isDeclaration(
Callee))
1041 for (
const auto &CS : CallsiteSamples)
1042 for (
const auto &NameFS : CS.second)
1043 NameFS.second.findInlinedFunctions(S, SymbolMap, Threshold);
1060 assert(IRToProfileLocationMap ==
nullptr &&
"this should be set only once");
1061 IRToProfileLocationMap = LTLM;
1067 auto AttrName =
"sample-profile-suffix-elision-policy";
1068 auto Attr =
F.getFnAttribute(AttrName).getValueAsString();
1084 if (Attr ==
"" || Attr ==
"all") {
1085 return FnName.
split(
'.').first;
1086 }
else if (Attr ==
"selected") {
1088 for (
const auto &Suf : knownSuffixes) {
1094 auto It = Cand.
rfind(Suffix);
1097 auto Dit = Cand.
rfind(
'.');
1098 if (Dit == It + Suffix.
size() - 1)
1099 Cand = Cand.
substr(0, It);
1102 }
else if (Attr ==
"none") {
1105 assert(
false &&
"internal error: unknown suffix elision policy");
1194 FunctionHash ==
Other.FunctionHash && Context ==
Other.Context &&
1195 TotalSamples ==
Other.TotalSamples &&
1196 TotalHeadSamples ==
Other.TotalHeadSamples &&
1197 BodySamples ==
Other.BodySamples &&
1198 CallsiteSamples ==
Other.CallsiteSamples;
1202 return !(*
this ==
Other);
1265 const LocToLocMap *IRToProfileLocationMap =
nullptr;
1271 std::unordered_map<SampleContext, FunctionSamples, SampleContext::Hash>;
1276 std::vector<NameFunctionSamples> &SortedProfiles);
1288 for (
const auto &
I : Samples)
1291 return A->first <
B->first;
1315 bool TrimColdContext,
1316 bool MergeColdContext,
1318 bool TrimBaseProfileOnly);
1356 bool ProfileIsCS =
false) {
1359 ProfileMap = std::move(TmpProfiles);
1364 bool ProfileIsCS =
false) {
1366 for (
const auto &
I : InputProfiles)
1367 OutputProfiles[
I.second.getName()].merge(
I.second);
1370 for (
auto &
I : OutputProfiles)
1373 for (
const auto &
I : InputProfiles)
1374 flattenNestedProfile(OutputProfiles,
I.second);
1384 auto Ret = OutputProfiles.try_emplace(Context, FS);
1389 Profile.getCallsiteSamples().clear();
1399 "There should be no inlinees' profiles after flattening.");
1405 uint64_t TotalSamples =
FS.getTotalSamples();
1407 for (
const auto &
I :
FS.getCallsiteSamples()) {
1408 for (
const auto &
Callee :
I.second) {
1409 const auto &CalleeProfile =
Callee.second;
1411 Profile.addBodySamples(
I.first.LineOffset,
I.first.Discriminator,
1412 CalleeProfile.getHeadSamplesEstimate());
1414 Profile.addCalledTargetSamples(
1415 I.first.LineOffset,
I.first.Discriminator, CalleeProfile.getName(),
1416 CalleeProfile.getHeadSamplesEstimate());
1418 TotalSamples = TotalSamples >= CalleeProfile.getTotalSamples()
1419 ? TotalSamples - CalleeProfile.getTotalSamples()
1421 TotalSamples += CalleeProfile.getHeadSamplesEstimate();
1423 flattenNestedProfile(OutputProfiles, CalleeProfile);
1426 Profile.addTotalSamples(TotalSamples);
1433 FrameNode *getOrCreateContextPath(
const SampleContext &Context);
1436 FrameNode RootFrame;
1452 Syms.insert(
Name.copy(Allocator));
1462 unsigned size() {
return Syms.size(); }
1475 bool ToCompress =
false;
1482using namespace sampleprof;
1513 return toString(IntHash, 10,
false)
This file defines the StringMap class.
amdgpu Simplify well known AMD library false FunctionCallee Callee
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseSet and SmallDenseSet classes.
Provides ErrorOr<T> smart pointer.
static cl::opt< unsigned > ColdCountThreshold("mfs-count-threshold", cl::desc("Minimum number of times a block must be executed to be retained."), cl::init(1), cl::Hidden)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
Class for arbitrary precision integers.
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
size_t size() const
size - Get the array size.
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
Allocate memory in an ever growing pool, as if by bump-pointer.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Implements a dense probed hash-table based set.
Represents either an error or a value T.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
static void stringifyResult(MD5Result &Result, SmallVectorImpl< char > &Str)
Translates the bytes in Res to a hex string that is deposited into Str.
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
iterator find(StringRef Key)
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
std::string str() const
str - Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
bool startswith(StringRef Prefix) const
size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
static constexpr size_t npos
Target - Wrapper for Target specific information.
The instances of the Type class are immutable: once they are created, they are never changed.
std::pair< iterator, bool > insert(const ValueT &V)
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
Representation of the samples collected for a function.
void setTotalSamples(uint64_t Num)
static bool ProfileIsPreInlined
void setName(StringRef FunctionName)
Set the name of the function.
bool operator!=(const FunctionSamples &Other) const
void updateTotalSamples()
void setHeadSamples(uint64_t Num)
sampleprof_error addTotalSamples(uint64_t Num, uint64_t Weight=1)
static uint64_t getGUID(StringRef Name)
static constexpr const char * UniqSuffix
void updateCallsiteSamples()
static StringRef getCanonicalFnName(StringRef FnName, StringRef Attr="selected")
ErrorOr< SampleRecord::CallTargetMap > findCallTargetMapAt(uint32_t LineOffset, uint32_t Discriminator) const
Returns the call target map collected at a given location.
bool operator==(const FunctionSamples &Other) const
static constexpr const char * PartSuffix
const FunctionSamplesMap * findFunctionSamplesMapAt(const LineLocation &Loc) const
Returns the FunctionSamplesMap at the given Loc.
void findInlinedFunctions(DenseSet< GlobalValue::GUID > &S, const StringMap< Function * > &SymbolMap, uint64_t Threshold) const
Recursively traverses all children, if the total sample count of the corresponding function is no les...
uint64_t getMaxCountInside(bool SkipCallSite=false) const
Return the maximum of sample counts in a function body.
void removeTotalSamples(uint64_t Num)
uint64_t getHeadSamples() const
For top-level functions, return the total number of branch samples that have the function as the bran...
ErrorOr< uint64_t > findSamplesAt(uint32_t LineOffset, uint32_t Discriminator) const
Return the number of samples collected at the given location.
ErrorOr< SampleRecord::CallTargetMap > findCallTargetMapAt(const LineLocation &CallSite) const
Returns the call target map collected at a given location specified by CallSite.
const LineLocation & mapIRLocToProfileLoc(const LineLocation &IRLoc) const
uint64_t getFunctionHash() const
static constexpr const char * LLVMSuffix
Name suffixes which canonicalization should handle to avoid profile mismatch.
void findAllNames(DenseSet< StringRef > &NameSet) const
StringRef getFuncName(StringRef Name) const
Translate Name into its original name.
sampleprof_error addHeadSamples(uint64_t Num, uint64_t Weight=1)
sampleprof_error addSampleRecord(LineLocation Location, const SampleRecord &SampleRecord, uint64_t Weight=1)
const FunctionSamples * findFunctionSamplesAt(const LineLocation &Loc, StringRef CalleeName, SampleProfileReaderItaniumRemapper *Remapper) const
Returns a pointer to FunctionSamples at the given callsite location Loc with callee CalleeName.
DenseMap< uint64_t, StringRef > * GUIDToFuncNameMap
GUIDToFuncNameMap saves the mapping from GUID to the symbol name, for all the function symbols define...
FunctionSamplesMap & functionSamplesAt(const LineLocation &Loc)
Return the function samples at the given callsite location.
CallsiteSampleMap & getCallsiteSamples()
static bool ProfileIsProbeBased
void setIRToProfileLocationMap(const LocToLocMap *LTLM)
static StringRef getCanonicalFnName(const Function &F)
Return the canonical name for a function, taking into account suffix elision policy attributes.
StringRef getFuncName() const
Return the original function name.
static uint64_t getCallSiteHash(StringRef CalleeName, const LineLocation &Callsite)
Returns a unique hash code for a combination of a callsite location and the callee function name.
sampleprof_error addBodySamples(uint32_t LineOffset, uint32_t Discriminator, uint64_t Num, uint64_t Weight=1)
static unsigned getOffset(const DILocation *DIL)
Returns the line offset to the start line of the subprogram.
void setFunctionHash(uint64_t Hash)
uint64_t removeCalledTargetAndBodySample(uint32_t LineOffset, uint32_t Discriminator, StringRef FName)
static bool ProfileIsFS
If this profile uses flow sensitive discriminators.
sampleprof_error addCalledTargetSamples(uint32_t LineOffset, uint32_t Discriminator, StringRef FName, uint64_t Num, uint64_t Weight=1)
SampleContext & getContext() const
static bool HasUniqSuffix
Whether the profile contains any ".__uniq." suffix in a name.
uint64_t getTotalSamples() const
Return the total number of samples collected inside the function.
void print(raw_ostream &OS=dbgs(), unsigned Indent=0) const
Print the samples collected for a function on stream OS.
sampleprof_error merge(const FunctionSamples &Other, uint64_t Weight=1)
Merge the samples in Other into this one.
FunctionSamples()=default
const CallsiteSampleMap & getCallsiteSamples() const
Return all the callsite samples collected in the body of the function.
void setContext(const SampleContext &FContext)
void SetContextSynthetic()
static LineLocation getCallSiteIdentifier(const DILocation *DIL, bool ProfileIsFS=false)
Returns a unique call site identifier for a given debug location of a call instruction.
uint64_t getHeadSamplesEstimate() const
Return an estimate of the sample count of the function entry basic block.
const FunctionSamples * findFunctionSamples(const DILocation *DIL, SampleProfileReaderItaniumRemapper *Remapper=nullptr) const
Get the FunctionSamples of the inline instance where DIL originates from.
StringRef getName() const
Return the function name.
const BodySampleMap & getBodySamples() const
Return all the samples collected in the body of the function.
static bool UseMD5
Whether the profile uses MD5 to represent string.
Helper class for profile conversion.
static void flattenProfile(SampleProfileMap &ProfileMap, bool ProfileIsCS=false)
static void flattenProfile(const SampleProfileMap &InputProfiles, SampleProfileMap &OutputProfiles, bool ProfileIsCS=false)
ProfileSymbolList records the list of function symbols shown up in the binary used to generate the pr...
void setToCompress(bool TC)
std::error_code write(raw_ostream &OS)
void dump(raw_ostream &OS=dbgs()) const
void merge(const ProfileSymbolList &List)
bool contains(StringRef Name)
void add(StringRef Name, bool copy=false)
copy indicates whether we need to copy the underlying memory for the input Name.
std::error_code read(const uint8_t *Data, uint64_t ListSize)
SampleContextTrimmer impelements helper functions to trim, merge cold context profiles.
SampleContextTrimmer(SampleProfileMap &Profiles)
void trimAndMergeColdContextProfiles(uint64_t ColdCountThreshold, bool TrimColdContext, bool MergeColdContext, uint32_t ColdContextFrameLength, bool TrimBaseProfileOnly)
void canonicalizeContextProfiles()
static void createCtxVectorFromStr(StringRef ContextStr, SampleContextFrameVector &Context)
Create a context vector from a given context string and save it in Context.
bool operator==(const SampleContext &That) const
SampleContext(SampleContextFrames Context, ContextStateMask CState=RawContext)
bool operator<(const SampleContext &That) const
StringRef getName() const
SampleContext(StringRef ContextStr, std::list< SampleContextFrameVector > &CSNameTable, ContextStateMask CState=RawContext)
bool hasState(ContextStateMask S)
void clearState(ContextStateMask S)
void setName(StringRef FunctionName)
Set the name of the function and clear the current context.
SampleContextFrames getContextFrames() const
bool isBaseContext() const
static std::string getContextString(SampleContextFrames Context, bool IncludeLeafLineLocation=false)
bool operator!=(const SampleContext &That) const
void setState(ContextStateMask S)
void setAllAttributes(uint32_t A)
uint64_t getHashCode() const
void setContext(SampleContextFrames Context, ContextStateMask CState=RawContext)
static void decodeContextString(StringRef ContextStr, StringRef &FName, LineLocation &LineLoc)
uint32_t getAllAttributes()
void setAttribute(ContextAttributeMask A)
bool IsPrefixOf(const SampleContext &That) const
bool hasAttribute(ContextAttributeMask A)
std::string toString() const
SampleContext(StringRef Name)
SampleProfileReaderItaniumRemapper remaps the profile data from a sample profile data reader,...
Representation of a single sample record.
bool hasCalls() const
Return true if this sample record contains function calls.
sampleprof_error merge(const SampleRecord &Other, uint64_t Weight=1)
Merge the samples in Other into this record.
const CallTargetMap & getCallTargets() const
std::set< CallTarget, CallTargetComparator > SortedCallTargetSet
uint64_t getSamples() const
uint64_t getCallTargetSum() const
uint64_t removeSamples(uint64_t S)
Decrease the number of samples for this record by S.
sampleprof_error addSamples(uint64_t S, uint64_t Weight=1)
Increment the number of samples for this record by S.
sampleprof_error addCalledTarget(StringRef F, uint64_t S, uint64_t Weight=1)
Add called function F with samples S.
std::pair< StringRef, uint64_t > CallTarget
StringMap< uint64_t > CallTargetMap
static const SortedCallTargetSet SortCallTargets(const CallTargetMap &Targets)
Sort call targets in descending order of call frequency.
const SortedCallTargetSet getSortedCallTargets() const
static const CallTargetMap adjustCallTargets(const CallTargetMap &Targets, float DistributionFactor)
Prorate call targets by a distribution factor.
bool operator!=(const SampleRecord &Other) const
bool operator==(const SampleRecord &Other) const
uint64_t removeCalledTarget(StringRef F)
Remove called function from the call target map.
void print(raw_ostream &OS, unsigned Indent) const
Print the sample record to the stream OS indented by Indent.
Sort a LocationT->SampleT map by LocationT.
std::pair< const LocationT, SampleT > SamplesWithLoc
SampleSorter(const std::map< LocationT, SampleT > &Samples)
const SamplesWithLocList & get() const
SmallVector< const SamplesWithLoc *, 20 > SamplesWithLocList
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
static void verifySecFlag(SecType Type, SecFlagType Flag)
ArrayRef< SampleContextFrame > SampleContextFrames
void sortFuncProfiles(const SampleProfileMap &ProfileMap, std::vector< NameFunctionSamples > &SortedProfiles)
std::unordered_map< SampleContext, FunctionSamples, SampleContext::Hash > SampleProfileMap
static uint64_t SPMagic(SampleProfileFormat Format=SPF_Binary)
std::unordered_map< LineLocation, LineLocation, LineLocationHash > LocToLocMap
std::pair< SampleContext, const FunctionSamples * > NameFunctionSamples
static void addSecFlag(SecHdrTableEntry &Entry, SecFlagType Flag)
raw_ostream & operator<<(raw_ostream &OS, const LineLocation &Loc)
static bool hasSecFlag(const SecHdrTableEntry &Entry, SecFlagType Flag)
std::map< LineLocation, FunctionSamplesMap > CallsiteSampleMap
@ ContextDuplicatedIntoBase
static StringRef getRepInFormat(StringRef Name, bool UseMD5, std::string &GUIDBuf)
Get the proper representation of a string according to whether the current Format uses MD5 to represe...
std::map< LineLocation, SampleRecord > BodySampleMap
@ SecFlagIsPreInlined
SecFlagIsPreInlined means this profile contains ShouldBeInlined contexts thus this is CS preinliner c...
@ SecFlagPartial
SecFlagPartial means the profile is for common/shared code.
@ SecFlagFSDiscriminator
SecFlagFSDiscriminator means this profile uses flow-sensitive discriminators.
@ SecFlagFullContext
SecFlagContext means this is context-sensitive flat profile for CSSPGO.
static void removeSecFlag(SecHdrTableEntry &Entry, SecFlagType Flag)
static hash_code hash_value(const SampleContextFrame &arg)
static std::string getSecName(SecType Type)
std::map< std::string, FunctionSamples, std::less<> > FunctionSamplesMap
static uint64_t SPVersion()
This is an optimization pass for GlobalISel generic memory operations.
void stable_sort(R &&Range)
std::error_code make_error_code(BitcodeError E)
@ unsupported_writing_format
@ ostream_seek_unsupported
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
std::enable_if_t< std::is_unsigned_v< T >, T > SaturatingMultiplyAdd(T X, T Y, T A, bool *ResultOverflowed=nullptr)
Multiply two unsigned integers, X and Y, and add the unsigned integer, A to the product.
const std::error_category & sampleprof_category()
std::string getUniqueInternalLinkagePostfix(const StringRef &FName)
sampleprof_error MergeResult(sampleprof_error &Accumulator, sampleprof_error Result)
OutputIt copy(R &&Range, OutputIt Out)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
static unsigned getHashValue(const SampleContext &Val)
static SampleContext getTombstoneKey()
static SampleContext getEmptyKey()
static bool isEqual(const SampleContext &LHS, const SampleContext &RHS)
An information struct used to provide DenseMap with the various necessary components for a given valu...
uint64_t operator()(const LineLocation &Loc) const
Represents the relative location of an instruction.
void print(raw_ostream &OS) const
LineLocation(uint32_t L, uint32_t D)
bool operator!=(const LineLocation &O) const
bool operator<(const LineLocation &O) const
bool operator==(const LineLocation &O) const
FrameNode * getOrCreateChildFrame(const LineLocation &CallSite, StringRef CalleeName)
FrameNode(StringRef FName=StringRef(), FunctionSamples *FSamples=nullptr, LineLocation CallLoc={0, 0})
FunctionSamples * FuncSamples
std::map< uint64_t, FrameNode > AllChildFrames
uint64_t operator()(const SampleContextFrameVector &S) const
bool operator==(const SampleContextFrame &That) const
bool operator!=(const SampleContextFrame &That) const
std::string toString(bool OutputLineLocation) const
SampleContextFrame(StringRef FuncName, LineLocation Location)
uint64_t operator()(const SampleContext &Context) const
bool operator()(const CallTarget &LHS, const CallTarget &RHS) const