51#ifndef LLVM_MC_MCPSEUDOPROBE_H
52#define LLVM_MC_MCPSEUDOPROBE_H
65#include <unordered_map>
66#include <unordered_set>
72class MCObjectStreamer;
93class MCDecodedPseudoProbe;
100 std::unordered_map<uint64_t, MCPseudoProbeFuncDesc>;
103 std::unordered_map<uint64_t, std::list<MCDecodedPseudoProbe>>;
160 assert(
Type <= 0xFF &&
"Probe type too big to encode, exceeding 2^8");
162 "Probe attributes too big to encode, exceeding 2^16");
203 bool ShowName)
const;
206template <
typename ProbeType,
typename DerivedProbeInlineTreeType>
208 struct InlineSiteHash {
210 return std::get<0>(Site) ^ std::get<1>(Site);
217 InlineSite, std::unique_ptr<DerivedProbeInlineTreeType>, InlineSiteHash>;
223 DerivedProbeInlineTreeType>
::value,
224 "DerivedProbeInlineTreeType must be subclass of "
225 "MCPseudoProbeInlineTreeBase");
241 Site, std::make_unique<DerivedProbeInlineTreeType>(Site));
242 Ret.first->second->Parent =
this;
243 return Ret.first->second.get();
254 MCPseudoProbeInlineTree> {
259 this->
Guid = std::get<0>(Site);
271 MCDecodedPseudoProbeInlineTree> {
290 MCProbeDivisions[FuncSym].addPseudoProbe(Probe, InlineStack);
305 bool empty()
const {
return MCProbeDivisions.empty(); }
343 const uint8_t *Data =
nullptr;
346 const uint8_t *End =
nullptr;
349 bool EncodingIsAddrBased =
false;
352 template <
typename T>
ErrorOr<T> readUnencodedNumber();
353 template <
typename T>
ErrorOr<T> readUnsignedNumber();
354 template <
typename T>
ErrorOr<T> readSignedNumber();
398 bool IncludeLeaf)
const;
401 return Address2ProbesMap;
407 return GUID2FuncDescMap;
414 return DummyInlineRoot;
Given that RA is a live value
This file defines the DenseSet and SmallDenseSet classes.
Provides ErrorOr<T> smart pointer.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
Represents either an error or a value T.
uint32_t ChildrenToProcess
MCDecodedPseudoProbeInlineTree()=default
MCDecodedPseudoProbeInlineTree(const InlineSite &Site)
bool hasInlineSite() const
void print(raw_ostream &OS, const GUIDProbeFunctionMap &GUID2FuncMAP, bool ShowName) const
void setAddress(uint64_t Addr)
std::string getInlineContextStr(const GUIDProbeFunctionMap &GUID2FuncMAP) const
void getInlineContext(SmallVectorImpl< MCPseduoProbeFrameLocation > &ContextStack, const GUIDProbeFunctionMap &GUID2FuncMAP) const
MCDecodedPseudoProbe(uint64_t Ad, uint64_t G, uint32_t I, PseudoProbeType K, uint8_t At, MCDecodedPseudoProbeInlineTree *Tree)
MCDecodedPseudoProbeInlineTree * getInlineTreeNode() const
uint64_t getAddress() const
Streaming object file generation interface.
uint8_t getAttributes() const
bool isDirectCall() const
bool isIndirectCall() const
uint64_t getIndex() const
MCPseudoProbeBase(uint64_t G, uint64_t I, uint64_t At, uint8_t T)
void setAttributes(uint8_t Attr)
static const uint32_t PseudoProbeFirstId
bool buildAddress2ProbeMap(const uint8_t *Start, std::size_t Size, const Uint64Set &GuildFilter, const Uint64Map &FuncStartAddrs)
void getInlineContextForProbe(const MCDecodedPseudoProbe *Probe, SmallVectorImpl< MCPseduoProbeFrameLocation > &InlineContextStack, bool IncludeLeaf) const
const AddressProbesMap & getAddress2ProbesMap() const
void printProbesForAllAddresses(raw_ostream &OS)
const GUIDProbeFunctionMap & getGUID2FuncDescMap() const
bool buildGUID2FuncDescMap(const uint8_t *Start, std::size_t Size)
const MCDecodedPseudoProbeInlineTree & getDummyInlineRoot() const
void printGUID2FuncDescMap(raw_ostream &OS)
void printProbeForAddress(raw_ostream &OS, uint64_t Address)
AddressProbesMap & getAddress2ProbesMap()
const MCPseudoProbeFuncDesc * getInlinerDescForProbe(const MCDecodedPseudoProbe *Probe) const
const MCDecodedPseudoProbe * getCallProbeForAddr(uint64_t Address) const
const MCPseudoProbeFuncDesc * getFuncDescForGUID(uint64_t GUID) const
InlinedProbeTreeMap & getChildren()
std::unordered_map< InlineSite, std::unique_ptr< DerivedProbeInlineTreeType >, InlineSiteHash > InlinedProbeTreeMap
const InlinedProbeTreeMap & getChildren() const
MCPseudoProbeInlineTreeBase< ProbeType, DerivedProbeInlineTreeType > * Parent
void addProbes(ProbeType Probe)
DerivedProbeInlineTreeType * getOrAddNode(const InlineSite &Site)
MCPseudoProbeInlineTreeBase()
std::vector< ProbeType > & getProbes()
std::vector< ProbeType > Probes
InlinedProbeTreeMap Children
MCPseudoProbeInlineTree()=default
MCPseudoProbeInlineTree(uint64_t Guid)
void addPseudoProbe(const MCPseudoProbe &Probe, const MCPseudoProbeInlineStack &InlineStack)
MCPseudoProbeInlineTree(const InlineSite &Site)
Instances of this class represent the pseudo probes inserted into a compile unit.
void addPseudoProbe(MCSymbol *FuncSym, const MCPseudoProbe &Probe, const MCPseudoProbeInlineStack &InlineStack)
const MCProbeDivisionMap & getMCProbes() const
std::map< MCSymbol *, MCPseudoProbeInlineTree > MCProbeDivisionMap
MCPseudoProbeSections & getProbeSections()
static int DdgPrintIndent
Instances of this class represent a pseudo probe instance for a pseudo probe table entry,...
MCSymbol * getLabel() const
MCPseudoProbe(MCSymbol *Label, uint64_t Guid, uint64_t Index, uint64_t Type, uint64_t Attributes)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
std::unordered_map< uint64_t, std::list< MCDecodedPseudoProbe > > AddressProbesMap
std::tuple< uint64_t, uint32_t > InlineSite
std::pair< StringRef, uint32_t > MCPseduoProbeFrameLocation
std::unordered_map< uint64_t, MCPseudoProbeFuncDesc > GUIDProbeFunctionMap
MCPseudoProbeFuncDesc(uint64_t GUID, uint64_t Hash, StringRef Name)
void print(raw_ostream &OS)