@@ -404,9 +404,11 @@ void EscapeAnalysis::ConnectionGraph::computeUsePoints() {
404
404
405
405
for (auto &I : BB) {
406
406
switch (I.getKind ()) {
407
+ #define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
408
+ case SILInstructionKind::Name##ReleaseInst:
409
+ #include " swift/AST/ReferenceStorage.def"
407
410
case SILInstructionKind::StrongReleaseInst:
408
411
case SILInstructionKind::ReleaseValueInst:
409
- case SILInstructionKind::UnownedReleaseInst:
410
412
case SILInstructionKind::ApplyInst:
411
413
case SILInstructionKind::TryApplyInst: {
412
414
// / Actually we only add instructions which may release a reference.
@@ -1369,12 +1371,14 @@ void EscapeAnalysis::analyzeInstruction(SILInstruction *I,
1369
1371
ConGraph->getNode (cast<SingleValueInstruction>(I), this );
1370
1372
return ;
1371
1373
1374
+ #define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1375
+ case SILInstructionKind::Name##RetainInst: \
1376
+ case SILInstructionKind::StrongRetain##Name##Inst: \
1377
+ case SILInstructionKind::Copy##Name##ValueInst:
1378
+ #include " swift/AST/ReferenceStorage.def"
1372
1379
case SILInstructionKind::DeallocStackInst:
1373
1380
case SILInstructionKind::StrongRetainInst:
1374
- case SILInstructionKind::StrongRetainUnownedInst:
1375
- case SILInstructionKind::CopyUnownedValueInst:
1376
1381
case SILInstructionKind::RetainValueInst:
1377
- case SILInstructionKind::UnownedRetainInst:
1378
1382
case SILInstructionKind::BranchInst:
1379
1383
case SILInstructionKind::CondBranchInst:
1380
1384
case SILInstructionKind::SwitchEnumInst:
@@ -1391,10 +1395,13 @@ void EscapeAnalysis::analyzeInstruction(SILInstruction *I,
1391
1395
case SILInstructionKind::ValueToBridgeObjectInst:
1392
1396
// These instructions don't have any effect on escaping.
1393
1397
return ;
1398
+
1399
+ #define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1400
+ case SILInstructionKind::Name##ReleaseInst:
1401
+ #include " swift/AST/ReferenceStorage.def"
1394
1402
case SILInstructionKind::StrongReleaseInst:
1395
1403
case SILInstructionKind::ReleaseValueInst:
1396
- case SILInstructionKind::StrongUnpinInst:
1397
- case SILInstructionKind::UnownedReleaseInst: {
1404
+ case SILInstructionKind::StrongUnpinInst: {
1398
1405
SILValue OpV = I->getOperand (0 );
1399
1406
if (CGNode *AddrNode = ConGraph->getNode (OpV, this )) {
1400
1407
// A release instruction may deallocate the pointer operand. This may
@@ -1410,8 +1417,11 @@ void EscapeAnalysis::analyzeInstruction(SILInstruction *I,
1410
1417
}
1411
1418
return ;
1412
1419
}
1420
+
1421
+ #define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1422
+ case SILInstructionKind::Load##Name##Inst:
1423
+ #include " swift/AST/ReferenceStorage.def"
1413
1424
case SILInstructionKind::LoadInst:
1414
- case SILInstructionKind::LoadWeakInst:
1415
1425
// We treat ref_element_addr like a load (see NodeType::Content).
1416
1426
case SILInstructionKind::RefElementAddrInst:
1417
1427
case SILInstructionKind::RefTailAddrInst:
@@ -1462,9 +1472,11 @@ void EscapeAnalysis::analyzeInstruction(SILInstruction *I,
1462
1472
}
1463
1473
return ;
1464
1474
}
1465
- break ;
1475
+
1476
+ #define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1477
+ case SILInstructionKind::Store##Name##Inst:
1478
+ #include " swift/AST/ReferenceStorage.def"
1466
1479
case SILInstructionKind::StoreInst:
1467
- case SILInstructionKind::StoreWeakInst:
1468
1480
if (CGNode *ValueNode = ConGraph->getNode (I->getOperand (StoreInst::Src),
1469
1481
this )) {
1470
1482
CGNode *AddrNode = ConGraph->getNode (I->getOperand (StoreInst::Dest),
@@ -1541,15 +1553,19 @@ void EscapeAnalysis::analyzeInstruction(SILInstruction *I,
1541
1553
case SILInstructionKind::UpcastInst:
1542
1554
case SILInstructionKind::InitExistentialRefInst:
1543
1555
case SILInstructionKind::OpenExistentialRefInst:
1544
- case SILInstructionKind::UnownedToRefInst:
1545
- case SILInstructionKind::RefToUnownedInst:
1546
1556
case SILInstructionKind::RawPointerToRefInst:
1547
1557
case SILInstructionKind::RefToRawPointerInst:
1548
1558
case SILInstructionKind::RefToBridgeObjectInst:
1549
1559
case SILInstructionKind::BridgeObjectToRefInst:
1550
1560
case SILInstructionKind::UncheckedAddrCastInst:
1551
1561
case SILInstructionKind::UnconditionalCheckedCastInst:
1552
1562
case SILInstructionKind::StrongPinInst:
1563
+ // DO NOT use LOADABLE_REF_STORAGE because unchecked references don't have
1564
+ // retain/release instructions that trigger the 'default' case.
1565
+ #define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1566
+ case SILInstructionKind::RefTo##Name##Inst: \
1567
+ case SILInstructionKind::Name##ToRefInst:
1568
+ #include " swift/AST/ReferenceStorage.def"
1553
1569
// A cast is almost like a projection.
1554
1570
if (CGNode *OpNode = ConGraph->getNode (I->getOperand (0 ), this )) {
1555
1571
ConGraph->setNode (cast<SingleValueInstruction>(I), OpNode);
0 commit comments