@@ -61,6 +61,7 @@ class BasicBlock;
61
61
class MDNode ;
62
62
class Module ;
63
63
class DbgVariableIntrinsic ;
64
+ class DIAssignID ;
64
65
class DPMarker ;
65
66
class DPValue ;
66
67
class raw_ostream ;
@@ -83,6 +84,7 @@ class DPValue : public ilist_node<DPValue>, private DebugValueUser {
83
84
DILocalVariable *Variable;
84
85
DIExpression *Expression;
85
86
DebugLoc DbgLoc;
87
+ DIExpression *AddressExpression;
86
88
87
89
public:
88
90
void deleteInstr ();
@@ -102,6 +104,7 @@ class DPValue : public ilist_node<DPValue>, private DebugValueUser {
102
104
enum class LocationType {
103
105
Declare,
104
106
Value,
107
+ Assign,
105
108
106
109
End, // /< Marks the end of the concrete types.
107
110
Any, // /< To indicate all LocationTypes in searches.
@@ -122,6 +125,21 @@ class DPValue : public ilist_node<DPValue>, private DebugValueUser {
122
125
// / assigning \p Location to the DV / Expr / DI variable.
123
126
DPValue (Metadata *Location, DILocalVariable *DV, DIExpression *Expr,
124
127
const DILocation *DI, LocationType Type = LocationType::Value);
128
+ DPValue (Metadata *Value, DILocalVariable *Variable, DIExpression *Expression,
129
+ DIAssignID *AssignID, Metadata *Address,
130
+ DIExpression *AddressExpression, const DILocation *DI);
131
+
132
+ static DPValue *createDPVAssign (Value *Val, DILocalVariable *Variable,
133
+ DIExpression *Expression,
134
+ DIAssignID *AssignID, Value *Address,
135
+ DIExpression *AddressExpression,
136
+ const DILocation *DI);
137
+ static DPValue *createLinkedDPVAssign (Instruction *LinkedInstr, Value *Val,
138
+ DILocalVariable *Variable,
139
+ DIExpression *Expression,
140
+ Value *Address,
141
+ DIExpression *AddressExpression,
142
+ const DILocation *DI);
125
143
126
144
static DPValue *createDPValue (Value *Location, DILocalVariable *DV,
127
145
DIExpression *Expr, const DILocation *DI);
@@ -213,7 +231,7 @@ class DPValue : public ilist_node<DPValue>, private DebugValueUser {
213
231
214
232
// / Does this describe the address of a local variable. True for dbg.addr
215
233
// / and dbg.declare, but not dbg.value, which describes its value.
216
- bool isAddressOfVariable () const { return Type != LocationType::Value ; }
234
+ bool isAddressOfVariable () const { return Type == LocationType::Declare ; }
217
235
LocationType getType () const { return Type; }
218
236
219
237
DebugLoc getDebugLoc () const { return DbgLoc; }
@@ -226,7 +244,11 @@ class DPValue : public ilist_node<DPValue>, private DebugValueUser {
226
244
227
245
DIExpression *getExpression () const { return Expression; }
228
246
229
- Metadata *getRawLocation () const { return DebugValue; }
247
+ // / Returns the metadata operand for the first location description. i.e.,
248
+ // / dbg intrinsic dbg.value,declare operand and dbg.assign 1st location
249
+ // / operand (the "value componenet"). Note the operand (singular) may be
250
+ // / a DIArgList which is a list of values.
251
+ Metadata *getRawLocation () const { return DebugValues[0 ]; }
230
252
231
253
Value *getValue (unsigned OpIdx = 0 ) const {
232
254
return getVariableLocationOp (OpIdx);
@@ -240,36 +262,58 @@ class DPValue : public ilist_node<DPValue>, private DebugValueUser {
240
262
(isa<ValueAsMetadata>(NewLocation) || isa<DIArgList>(NewLocation) ||
241
263
isa<MDNode>(NewLocation)) &&
242
264
" Location for a DPValue must be either ValueAsMetadata or DIArgList" );
243
- resetDebugValue (NewLocation);
265
+ resetDebugValue (0 , NewLocation);
244
266
}
245
267
246
268
// / Get the size (in bits) of the variable, or fragment of the variable that
247
269
// / is described.
248
270
std::optional<uint64_t > getFragmentSizeInBits () const ;
249
271
250
272
bool isEquivalentTo (const DPValue &Other) {
251
- return std::tie (Type, DebugValue , Variable, Expression, DbgLoc) ==
252
- std::tie (Other.Type , Other.DebugValue , Other.Variable ,
273
+ return std::tie (Type, DebugValues , Variable, Expression, DbgLoc) ==
274
+ std::tie (Other.Type , Other.DebugValues , Other.Variable ,
253
275
Other.Expression , Other.DbgLoc );
254
276
}
255
277
// Matches the definition of the Instruction version, equivalent to above but
256
278
// without checking DbgLoc.
257
279
bool isIdenticalToWhenDefined (const DPValue &Other) {
258
- return std::tie (Type, DebugValue , Variable, Expression) ==
259
- std::tie (Other.Type , Other.DebugValue , Other.Variable ,
280
+ return std::tie (Type, DebugValues , Variable, Expression) ==
281
+ std::tie (Other.Type , Other.DebugValues , Other.Variable ,
260
282
Other.Expression );
261
283
}
262
284
285
+ // / @name DbgAssign Methods
286
+ // / @{
287
+ bool isDbgAssign () const { return getType () == LocationType::Assign; }
288
+
289
+ Value *getAddress () const ;
290
+ Metadata *getRawAddress () const {
291
+ return isDbgAssign () ? DebugValues[1 ] : DebugValues[0 ];
292
+ }
293
+ Metadata *getRawAssignID () const { return DebugValues[2 ]; }
294
+ DIAssignID *getAssignID () const ;
295
+ DIExpression *getAddressExpression () const { return AddressExpression; }
296
+ void setAddressExpression (DIExpression *NewExpr) {
297
+ AddressExpression = NewExpr;
298
+ }
299
+ void setAssignId (DIAssignID *New);
300
+ void setAddress (Value *V) { resetDebugValue (1 , ValueAsMetadata::get (V)); }
301
+ // / Kill the address component.
302
+ void setKillAddress ();
303
+ // / Check whether this kills the address component. This doesn't take into
304
+ // / account the position of the intrinsic, therefore a returned value of false
305
+ // / does not guarentee the address is a valid location for the variable at the
306
+ // / intrinsic's position in IR.
307
+ bool isKillAddress () const ;
308
+
309
+ // / @}
310
+
263
311
DPValue *clone () const ;
264
312
// / Convert this DPValue back into a dbg.value intrinsic.
265
313
// / \p InsertBefore Optional position to insert this intrinsic.
266
314
// / \returns A new dbg.value intrinsic representiung this DPValue.
267
315
DbgVariableIntrinsic *createDebugIntrinsic (Module *M,
268
316
Instruction *InsertBefore) const ;
269
- // / Handle changes to the location of the Value(s) that we refer to happening
270
- // / "under our feet".
271
- void handleChangedLocation (Metadata *NewLocation);
272
-
273
317
void setMarker (DPMarker *M) { Marker = M; }
274
318
275
319
DPMarker *getMarker () { return Marker; }
0 commit comments