54#ifndef LLVM_MC_MCPSEUDOPROBE_H
55#define LLVM_MC_MCPSEUDOPROBE_H
71#include <unordered_map>
77class MCObjectStreamer;
98class MCDecodedPseudoProbe;
108 return Desc.FuncGUID < GUID;
111 if (It->FuncGUID != GUID)
117class MCDecodedPseudoProbeInlineTree;
174 assert(
Type <= 0xFF &&
"Probe type too big to encode, exceeding 2^8");
176 "Probe attributes too big to encode, exceeding 2^16");
219 bool ShowName)
const;
224 :
public std::vector<std::reference_wrapper<MCDecodedPseudoProbe>> {
240 if (FromIt == end() || FromIt->get().getAddress() !=
Address)
242 auto ToIt = getIt(
Address + 1);
247template <
typename ProbesType,
typename DerivedProbeInlineTreeType,
248 typename InlinedProbeTreeMap>
257 DerivedProbeInlineTreeType>
::value,
258 "DerivedProbeInlineTreeType must be subclass of "
259 "MCPseudoProbeInlineTreeBase");
275 Site, std::make_unique<DerivedProbeInlineTreeType>(Site));
276 Ret.first->second->Parent =
this;
277 return Ret.first->second.get();
288 return std::get<0>(Site) ^ std::get<1>(Site);
293 std::vector<MCPseudoProbe>, MCPseudoProbeInlineTree,
294 std::unordered_map<InlineSite,
295 std::unique_ptr<MCPseudoProbeInlineTree>,
301 this->
Guid = std::get<0>(Site);
313 MCDecodedPseudoProbe *, MCDecodedPseudoProbeInlineTree,
314 MutableArrayRef<MCDecodedPseudoProbeInlineTree>> {
322 : ProbeId(
std::
get<1>(Site)) {
323 this->
Guid = std::get<0>(Site);
332 NumProbes = ProbesRef.
size();
345 MCProbeDivisions[FuncSym].addPseudoProbe(Probe, InlineStack);
361 bool empty()
const {
return MCProbeDivisions.empty(); }
387 std::vector<MCDecodedPseudoProbe> PseudoProbeVec;
395 std::vector<MCDecodedPseudoProbe>>
398 std::vector<MCDecodedPseudoProbeInlineTree> InlineTreeVec;
421 bool EncodingIsAddrBased =
false;
424 template <
typename T>
ErrorOr<T> readUnencodedNumber();
425 template <
typename T>
ErrorOr<T> readUnsignedNumber();
426 template <
typename T>
ErrorOr<T> readSignedNumber();
437 bool IsMMapped =
false);
441 template <
bool IsTopLevelFunc>
475 bool IncludeLeaf)
const;
478 return Address2ProbesMap;
484 return GUID2FuncDescMap;
491 return DummyInlineRoot;
496 InjectedProbeMap[Parent].emplace_back(Probe).setAddress(
Address);
501 auto It = InjectedProbeMap.find(Parent);
502 if (It == InjectedProbeMap.end())
504 return It->second.size();
508 auto It = InjectedProbeMap.find(Parent);
509 assert(It != InjectedProbeMap.end());
514 return InlineTreeVec;
520 template <
bool IsTopLevelFunc>
This file defines the BumpPtrAllocator interface.
BlockVerifier::State From
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Given that RA is a live value
This file defines the DenseMap class.
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.
auto find(uint64_t Address) const
auto find(uint64_t From, uint64_t To) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Allocate memory in an ever growing pool, as if by bump-pointer.
Represents either an error or a value T.
auto find(uint64_t GUID) const
InlineSite getInlineSite() const
MCDecodedPseudoProbeInlineTree()=default
bool hasInlineSite() const
MCDecodedPseudoProbeInlineTree(const InlineSite &Site, MCDecodedPseudoProbeInlineTree *Parent)
void setProbes(MutableArrayRef< MCDecodedPseudoProbe > ProbesRef)
void print(raw_ostream &OS, const GUIDProbeFunctionMap &GUID2FuncMAP, bool ShowName) const
void setAddress(uint64_t Addr)
MCDecodedPseudoProbe(uint64_t Ad, uint32_t I, PseudoProbeType K, uint8_t At, uint32_t D, MCDecodedPseudoProbeInlineTree *Tree)
std::string getInlineContextStr(const GUIDProbeFunctionMap &GUID2FuncMAP) const
MCDecodedPseudoProbeInlineTree * getInlineTreeNode() const
void getInlineContext(SmallVectorImpl< MCPseudoProbeFrameLocation > &ContextStack, const GUIDProbeFunctionMap &GUID2FuncMAP) const
uint64_t getAddress() const
Streaming object file generation interface.
uint32_t getIndex() const
uint8_t getAttributes() const
uint32_t getDiscriminator() const
MCPseudoProbeBase(uint64_t I, uint64_t At, uint8_t T, uint32_t D)
bool isDirectCall() const
bool isIndirectCall() const
void setAttributes(uint8_t Attr)
static const uint32_t PseudoProbeFirstId
auto getInjectedProbes(MCDecodedPseudoProbeInlineTree *Parent)
DenseSet< uint64_t > Uint64Set
bool buildAddress2ProbeMap(const uint8_t *Start, std::size_t Size, const Uint64Set &GuildFilter, const Uint64Map &FuncStartAddrs)
const AddressProbesMap & getAddress2ProbesMap() const
void printProbesForAllAddresses(raw_ostream &OS)
size_t getNumInjectedProbes(const MCDecodedPseudoProbeInlineTree *Parent) const
const GUIDProbeFunctionMap & getGUID2FuncDescMap() const
const MCDecodedPseudoProbeInlineTree & getDummyInlineRoot() const
void printGUID2FuncDescMap(raw_ostream &OS)
DenseMap< uint64_t, uint64_t > Uint64Map
bool buildGUID2FuncDescMap(const uint8_t *Start, std::size_t Size, bool IsMMapped=false)
void printProbeForAddress(raw_ostream &OS, uint64_t Address)
void getInlineContextForProbe(const MCDecodedPseudoProbe *Probe, SmallVectorImpl< MCPseudoProbeFrameLocation > &InlineContextStack, bool IncludeLeaf) const
const ArrayRef< MCDecodedPseudoProbeInlineTree > getInlineTreeVec() const
AddressProbesMap & getAddress2ProbesMap()
const MCPseudoProbeFuncDesc * getInlinerDescForProbe(const MCDecodedPseudoProbe *Probe) const
bool countRecords(bool &Discard, uint32_t &ProbeCount, uint32_t &InlinedCount, const Uint64Set &GuidFilter)
void addInjectedProbe(const MCDecodedPseudoProbe &Probe, uint64_t Address)
const MCDecodedPseudoProbe * getCallProbeForAddr(uint64_t Address) const
const MCPseudoProbeFuncDesc * getFuncDescForGUID(uint64_t GUID) const
InlinedProbeTreeMap Children
DerivedProbeInlineTreeType * getOrAddNode(const InlineSite &Site)
MCPseudoProbeInlineTreeBase< ProbesType, DerivedProbeInlineTreeType, InlinedProbeTreeMap > * Parent
MCPseudoProbeInlineTreeBase()
const InlinedProbeTreeMap & getChildren() const
InlinedProbeTreeMap & getChildren()
const ProbesType & getProbes() const
MCPseudoProbeInlineTree()=default
void emit(MCObjectStreamer *MCOS, const MCPseudoProbe *&LastProbe)
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)
void emit(MCObjectStreamer *MCOS)
const MCProbeDivisionMap & getMCProbes() const
std::unordered_map< MCSymbol *, MCPseudoProbeInlineTree > MCProbeDivisionMap
MCPseudoProbeSections & getProbeSections()
static int DdgPrintIndent
static void emit(MCObjectStreamer *MCOS)
Instances of this class represent a pseudo probe instance for a pseudo probe table entry,...
MCSymbol * getLabel() const
void emit(MCObjectStreamer *MCOS, const MCPseudoProbe *LastProbe) const
MCPseudoProbe(MCSymbol *Label, uint64_t Guid, uint64_t Index, uint64_t Type, uint64_t Attributes, uint32_t Discriminator)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
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.
A range adaptor for a pair of iterators.
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.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
std::tuple< uint64_t, uint32_t > InlineSite
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
std::pair< StringRef, uint32_t > MCPseudoProbeFrameLocation
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Implement std::hash so that hash_code can be used in STL containers.
Description of the encoding of one expression Op.
uint64_t operator()(const InlineSite &Site) const
MCPseudoProbeFuncDesc(uint64_t GUID, uint64_t Hash, StringRef Name)
void print(raw_ostream &OS)