30#define DEBUG_TYPE "pseudo-probe-inserter"
40 return MI.isCall() || (!
MI.isPseudo() && !
MI.isMetaInstruction());
44 auto Name =
DL->getSubprogramLinkageName();
63 if (isCallOrRealInstruction(
MI))
67 auto Value =
DL->getDiscriminator();
94 auto MII =
MBB.rbegin();
95 while (MII !=
MBB.rend()) {
100 if (isCallOrRealInstruction(*MII))
103 if (Cur->getOpcode() != TargetOpcode::PSEUDO_PROBE)
106 auto *ProbeInstr = &*Cur;
107 MBB.remove(ProbeInstr);
108 MBB.insert(FirstInstr, ProbeInstr);
120 if (
MI.isPseudoProbe())
124 for (
auto *
MI : ToBeRemoved)
125 MI->eraseFromParent();
140 StringRef getPassName()
const override {
return "Pseudo Probe Inserter"; }
148 return insertPseudoProbesInMF(MF);
161char PseudoProbeInserterLegacy::ID = 0;
163 "Insert pseudo probe annotations for value profiling",
166 "Insert pseudo probe annotations for value profiling",
170 return new PseudoProbeInserterLegacy();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
Represents analyses that only rely on functions' control flow.
static bool isPseudoProbeDiscriminator(unsigned Discriminator)
FunctionPass class - This class is used to implement most global optimizations.
static LLVM_ABI GUID getGUIDAssumingExternalLinkage(StringRef GlobalName)
Return a 64-bit global unique ID constructed from the name of a global symbol.
Module * getParent()
Get the module that this global value is contained inside of...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Representation of each machine instruction.
A Module instance is used to store all the information related to an LLVM module.
NamedMDNode * getNamedMetadata(StringRef Name) const
Return the first NamedMDNode in the module with the specified name.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
void push_back(const T &Elt)
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.
TargetInstrInfo - Interface to description of machine instruction set.
virtual const TargetInstrInfo * getInstrInfo() const
LLVM Value Representation.
static StringRef getCanonicalCoroFnName(StringRef FnName, StringRef Attr="selected")
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI FunctionPass * createPseudoProbeInserterLegacyPass()
This pass inserts pseudo probe annotation for callsite profiling.
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
constexpr const char * PseudoProbeDescMetadataName
static uint32_t extractProbeIndex(uint32_t Value)
static uint32_t extractProbeAttributes(uint32_t Value)
static uint32_t extractProbeType(uint32_t Value)