LLVM: lib/CodeGen/PseudoProbeInserter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

24

25#define DEBUG_TYPE "pseudo-probe-inserter"

26

27using namespace llvm;

28

29namespace {

31public:

32 static char ID;

33

36 }

37

38 StringRef getPassName() const override { return "Pseudo Probe Inserter"; }

39

40 void getAnalysisUsage(AnalysisUsage &AU) const override {

43 }

44

45 bool doInitialization(Module &M) override {

47 return false;

48 }

49

51 if (!ShouldRun)

52 return false;

58 if (MI.isPseudo())

59 FirstInstr = &MI;

60 if (MI.isCall()) {

62 auto Value = DL->getDiscriminator();

73 }

74 }

75 }

76 }

77

78

79

80

81

82

83

84

85

86

87

88

89

90 if (FirstInstr) {

91 auto MII = MBB.rbegin();

92 while (MII != MBB.rend()) {

93

94

95 if (!MII->isPseudo())

96 break;

97 auto Cur = MII++;

98 if (Cur->getOpcode() != TargetOpcode::PSEUDO_PROBE)

99 continue;

100

101 auto *ProbeInstr = &*Cur;

102 MBB.remove(ProbeInstr);

103 MBB.insert(FirstInstr, ProbeInstr);

105 }

106 } else {

107

108

109

110

111

112

115 if (MI.isPseudoProbe())

117 }

118

119 for (auto *MI : ToBeRemoved)

120 MI->eraseFromParent();

121

123 }

124 }

125

127 }

128

129private:

131 auto Name = DL->getSubprogramLinkageName();

133 }

134

135 bool ShouldRun = false;

136};

137}

138

139char PseudoProbeInserter::ID = 0;

141 "Insert pseudo probe annotations for value profiling",

142 false, false)

145 "Insert pseudo probe annotations for value profiling",

147

149 return new PseudoProbeInserter();

150}

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

const HexagonInstrInfo * TII

Module.h This file contains the declarations for the Module class.

#define INITIALIZE_PASS_DEPENDENCY(depName)

#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.

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.

static LLVM_ABI PassRegistry * getPassRegistry()

getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...

void push_back(const T &Elt)

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.

TargetInstrInfo - Interface to description of machine instruction set.

Target-Independent Code Generator Pass Configuration Options.

virtual const TargetInstrInfo * getInstrInfo() const

LLVM Value Representation.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

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.

LLVM_ABI FunctionPass * createPseudoProbeInserter()

This pass inserts pseudo probe annotation for callsite profiling.

Definition PseudoProbeInserter.cpp:148

LLVM_ABI void initializePseudoProbeInserterPass(PassRegistry &)

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)