15#ifndef LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
16#define LLVM_TRANSFORMS_IPO_SAMPLECONTEXTTRACKER_H
41 : ParentContext(Parent), FuncName(FName), FuncSamples(FSamples),
42 CallSiteLoc(CallLoc){};
44 FunctionId ChildName);
49 bool AllowCreate =
true);
51 FunctionId ChildName);
67 std::map<uint64_t, ContextTrieNode> AllChildContext;
76 FunctionSamples *FuncSamples;
79 std::optional<uint32_t> FuncSize;
82 LineLocation CallSiteLoc;
107 LLVM_ABI std::vector<const FunctionSamples *>
122 bool MergeContext =
true);
125 bool MergeContext =
true);
144 auto I = ProfileToNodeMap.find(FSamples);
145 if (
I == ProfileToNodeMap.end())
151 return FuncToCtxtProfiles;
155 Iterator, std::forward_iterator_tag, ContextTrieNode *,
156 std::ptrdiff_t, ContextTrieNode **, ContextTrieNode *> {
157 std::queue<ContextTrieNode *> NodeQueue;
163 assert(!NodeQueue.empty() &&
"Iterator already at the end");
166 for (
auto &It :
Node->getAllChildContext())
167 NodeQueue.push(&It.second);
172 if (NodeQueue.empty() &&
Other.NodeQueue.empty())
174 if (NodeQueue.empty() ||
Other.NodeQueue.empty())
176 return NodeQueue.front() ==
Other.NodeQueue.front();
180 assert(!NodeQueue.empty() &&
"Invalid access to end iterator");
181 return NodeQueue.front();
211 ProfileToNodeMap[FSample] =
Node;
214 HashKeyMap<std::unordered_map, FunctionId, ContextSamplesTy>
218 std::unordered_map<const FunctionSamples *, ContextTrieNode *>
222 const DenseMap<uint64_t, StringRef> *GUIDToFuncNameMap;
225 ContextTrieNode RootContext;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
LLVM_ABI ContextTrieNode * getOrCreateChildContext(const LineLocation &CallSite, FunctionId ChildName, bool AllowCreate=true)
LLVM_ABI std::map< uint64_t, ContextTrieNode > & getAllChildContext()
LLVM_ABI void setCallSiteLoc(const LineLocation &Loc)
LLVM_ABI LineLocation getCallSiteLoc() const
LLVM_ABI FunctionSamples * getFunctionSamples() const
LLVM_ABI std::optional< uint32_t > getFunctionSize() const
LLVM_ABI ContextTrieNode * getHottestChildContext(const LineLocation &CallSite)
LLVM_ABI void setParentContext(ContextTrieNode *Parent)
LLVM_ABI void removeChildContext(const LineLocation &CallSite, FunctionId ChildName)
LLVM_ABI void addFunctionSize(uint32_t FSize)
LLVM_ABI FunctionId getFuncName() const
LLVM_ABI ContextTrieNode * getChildContext(const LineLocation &CallSite, FunctionId ChildName)
LLVM_ABI ContextTrieNode * getParentContext() const
LLVM_ABI 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
LLVM_ABI void promoteMergeContextSamplesTree(const Instruction &Inst, FunctionId CalleeName)
LLVM_ABI FunctionSamples * getBaseSamplesFor(const Function &Func, bool MergeContext=true)
LLVM_ABI ContextTrieNode * getOrCreateContextPath(const SampleContext &Context, bool AllowCreate)
HashKeyMap< std::unordered_map, FunctionId, ContextSamplesTy > & getFuncToCtxtProfiles()
LLVM_ABI StringRef getFuncNameFor(ContextTrieNode *Node) const
LLVM_ABI void populateFuncToCtxtMap()
LLVM_ABI ContextTrieNode & getRootContext()
LLVM_ABI std::string getContextString(const FunctionSamples &FSamples) const
ContextTrieNode * getContextNodeForProfile(const FunctionSamples *FSamples) const
LLVM_ABI FunctionSamples * getContextSamplesFor(const DILocation *DIL)
std::vector< FunctionSamples * > ContextSamplesTy
LLVM_ABI ContextSamplesTy & getAllContextSamplesFor(const Function &Func)
LLVM_ABI void markContextSamplesInlined(const FunctionSamples *InlinedSamples)
LLVM_ABI void createContextLessProfileMap(SampleProfileMap &ContextLessProfiles)
LLVM_ABI std::vector< const FunctionSamples * > getIndirectCalleeContextSamplesFor(const DILocation *DIL)
SampleContextTracker()=default
LLVM_ABI FunctionSamples * getCalleeContextSamplesFor(const CallBase &Inst, StringRef CalleeName)
LLVM_ABI 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.