LLVM 17.0.0git
Go to the documentation of this file.
1//===- llvm/CodeGen/PseudoProbePrinter.cpp - Pseudo Probe Emission -------===//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9// This file contains support for writing pseudo probe info into asm files.
13#include "PseudoProbePrinter.h"
16#include "llvm/IR/Function.h"
17#include "llvm/IR/PseudoProbe.h"
19#include "llvm/MC/MCStreamer.h"
21using namespace llvm;
27 const DILocation *DebugLoc) {
28 // Gather all the inlined-at nodes.
29 // When it's done ReversedInlineStack looks like ([66, B], [88, A])
30 // which means, Function A inlines function B at calliste with a probe id 88,
31 // and B inlines C at probe 66 where C is represented by Guid.
32 SmallVector<InlineSite, 8> ReversedInlineStack;
33 auto *InlinedAt = DebugLoc ? DebugLoc->getInlinedAt() : nullptr;
34 while (InlinedAt) {
35 auto Name = InlinedAt->getSubprogramLinkageName();
36 // Use caching to avoid redundant md5 computation for build speed.
37 uint64_t &CallerGuid = NameGuidMap[Name];
38 if (!CallerGuid)
39 CallerGuid = Function::getGUID(Name);
41 InlinedAt->getDiscriminator());
42 ReversedInlineStack.emplace_back(CallerGuid, CallerProbeId);
43 InlinedAt = InlinedAt->getInlinedAt();
44 }
46 SmallVector<InlineSite, 8> InlineStack(llvm::reverse(ReversedInlineStack));
47 Asm->OutStreamer->emitPseudoProbe(Guid, Index, Type, Attr, InlineStack,
48 Asm->CurrentFnSym);
std::string Name
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition: AsmPrinter.h:121
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:99
Debug location.
A debug info location.
Definition: DebugLoc.h:33
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:591
~PseudoProbeHandler() override
void emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type, uint64_t Attr, const DILocation *DebugLoc)
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:941
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:511
static uint32_t extractProbeIndex(uint32_t Value)
Definition: PseudoProbe.h:60