@@ -316,14 +316,27 @@ class UnaryInstructionBase : public BASE {
316
316
typename std::enable_if<has_result<X>::value, SILType>::type
317
317
getType (unsigned i = 0 ) const { return ValueBase::getType (i); }
318
318
319
- ArrayRef<Operand> getAllOperands () const { return Operands.asArray (); }
319
+ ArrayRef<Operand> getAllOperands () const { return Operands.asArray (); }\
320
320
MutableArrayRef<Operand> getAllOperands () { return Operands.asArray (); }
321
321
322
322
static bool classof (const ValueBase *V) {
323
323
return V->getKind () == KIND;
324
324
}
325
325
};
326
326
327
+
328
+ // / Holds common debug information about local variables and function
329
+ // / arguments that are needed by DebugValueInst, DebugValueAddrInst,
330
+ // / AllocStackInst, and AllocBoxInst.
331
+ class DebugVariable {
332
+ // / The source function argument position from left to right
333
+ // / starting with 1 or 0 if this is a local variable.
334
+ unsigned char ArgNo;
335
+ public:
336
+ DebugVariable (unsigned ArgNo) : ArgNo(ArgNo) {};
337
+ unsigned getArgNo () const { return ArgNo; }
338
+ };
339
+
327
340
// ===----------------------------------------------------------------------===//
328
341
// Allocation Instructions
329
342
// ===----------------------------------------------------------------------===//
@@ -368,15 +381,20 @@ class StackPromotable {
368
381
// / reference count) stack memory. The memory is provided uninitialized.
369
382
class AllocStackInst : public AllocationInst {
370
383
friend class SILBuilder ;
384
+ DebugVariable VarInfo;
371
385
372
- AllocStackInst (SILDebugLocation *Loc, SILType elementType, SILFunction &F);
386
+ AllocStackInst (SILDebugLocation *Loc, SILType elementType, SILFunction &F,
387
+ unsigned ArgNo);
373
388
374
389
public:
375
390
376
391
// / getDecl - Return the underlying variable declaration associated with this
377
392
// / allocation, or null if this is a temporary allocation.
378
393
VarDecl *getDecl () const ;
379
394
395
+ DebugVariable getVarInfo () const { return VarInfo; };
396
+ void setArgNo (unsigned N) { VarInfo = DebugVariable (N); }
397
+
380
398
// / getElementType - Get the type of the allocated memory (as opposed to the
381
399
// / (second) type of the instruction itself, which will be an address type).
382
400
SILType getElementType () const {
@@ -463,7 +481,10 @@ class AllocValueBufferInst :
463
481
class AllocBoxInst : public AllocationInst {
464
482
friend class SILBuilder ;
465
483
466
- AllocBoxInst (SILDebugLocation *DebugLoc, SILType ElementType, SILFunction &F);
484
+ DebugVariable VarInfo;
485
+
486
+ AllocBoxInst (SILDebugLocation *DebugLoc, SILType ElementType, SILFunction &F,
487
+ unsigned ArgNo);
467
488
468
489
public:
469
490
@@ -478,6 +499,8 @@ class AllocBoxInst : public AllocationInst {
478
499
// / allocation, or null if this is a temporary allocation.
479
500
VarDecl *getDecl () const ;
480
501
502
+ DebugVariable getVarInfo () const { return VarInfo; };
503
+
481
504
ArrayRef<Operand> getAllOperands () const { return {}; }
482
505
MutableArrayRef<Operand> getAllOperands () { return {}; }
483
506
@@ -1341,29 +1364,34 @@ class MarkFunctionEscapeInst : public SILInstruction {
1341
1364
// / types).
1342
1365
class DebugValueInst : public UnaryInstructionBase <ValueKind::DebugValueInst> {
1343
1366
friend class SILBuilder ;
1367
+ DebugVariable VarInfo;
1344
1368
1345
- DebugValueInst (SILDebugLocation *DebugLoc, SILValue Operand)
1346
- : UnaryInstructionBase(DebugLoc, Operand) {}
1369
+ DebugValueInst (SILDebugLocation *DebugLoc, SILValue Operand, unsigned ArgNo )
1370
+ : UnaryInstructionBase(DebugLoc, Operand), VarInfo(ArgNo) {}
1347
1371
1348
1372
public:
1349
1373
// / getDecl - Return the underlying variable declaration that this denotes,
1350
1374
// / or null if we don't have one.
1351
1375
VarDecl *getDecl () const ;
1376
+ DebugVariable getVarInfo () const { return VarInfo; }
1352
1377
};
1353
1378
1354
1379
// / Define the start or update to a symbolic variable value (for address-only
1355
1380
// / types) .
1356
1381
class DebugValueAddrInst
1357
1382
: public UnaryInstructionBase<ValueKind::DebugValueAddrInst> {
1358
1383
friend class SILBuilder ;
1384
+ DebugVariable VarInfo;
1359
1385
1360
- DebugValueAddrInst (SILDebugLocation *DebugLoc, SILValue Operand)
1361
- : UnaryInstructionBase(DebugLoc, Operand) {}
1386
+ DebugValueAddrInst (SILDebugLocation *DebugLoc, SILValue Operand,
1387
+ unsigned ArgNo)
1388
+ : UnaryInstructionBase(DebugLoc, Operand), VarInfo(ArgNo) {}
1362
1389
1363
1390
public:
1364
1391
// / getDecl - Return the underlying variable declaration that this denotes,
1365
1392
// / or null if we don't have one.
1366
1393
VarDecl *getDecl () const ;
1394
+ DebugVariable getVarInfo () const { return VarInfo; }
1367
1395
};
1368
1396
1369
1397
0 commit comments