LLVM: lib/CodeGen/StackMapLivenessAnalysis.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
26
27using namespace llvm;
28
29#define DEBUG_TYPE "stackmaps"
30
33 cl::desc("Enable PatchPoint Liveness Analysis Pass"));
34
35STATISTIC(NumStackMapFuncVisited, "Number of functions visited");
36STATISTIC(NumStackMapFuncSkipped, "Number of functions skipped");
37STATISTIC(NumBBsVisited, "Number of basic blocks visited");
38STATISTIC(NumBBsHaveNoStackmap, "Number of basic blocks with no stackmap");
39STATISTIC(NumStackMaps, "Number of StackMaps visited");
40
41namespace {
42
43
44
45
46
47
48
49
53
54public:
55 static char ID;
56
57
58 StackMapLiveness();
59
60
61
63
66 MachineFunctionProperties::Property::NoVRegs);
67 }
68
69
71
72private:
73
75
76
78
79
80
82};
83}
84
85char StackMapLiveness::ID = 0;
88 "StackMap Liveness Analysis", false, false)
89
90
93}
94
95
96
97void StackMapLiveness::getAnalysisUsage(AnalysisUsage &AU) const {
98
102}
103
104
105bool StackMapLiveness::runOnMachineFunction(MachineFunction &MF) {
107 return false;
108
110 ++NumStackMapFuncVisited;
111
112
114 ++NumStackMapFuncSkipped;
115 return false;
116 }
117 return calculateLiveness(MF);
118}
119
120
121bool StackMapLiveness::calculateLiveness(MachineFunction &MF) {
122 LLVM_DEBUG(dbgs() << "********** COMPUTING STACKMAP LIVENESS: "
123 << MF.getName() << " **********\n");
124 bool HasChanged = false;
125
126 for (auto &MBB : MF) {
128 LiveRegs.init(*TRI);
129 LiveRegs.addLiveOuts(MBB);
130 bool HasStackMap = false;
131
132
134 if (MI.getOpcode() == TargetOpcode::PATCHPOINT) {
135 addLiveOutSetToMI(MF, MI);
136 HasChanged = true;
137 HasStackMap = true;
138 ++NumStackMaps;
139 }
141 LiveRegs.stepBackward(MI);
142 }
143 ++NumBBsVisited;
144 if (!HasStackMap)
145 ++NumBBsHaveNoStackmap;
146 }
147 return HasChanged;
148}
149
150
151void StackMapLiveness::addLiveOutSetToMI(MachineFunction &MF,
155 MI.addOperand(MF, MO);
156}
157
158
159
161
163 for (auto Reg : LiveRegs)
165
166
167 TRI->adjustStackMapLiveOutMask(Mask);
168
170}
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static cl::opt< bool > EnablePatchPointLiveness("enable-patchpoint-liveness", cl::Hidden, cl::init(true), cl::desc("Enable PatchPoint Liveness Analysis Pass"))
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Represent the analysis usage information of a pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
void setPreservesAll()
Set by analyses that do not transform their input at all.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
bool hasPatchPoint() const
This method may be called any time after instruction selection is complete to determine if there is a...
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.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
virtual MachineFunctionProperties getRequiredProperties() const
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
static MachineOperand CreateRegLiveOut(const uint32_t *Mask)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Reg
All possible values of the reg field in the ModR/M byte.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
void initializeStackMapLivenessPass(PassRegistry &)
auto reverse(ContainerTy &&C)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...