15#ifndef LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
16#define LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
41 : ParentContext(Parent), FuncName(FName), FuncSamples(FSamples),
42 CallSiteLoc(CallLoc){};
48 bool AllowCreate =
true);
65 std::map<uint64_t, ContextTrieNode> AllChildContext;
68 ContextTrieNode *ParentContext;
74 FunctionSamples *FuncSamples;
77 std::optional<uint32_t> FuncSize;
80 LineLocation CallSiteLoc;
104 std::vector<const FunctionSamples *>
119 bool MergeContext =
true);
138 auto I = ProfileToNodeMap.find(FSamples);
139 if (
I == ProfileToNodeMap.end())
144 return FuncToCtxtProfiles;
148 Iterator, std::forward_iterator_tag, ContextTrieNode *,
149 std::ptrdiff_t, ContextTrieNode **, ContextTrieNode *> {
150 std::queue<ContextTrieNode *> NodeQueue;
156 assert(!NodeQueue.empty() &&
"Iterator already at the end");
159 for (
auto &It :
Node->getAllChildContext())
160 NodeQueue.push(&It.second);
165 if (NodeQueue.empty() &&
Other.NodeQueue.empty())
167 if (NodeQueue.empty() ||
Other.NodeQueue.empty())
169 return NodeQueue.front() ==
Other.NodeQueue.front();
173 assert(!NodeQueue.empty() &&
"Invalid access to end iterator");
174 return NodeQueue.front();
204 ProfileToNodeMap[FSample] =
Node;
207 StringMap<ContextSamplesTy> FuncToCtxtProfiles;
210 std::unordered_map<const FunctionSamples *, ContextTrieNode *>
214 const DenseMap<uint64_t, StringRef> *GUIDToFuncNameMap;
217 ContextTrieNode RootContext;
This file defines the StringMap class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
std::map< uint64_t, ContextTrieNode > & getAllChildContext()
ContextTrieNode * getOrCreateChildContext(const LineLocation &CallSite, StringRef ChildName, bool AllowCreate=true)
StringRef getFuncName() const
void setCallSiteLoc(const LineLocation &Loc)
LineLocation getCallSiteLoc() const
FunctionSamples * getFunctionSamples() const
std::optional< uint32_t > getFunctionSize() const
void removeChildContext(const LineLocation &CallSite, StringRef ChildName)
ContextTrieNode * getHottestChildContext(const LineLocation &CallSite)
void setParentContext(ContextTrieNode *Parent)
ContextTrieNode(ContextTrieNode *Parent=nullptr, StringRef FName=StringRef(), FunctionSamples *FSamples=nullptr, LineLocation CallLoc={0, 0})
void addFunctionSize(uint32_t FSize)
ContextTrieNode * getParentContext() const
void setFunctionSamples(FunctionSamples *FSamples)
ContextTrieNode * getChildContext(const LineLocation &CallSite, StringRef ChildName)
Iterator(ContextTrieNode *Node)
bool operator==(const Iterator &Other) const
ContextTrieNode * operator*() const
FunctionSamples * getBaseSamplesFor(const Function &Func, bool MergeContext=true)
ContextTrieNode * getOrCreateContextPath(const SampleContext &Context, bool AllowCreate)
StringMap< ContextSamplesTy > & getFuncToCtxtProfiles()
StringRef getFuncNameFor(ContextTrieNode *Node) const
void populateFuncToCtxtMap()
ContextTrieNode & getRootContext()
std::string getContextString(const FunctionSamples &FSamples) const
void promoteMergeContextSamplesTree(const Instruction &Inst, StringRef CalleeName)
ContextTrieNode * getContextNodeForProfile(const FunctionSamples *FSamples) const
FunctionSamples * getContextSamplesFor(const DILocation *DIL)
std::vector< FunctionSamples * > ContextSamplesTy
ContextSamplesTy & getAllContextSamplesFor(const Function &Func)
void markContextSamplesInlined(const FunctionSamples *InlinedSamples)
void createContextLessProfileMap(SampleProfileMap &ContextLessProfiles)
std::vector< const FunctionSamples * > getIndirectCalleeContextSamplesFor(const DILocation *DIL)
SampleContextTracker()=default
FunctionSamples * getCalleeContextSamplesFor(const CallBase &Inst, StringRef CalleeName)
ContextTrieNode * getContextFor(const SampleContext &Context)
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Representation of the samples collected for a function.
std::unordered_map< SampleContext, FunctionSamples, SampleContext::Hash > SampleProfileMap
This is an optimization pass for GlobalISel generic memory operations.
Represents the relative location of an instruction.