@@ -199,6 +199,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
199
199
llvm::DILocalVariable *Var, llvm::DIExpression *Expr,
200
200
unsigned Line, unsigned Col, llvm::DILocalScope *Scope,
201
201
const SILDebugScope *DS, bool InCoroContext = false );
202
+ #ifndef NDEBUG
203
+ bool verifyCoroutineArgument (llvm::Value *Addr);
204
+ #endif
205
+
202
206
void emitGlobalVariableDeclaration (llvm::GlobalVariable *Storage,
203
207
StringRef Name, StringRef LinkageName,
204
208
DebugTypeInfo DebugType,
@@ -1611,6 +1615,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1611
1615
return getOrCreateDesugaredType (CanTy, DbgTy);
1612
1616
}
1613
1617
1618
+ // SILBox should appear only inside of coroutine contexts.
1619
+ case TypeKind::SILBox:
1614
1620
case TypeKind::DependentMember:
1615
1621
case TypeKind::GenericTypeParam: {
1616
1622
// FIXME: Provide a more meaningful debug type.
@@ -1628,7 +1634,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1628
1634
case TypeKind::Hole:
1629
1635
case TypeKind::Module:
1630
1636
case TypeKind::SILBlockStorage:
1631
- case TypeKind::SILBox:
1632
1637
case TypeKind::SILToken:
1633
1638
case TypeKind::BuiltinUnsafeValueBuffer:
1634
1639
case TypeKind::BuiltinDefaultActorStorage:
@@ -1652,7 +1657,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1652
1657
switch (Ty->getKind ()) {
1653
1658
case TypeKind::GenericFunction: // Not yet supported.
1654
1659
case TypeKind::SILBlockStorage: // Not supported at all.
1655
- case TypeKind::SILBox:
1656
1660
return false ;
1657
1661
default :
1658
1662
return true ;
@@ -2455,6 +2459,28 @@ void IRGenDebugInfoImpl::emitDbgIntrinsic(
2455
2459
}
2456
2460
}
2457
2461
2462
+ #ifndef NDEBUG
2463
+ bool IRGenDebugInfoImpl::verifyCoroutineArgument (llvm::Value *Addr) {
2464
+ llvm::Value *Storage = Addr;
2465
+ while (Storage) {
2466
+ if (auto *LdInst = dyn_cast<llvm::LoadInst>(Storage))
2467
+ Storage = LdInst->getOperand (0 );
2468
+ else if (auto *GEPInst = dyn_cast<llvm::GetElementPtrInst>(Storage))
2469
+ Storage = GEPInst->getOperand (0 );
2470
+ else if (auto *BCInst = dyn_cast<llvm::BitCastInst>(Storage))
2471
+ Storage = BCInst->getOperand (0 );
2472
+ else if (auto *CallInst = dyn_cast<llvm::CallInst>(Storage)) {
2473
+ assert (CallInst->getCalledFunction () == IGM.getProjectBoxFn () &&
2474
+ " unhandled projection" );
2475
+ Storage = CallInst->getArgOperand (0 );
2476
+ } else
2477
+
2478
+ break ;
2479
+ }
2480
+ return llvm::isa<llvm::Argument>(Storage);
2481
+ }
2482
+ #endif
2483
+
2458
2484
void IRGenDebugInfoImpl::emitGlobalVariableDeclaration (
2459
2485
llvm::GlobalVariable *Var, StringRef Name, StringRef LinkageName,
2460
2486
DebugTypeInfo DbgTy, bool IsLocalToUnit, bool InFixedBuffer,
@@ -2638,6 +2664,12 @@ void IRGenDebugInfo::emitDbgIntrinsic(IRBuilder &Builder, llvm::Value *Storage,
2638
2664
Builder, Storage, Var, Expr, Line, Col, Scope, DS, InCoroContext);
2639
2665
}
2640
2666
2667
+ #ifndef NDEBUG
2668
+ bool IRGenDebugInfo::verifyCoroutineArgument (llvm::Value *Addr) {
2669
+ return static_cast <IRGenDebugInfoImpl *>(this )->verifyCoroutineArgument (Addr);
2670
+ }
2671
+ #endif
2672
+
2641
2673
void IRGenDebugInfo::emitGlobalVariableDeclaration (
2642
2674
llvm::GlobalVariable *Storage, StringRef Name, StringRef LinkageName,
2643
2675
DebugTypeInfo DebugType, bool IsLocalToUnit, bool InFixedBuffer,
0 commit comments