54#ifndef LLVM_MC_MCPSEUDOPROBE_H
55#define LLVM_MC_MCPSEUDOPROBE_H
72#include <unordered_map>
99class MCDecodedPseudoProbe;
109 return Desc.FuncGUID < GUID;
112 if (It->FuncGUID != GUID)
118class MCDecodedPseudoProbeInlineTree;
175 assert(
Type <= 0xFF &&
"Probe type too big to encode, exceeding 2^8");
177 "Probe attributes too big to encode, exceeding 2^16");
221 bool ShowName)
const;
226 :
public std::vector<std::reference_wrapper<MCDecodedPseudoProbe>> {
242 if (FromIt == end() || FromIt->get().getAddress() !=
Address)
244 auto ToIt = getIt(
Address + 1);
249template <
typename ProbesType,
typename DerivedProbeInlineTreeType,
250 typename InlinedProbeTreeMap>
259 DerivedProbeInlineTreeType>::value,
260 "DerivedProbeInlineTreeType must be subclass of "
261 "MCPseudoProbeInlineTreeBase");
276 auto [It, Inserted] =
Children.try_emplace(Site);
278 It->second = std::make_unique<DerivedProbeInlineTreeType>(Site);
279 It->second->Parent =
this;
281 return It->second.get();
292 std::vector<MCPseudoProbe>, MCPseudoProbeInlineTree,
293 DenseMap<InlineSite, std::unique_ptr<MCPseudoProbeInlineTree>>> {
298 this->
Guid = std::get<0>(Site);
310 MCDecodedPseudoProbe *, MCDecodedPseudoProbeInlineTree,
311 MutableArrayRef<MCDecodedPseudoProbeInlineTree>> {
319 : ProbeId(
std::
get<1>(Site)) {
320 this->
Guid = std::get<0>(Site);
330 NumProbes = ProbesRef.
size();
343 MCProbeDivisions[FuncSym].addPseudoProbe(Probe, InlineStack);
359 bool empty()
const {
return MCProbeDivisions.empty(); }
385 std::vector<MCDecodedPseudoProbe> PseudoProbeVec;
393 std::vector<MCDecodedPseudoProbe>>
396 std::vector<MCDecodedPseudoProbeInlineTree> InlineTreeVec;
419 bool EncodingIsAddrBased =
false;
422 template <
typename T>
ErrorOr<T> readUnencodedNumber();
423 template <
typename T>
ErrorOr<T> readUnsignedNumber();
424 template <
typename T>
ErrorOr<T> readSignedNumber();
444 bool IsMMapped =
false,
445 bool VerboseWarnings =
false);
449 template <
bool IsTopLevelFunc>
484 bool IncludeLeaf)
const;
487 return Address2ProbesMap;
493 return GUID2FuncDescMap;
500 return DummyInlineRoot;
505 InjectedProbeMap[Parent].emplace_back(Probe).setAddress(
Address);
510 auto It = InjectedProbeMap.find(Parent);
511 if (It == InjectedProbeMap.end())
513 return It->second.size();
517 auto It = InjectedProbeMap.find(Parent);
518 assert(It != InjectedProbeMap.end());
523 return InlineTreeVec;
529 template <
bool IsTopLevelFunc>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
Provides ErrorOr<T> smart pointer.
This file defines the SmallVector class.
auto find(uint64_t Address) const
auto find(uint64_t From, uint64_t To) const
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
Implements a dense probed hash-table based set.
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)
bool isTopLevelFunc() const
LLVM_ABI void print(raw_ostream &OS, const GUIDProbeFunctionMap &GUID2FuncMAP, bool ShowName) const
void setAddress(uint64_t Addr)
LLVM_ABI uint64_t getGuid() const
MCDecodedPseudoProbe(uint64_t Ad, uint32_t I, PseudoProbeType K, uint8_t At, uint32_t D, MCDecodedPseudoProbeInlineTree *Tree)
LLVM_ABI std::string getInlineContextStr(const GUIDProbeFunctionMap &GUID2FuncMAP) const
MCDecodedPseudoProbeInlineTree * getInlineTreeNode() const
LLVM_ABI 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
LLVM_ABI bool buildAddress2ProbeMap(const uint8_t *Start, std::size_t Size, const Uint64Set &GuildFilter, const Uint64Map &FuncStartAddrs)
LLVM_ABI bool buildGUID2FuncDescMap(const uint8_t *Start, std::size_t Size, bool IsMMapped=false, bool VerboseWarnings=false)
const AddressProbesMap & getAddress2ProbesMap() const
LLVM_ABI void printProbesForAllAddresses(raw_ostream &OS)
size_t getNumInjectedProbes(const MCDecodedPseudoProbeInlineTree *Parent) const
const GUIDProbeFunctionMap & getGUID2FuncDescMap() const
const MCDecodedPseudoProbeInlineTree & getDummyInlineRoot() const
LLVM_ABI void printGUID2FuncDescMap(raw_ostream &OS)
DenseMap< uint64_t, uint64_t > Uint64Map
~MCPseudoProbeDecoder()=default
MCPseudoProbeDecoder & operator=(MCPseudoProbeDecoder &&)=delete
LLVM_ABI void printProbeForAddress(raw_ostream &OS, uint64_t Address)
ArrayRef< MCDecodedPseudoProbeInlineTree > getInlineTreeVec() const
LLVM_ABI void getInlineContextForProbe(const MCDecodedPseudoProbe *Probe, SmallVectorImpl< MCPseudoProbeFrameLocation > &InlineContextStack, bool IncludeLeaf) const
MCPseudoProbeDecoder()=default
AddressProbesMap & getAddress2ProbesMap()
LLVM_ABI const MCPseudoProbeFuncDesc * getInlinerDescForProbe(const MCDecodedPseudoProbe *Probe) const
MCPseudoProbeDecoder(const MCPseudoProbeDecoder &)=delete
MCPseudoProbeDecoder(MCPseudoProbeDecoder &&)=delete
bool countRecords(bool &Discard, uint32_t &ProbeCount, uint32_t &InlinedCount, const Uint64Set &GuidFilter)
void addInjectedProbe(const MCDecodedPseudoProbe &Probe, uint64_t Address)
LLVM_ABI const MCDecodedPseudoProbe * getCallProbeForAddr(uint64_t Address) const
MCPseudoProbeDecoder & operator=(const MCPseudoProbeDecoder &)=delete
LLVM_ABI 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
LLVM_ABI void emit(MCObjectStreamer *MCOS, const MCPseudoProbe *&LastProbe)
MCPseudoProbeInlineTree(uint64_t Guid)
LLVM_ABI 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)
LLVM_ABI void emit(MCObjectStreamer *MCOS)
const MCProbeDivisionMap & getMCProbes() const
std::unordered_map< MCSymbol *, MCPseudoProbeInlineTree > MCProbeDivisionMap
MCPseudoProbeSections & getProbeSections()
static int DdgPrintIndent
static LLVM_ABI void emit(MCObjectStreamer *MCOS)
Instances of this class represent a pseudo probe instance for a pseudo probe table entry,...
MCSymbol * getLabel() const
LLVM_ABI 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 ...
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
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.
Represent a constant reference to a string, i.e.
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
std::pair< StringRef, uint32_t > MCPseudoProbeFrameLocation
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
SmallVector< InlineSite, 8 > MCPseudoProbeInlineStack
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Implement std::hash so that hash_code can be used in STL containers.
MCPseudoProbeFuncDesc(uint64_t GUID, uint64_t Hash, StringRef Name)
LLVM_ABI void print(raw_ostream &OS)