@@ -1486,39 +1486,34 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1486
1486
1487
1487
void checkDebugVariable (SILInstruction *inst) {
1488
1488
std::optional<SILDebugVariable> varInfo;
1489
- if (auto *di = dyn_cast<AllocStackInst>(inst))
1490
- varInfo = di->getVarInfo ();
1491
- else if (auto *di = dyn_cast<AllocBoxInst>(inst))
1492
- varInfo = di->getVarInfo ();
1493
- else if (auto *di = dyn_cast<DebugValueInst>(inst))
1494
- varInfo = di->getVarInfo ();
1489
+ if (auto di = DebugVarCarryingInst (inst))
1490
+ varInfo = di.getVarInfo ();
1495
1491
1496
1492
if (!varInfo)
1497
1493
return ;
1498
1494
1499
1495
// Retrieve debug variable type
1500
- SILType DebugVarTy;
1501
- if (varInfo->Type )
1502
- DebugVarTy = *varInfo->Type ;
1503
- else {
1504
- // Fetch from related SSA value
1505
- switch (inst->getKind ()) {
1506
- case SILInstructionKind::AllocStackInst:
1507
- case SILInstructionKind::AllocBoxInst:
1508
- DebugVarTy = inst->getResult (0 )->getType ();
1509
- break ;
1510
- case SILInstructionKind::DebugValueInst:
1511
- DebugVarTy = inst->getOperand (0 )->getType ();
1512
- if (DebugVarTy.isAddress ()) {
1513
- // FIXME: op_deref could be applied to address types only.
1514
- // FIXME: Add this check
1515
- if (varInfo->DIExpr .startsWithDeref ())
1516
- DebugVarTy = DebugVarTy.getObjectType ();
1517
- }
1518
- break ;
1519
- default :
1520
- llvm_unreachable (" impossible instruction kind" );
1521
- }
1496
+ SILType SSAType;
1497
+ switch (inst->getKind ()) {
1498
+ case SILInstructionKind::AllocStackInst:
1499
+ case SILInstructionKind::AllocBoxInst:
1500
+ // TODO: unwrap box for AllocBox
1501
+ SSAType = inst->getResult (0 )->getType ().getObjectType ();
1502
+ break ;
1503
+ case SILInstructionKind::DebugValueInst:
1504
+ SSAType = inst->getOperand (0 )->getType ();
1505
+ break ;
1506
+ default :
1507
+ llvm_unreachable (" impossible instruction kind" );
1508
+ }
1509
+
1510
+ SILType DebugVarTy = varInfo->Type ? *varInfo->Type :
1511
+ SSAType.getObjectType ();
1512
+ if (!varInfo->DIExpr && !isa<AllocBoxInst>(inst)) {
1513
+ // FIXME: Remove getObjectType() below when we fix create/createAddr
1514
+ require (DebugVarTy.removingMoveOnlyWrapper ()
1515
+ == SSAType.getObjectType ().removingMoveOnlyWrapper (),
1516
+ " debug type mismatch without a DIExpr" );
1522
1517
}
1523
1518
1524
1519
auto *debugScope = inst->getDebugScope ();
0 commit comments