@@ -114,8 +114,11 @@ class ReachingDefAnalysis : public MachineFunctionPass {
114
114
private:
115
115
MachineFunction *MF = nullptr ;
116
116
const TargetRegisterInfo *TRI = nullptr ;
117
+ const TargetInstrInfo *TII = nullptr ;
117
118
LoopTraversal::TraversalOrder TraversedMBBOrder;
118
119
unsigned NumRegUnits = 0 ;
120
+ unsigned NumStackObjects = 0 ;
121
+ int ObjectIndexBegin = 0 ;
119
122
// / Instruction that defined each register, relative to the beginning of the
120
123
// / current basic block. When a LiveRegsDefInfo is used to represent a
121
124
// / live-out register, this value is relative to the end of the basic block,
@@ -138,6 +141,13 @@ class ReachingDefAnalysis : public MachineFunctionPass {
138
141
DenseMap<MachineInstr *, int > InstIds;
139
142
140
143
MBBReachingDefsInfo MBBReachingDefs;
144
+ using MBBFrameObjsReachingDefsInfo =
145
+ std::vector<std::vector<SmallVector<int >>>;
146
+ // MBBFrameObjsReachingDefs[i][j] is a list of instruction indices (relative
147
+ // to begining of MBB) that define frame index (j +
148
+ // MF->getFrameInfo().getObjectIndexBegin()) in MBB i. This is used in
149
+ // answering reaching definition queries.
150
+ MBBFrameObjsReachingDefsInfo MBBFrameObjsReachingDefs;
141
151
142
152
// / Default values are 'nothing happened a long time ago'.
143
153
const int ReachingDefDefaultVal = -(1 << 21 );
@@ -158,6 +168,7 @@ class ReachingDefAnalysis : public MachineFunctionPass {
158
168
MachineFunctionPass::getAnalysisUsage (AU);
159
169
}
160
170
171
+ void printAllReachingDefs (MachineFunction &MF);
161
172
bool runOnMachineFunction (MachineFunction &MF) override ;
162
173
163
174
MachineFunctionProperties getRequiredProperties () const override {
@@ -176,12 +187,13 @@ class ReachingDefAnalysis : public MachineFunctionPass {
176
187
void traverse ();
177
188
178
189
// / Provides the instruction id of the closest reaching def instruction of
179
- // / PhysReg that reaches MI, relative to the begining of MI's basic block.
180
- int getReachingDef (MachineInstr *MI, MCRegister PhysReg) const ;
190
+ // / Reg that reaches MI, relative to the begining of MI's basic block.
191
+ // Note that Reg may represent a stack slot.
192
+ int getReachingDef (MachineInstr *MI, MCRegister Reg) const ;
181
193
182
- // / Return whether A and B use the same def of PhysReg .
194
+ // / Return whether A and B use the same def of Reg .
183
195
bool hasSameReachingDef (MachineInstr *A, MachineInstr *B,
184
- MCRegister PhysReg ) const ;
196
+ MCRegister Reg ) const ;
185
197
186
198
// / Return whether the reaching def for MI also is live out of its parent
187
199
// / block.
@@ -309,9 +321,9 @@ class ReachingDefAnalysis : public MachineFunctionPass {
309
321
MachineInstr *getInstFromId (MachineBasicBlock *MBB, int InstId) const ;
310
322
311
323
// / Provides the instruction of the closest reaching def instruction of
312
- // / PhysReg that reaches MI, relative to the begining of MI's basic block.
313
- MachineInstr * getReachingLocalMIDef (MachineInstr *MI,
314
- MCRegister PhysReg ) const ;
324
+ // / Reg that reaches MI, relative to the begining of MI's basic block.
325
+ // Note that Reg may represent a stack slot.
326
+ MachineInstr * getReachingLocalMIDef (MachineInstr *MI, MCRegister Reg ) const ;
315
327
};
316
328
317
329
} // namespace llvm
0 commit comments