@@ -1465,39 +1465,34 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1465
1465
1466
1466
void checkDebugVariable (SILInstruction *inst) {
1467
1467
std::optional<SILDebugVariable> varInfo;
1468
- if (auto *di = dyn_cast<AllocStackInst>(inst))
1469
- varInfo = di->getVarInfo ();
1470
- else if (auto *di = dyn_cast<AllocBoxInst>(inst))
1471
- varInfo = di->getVarInfo ();
1472
- else if (auto *di = dyn_cast<DebugValueInst>(inst))
1473
- varInfo = di->getVarInfo ();
1468
+ if (auto di = DebugVarCarryingInst (inst))
1469
+ varInfo = di.getVarInfo ();
1474
1470
1475
1471
if (!varInfo)
1476
1472
return ;
1477
1473
1478
1474
// Retrieve debug variable type
1479
- SILType DebugVarTy;
1480
- if (varInfo->Type )
1481
- DebugVarTy = *varInfo->Type ;
1482
- else {
1483
- // Fetch from related SSA value
1484
- switch (inst->getKind ()) {
1485
- case SILInstructionKind::AllocStackInst:
1486
- case SILInstructionKind::AllocBoxInst:
1487
- DebugVarTy = inst->getResult (0 )->getType ();
1488
- break ;
1489
- case SILInstructionKind::DebugValueInst:
1490
- DebugVarTy = inst->getOperand (0 )->getType ();
1491
- if (DebugVarTy.isAddress ()) {
1492
- // FIXME: op_deref could be applied to address types only.
1493
- // FIXME: Add this check
1494
- if (varInfo->DIExpr .startsWithDeref ())
1495
- DebugVarTy = DebugVarTy.getObjectType ();
1496
- }
1497
- break ;
1498
- default :
1499
- llvm_unreachable (" impossible instruction kind" );
1500
- }
1475
+ SILType SSAType;
1476
+ switch (inst->getKind ()) {
1477
+ case SILInstructionKind::AllocStackInst:
1478
+ case SILInstructionKind::AllocBoxInst:
1479
+ // TODO: unwrap box for AllocBox
1480
+ SSAType = inst->getResult (0 )->getType ().getObjectType ();
1481
+ break ;
1482
+ case SILInstructionKind::DebugValueInst:
1483
+ SSAType = inst->getOperand (0 )->getType ();
1484
+ break ;
1485
+ default :
1486
+ llvm_unreachable (" impossible instruction kind" );
1487
+ }
1488
+
1489
+ SILType DebugVarTy = varInfo->Type ? *varInfo->Type :
1490
+ SSAType.getObjectType ();
1491
+ if (!varInfo->DIExpr && !isa<AllocBoxInst>(inst)) {
1492
+ // FIXME: Remove getObjectType() below when we fix create/createAddr
1493
+ require (DebugVarTy.removingMoveOnlyWrapper ()
1494
+ == SSAType.getObjectType ().removingMoveOnlyWrapper (),
1495
+ " debug type mismatch without a DIExpr" );
1501
1496
}
1502
1497
1503
1498
auto *debugScope = inst->getDebugScope ();
0 commit comments