15#ifndef LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
16#define LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
40 : ParentContext(Parent), FuncName(FName), FuncSamples(FSamples),
41 CallSiteLoc(CallLoc){};
43 FunctionId ChildName);
47 bool AllowCreate =
true);
64 std::map<uint64_t, ContextTrieNode> AllChildContext;
67 ContextTrieNode *ParentContext;
73 FunctionSamples *FuncSamples;
76 std::optional<uint32_t> FuncSize;
79 LineLocation CallSiteLoc;
103 std::vector<const FunctionSamples *>
118 bool MergeContext =
true);
121 bool MergeContext =
true);
138 auto I = ProfileToNodeMap.find(FSamples);
139 if (
I == ProfileToNodeMap.end())
145 return FuncToCtxtProfiles;
149 Iterator, std::forward_iterator_tag, ContextTrieNode *,
150 std::ptrdiff_t, ContextTrieNode **, ContextTrieNode *> {
151 std::queue<ContextTrieNode *> NodeQueue;
157 assert(!NodeQueue.empty() &&
"Iterator already at the end");
160 for (
auto &It :
Node->getAllChildContext())
161 NodeQueue.push(&It.second);
166 if (NodeQueue.empty() &&
Other.NodeQueue.empty())
168 if (NodeQueue.empty() ||
Other.NodeQueue.empty())
170 return NodeQueue.front() ==
Other.NodeQueue.front();
174 assert(!NodeQueue.empty() &&
"Invalid access to end iterator");
175 return NodeQueue.front();
205 ProfileToNodeMap[FSample] =
Node;
208 HashKeyMap<std::unordered_map, FunctionId, ContextSamplesTy>
212 std::unordered_map<const FunctionSamples *, ContextTrieNode *>
216 const DenseMap<uint64_t, StringRef> *GUIDToFuncNameMap;
219 ContextTrieNode RootContext;
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
ContextTrieNode * getOrCreateChildContext(const LineLocation &CallSite, FunctionId ChildName, bool AllowCreate=true)
std::map< uint64_t, ContextTrieNode > & getAllChildContext()
void setCallSiteLoc(const LineLocation &Loc)
LineLocation getCallSiteLoc() const
FunctionSamples * getFunctionSamples() const
std::optional< uint32_t > getFunctionSize() const
ContextTrieNode * getHottestChildContext(const LineLocation &CallSite)
void setParentContext(ContextTrieNode *Parent)
void removeChildContext(const LineLocation &CallSite, FunctionId ChildName)
void addFunctionSize(uint32_t FSize)
FunctionId getFuncName() const
ContextTrieNode * getChildContext(const LineLocation &CallSite, FunctionId ChildName)
ContextTrieNode * getParentContext() const
void setFunctionSamples(FunctionSamples *FSamples)
ContextTrieNode(ContextTrieNode *Parent=nullptr, FunctionId FName=FunctionId(), FunctionSamples *FSamples=nullptr, LineLocation CallLoc={0, 0})
Iterator(ContextTrieNode *Node)
bool operator==(const Iterator &Other) const
ContextTrieNode * operator*() const
void promoteMergeContextSamplesTree(const Instruction &Inst, FunctionId CalleeName)
FunctionSamples * getBaseSamplesFor(const Function &Func, bool MergeContext=true)
ContextTrieNode * getOrCreateContextPath(const SampleContext &Context, bool AllowCreate)
HashKeyMap< std::unordered_map, FunctionId, ContextSamplesTy > & getFuncToCtxtProfiles()
StringRef getFuncNameFor(ContextTrieNode *Node) const
void populateFuncToCtxtMap()
ContextTrieNode & getRootContext()
std::string getContextString(const FunctionSamples &FSamples) const
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)
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 ...
This class represents a function that is read from a sample profile.
Representation of the samples collected for a function.
This class is a wrapper to associative container MapT<KeyT, ValueT> using the hash value of the origi...
This class provides operator overloads to the map container using MD5 as the key type,...
This is an optimization pass for GlobalISel generic memory operations.
Represents the relative location of an instruction.