@@ -1158,12 +1158,10 @@ class IRGenSILFunction :
1158
1158
}
1159
1159
1160
1160
emitTypeMetadataRef (archetype);
1161
- } else if (auto packArchetype = dyn_cast<PackArchetypeType>(t)) {
1162
- emitTypeMetadataRef (packArchetype);
1163
- } else if (auto packtype = dyn_cast<SILPackType>(t)) {
1161
+ } else if (auto packType = dyn_cast<SILPackType>(t)) {
1164
1162
llvm::Value *Shape = emitPackShapeExpression (t);
1165
1163
emitPackCountDebugVariable (Shape);
1166
- } else if (auto packtype = dyn_cast<PackType>(t)) {
1164
+ } else if (auto packType = dyn_cast<PackType>(t)) {
1167
1165
llvm::Value *Shape = emitPackShapeExpression (t);
1168
1166
emitPackCountDebugVariable (Shape);
1169
1167
}
@@ -1212,8 +1210,13 @@ class IRGenSILFunction :
1212
1210
SILResultInfo ErrorInfo,
1213
1211
DebugValueInst *DbgValue);
1214
1212
void emitPoisonDebugValueInst (DebugValueInst *i);
1215
- void emitDebugInfoForAllocStack (AllocStackInst *i, const TypeInfo &type,
1216
- llvm::Value *addr);
1213
+ void emitDebugInfoBeforeAllocStack (AllocStackInst *i,
1214
+ const TypeInfo &type,
1215
+ DebugTypeInfo &DbgTy);
1216
+ void emitDebugInfoAfterAllocStack (AllocStackInst *i,
1217
+ const TypeInfo &type,
1218
+ const DebugTypeInfo &DbgTy,
1219
+ llvm::Value *addr);
1217
1220
void visitAllocStackInst (AllocStackInst *i);
1218
1221
void visitAllocPackInst (AllocPackInst *i);
1219
1222
void visitAllocPackMetadataInst (AllocPackMetadataInst *i);
@@ -6410,14 +6413,49 @@ void IRGenSILFunction::visitDestroyNotEscapedClosureInst(
6410
6413
setLoweredExplosion (i, out);
6411
6414
}
6412
6415
6413
- void IRGenSILFunction::emitDebugInfoForAllocStack (AllocStackInst *i,
6414
- const TypeInfo &type,
6415
- llvm::Value *addr ) {
6416
+ void IRGenSILFunction::emitDebugInfoBeforeAllocStack (AllocStackInst *i,
6417
+ const TypeInfo &type,
6418
+ DebugTypeInfo &DbgTy ) {
6416
6419
auto VarInfo = i->getVarInfo ();
6417
- if (!VarInfo)
6420
+ if (!VarInfo ||
6421
+ !i->getDebugScope () ||
6422
+ i->getDebugScope ()->getInlinedFunction ()->isTransparent ())
6423
+ return ;
6424
+
6425
+ VarDecl *Decl = i->getDecl ();
6426
+
6427
+ SILType SILTy;
6428
+ if (auto MaybeSILTy = VarInfo->Type ) {
6429
+ // If there is auxiliary type info, use it
6430
+ SILTy = *MaybeSILTy;
6431
+ } else {
6432
+ SILTy = i->getType ();
6433
+ }
6434
+ auto RealType = SILTy.getASTType ();
6435
+ if (Decl) {
6436
+ DbgTy = DebugTypeInfo::getLocalVariable (Decl, RealType, type, IGM);
6437
+ } else if (i->getFunction ()->isBare () && !SILTy.hasArchetype () &&
6438
+ !VarInfo->Name .empty ()) {
6439
+ DbgTy = DebugTypeInfo::getFromTypeInfo (RealType, getTypeInfo (SILTy), IGM);
6440
+ } else
6441
+ return ;
6442
+
6443
+ bindArchetypes (DbgTy.getType ());
6444
+ }
6445
+
6446
+ void IRGenSILFunction::emitDebugInfoAfterAllocStack (AllocStackInst *i,
6447
+ const TypeInfo &type,
6448
+ const DebugTypeInfo &DbgTy,
6449
+ llvm::Value *addr) {
6450
+ auto VarInfo = i->getVarInfo ();
6451
+ if (!VarInfo ||
6452
+ !i->getDebugScope () ||
6453
+ i->getDebugScope ()->getInlinedFunction ()->isTransparent ())
6418
6454
return ;
6419
6455
6420
6456
VarDecl *Decl = i->getDecl ();
6457
+ auto *DS = i->getDebugScope ();
6458
+
6421
6459
// Describe the underlying alloca. This way an llvm.dbg.declare intrinsic
6422
6460
// is used, which is valid for the entire lifetime of the alloca.
6423
6461
if (auto *BitCast = dyn_cast<llvm::BitCastInst>(addr)) {
@@ -6434,13 +6472,6 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
6434
6472
(void )isTaskAlloc;
6435
6473
}
6436
6474
}
6437
-
6438
- auto DS = i->getDebugScope ();
6439
- if (!DS)
6440
- return ;
6441
-
6442
- if (i->getDebugScope ()->getInlinedFunction ()->isTransparent ())
6443
- return ;
6444
6475
6445
6476
bool IsAnonymous = false ;
6446
6477
VarInfo->Name = getVarName (i, IsAnonymous);
@@ -6475,25 +6506,15 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
6475
6506
}
6476
6507
}
6477
6508
6478
- SILType SILTy;
6479
- if (auto MaybeSILTy = VarInfo->Type ) {
6480
- // If there is auxiliary type info, use it
6481
- SILTy = *MaybeSILTy;
6482
- } else {
6483
- SILTy = i->getType ();
6484
- }
6485
- auto RealType = SILTy.getASTType ();
6486
- DebugTypeInfo DbgTy;
6487
- if (Decl) {
6488
- DbgTy = DebugTypeInfo::getLocalVariable (Decl, RealType, type, IGM);
6489
- } else if (i->getFunction ()->isBare () && !SILTy.hasArchetype () &&
6490
- !VarInfo->Name .empty ()) {
6491
- DbgTy = DebugTypeInfo::getFromTypeInfo (RealType, getTypeInfo (SILTy), IGM);
6492
- } else
6493
- return ;
6509
+ if (DbgTy.getType () && IGM.DebugInfo ) {
6510
+ SILType SILTy;
6511
+ if (auto MaybeSILTy = VarInfo->Type ) {
6512
+ // If there is auxiliary type info, use it
6513
+ SILTy = *MaybeSILTy;
6514
+ } else {
6515
+ SILTy = i->getType ();
6516
+ }
6494
6517
6495
- bindArchetypes (DbgTy.getType ());
6496
- if (IGM.DebugInfo ) {
6497
6518
emitDebugVariableDeclaration (
6498
6519
addr, DbgTy, SILTy, DS, i->getLoc (), *VarInfo, Indirection,
6499
6520
AddrDbgInstrKind (i->usesMoveableValueDebugInfo ()));
@@ -6511,6 +6532,9 @@ void IRGenSILFunction::visitAllocStackInst(swift::AllocStackInst *i) {
6511
6532
dbgname = getVarName (i, IsAnonymous);
6512
6533
# endif
6513
6534
6535
+ DebugTypeInfo DbgTy;
6536
+ emitDebugInfoBeforeAllocStack (i, type, DbgTy);
6537
+
6514
6538
auto stackAddr = type.allocateStack (*this , i->getElementType (), dbgname);
6515
6539
setLoweredStackAddress (i, stackAddr);
6516
6540
Address addr = stackAddr.getAddress ();
@@ -6525,7 +6549,7 @@ void IRGenSILFunction::visitAllocStackInst(swift::AllocStackInst *i) {
6525
6549
Ty->getStructOrBoundGenericStruct ())
6526
6550
zeroInit (dyn_cast<llvm::AllocaInst>(addr.getAddress ()));
6527
6551
}
6528
- emitDebugInfoForAllocStack (i, type, addr.getAddress ());
6552
+ emitDebugInfoAfterAllocStack (i, type, DbgTy , addr.getAddress ());
6529
6553
}
6530
6554
6531
6555
void IRGenSILFunction::visitAllocPackInst (swift::AllocPackInst *i) {
0 commit comments