@@ -2266,8 +2266,14 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
2266
2266
void checkDeallocRefInst (DeallocRefInst *DI) {
2267
2267
require (DI->getOperand ()->getType ().isObject (),
2268
2268
" Operand of dealloc_ref must be object" );
2269
- require (DI->getOperand ()->getType ().getClassOrBoundGenericClass (),
2270
- " Operand of dealloc_ref must be of class type" );
2269
+ auto *cd = DI->getOperand ()->getType ().getClassOrBoundGenericClass ();
2270
+ require (cd, " Operand of dealloc_ref must be of class type" );
2271
+
2272
+ if (!DI->canAllocOnStack ()) {
2273
+ require (!cd->isResilient (F.getModule ().getSwiftModule (),
2274
+ F.getResilienceExpansion ()),
2275
+ " cannot directly deallocate resilient class" );
2276
+ }
2271
2277
}
2272
2278
void checkDeallocPartialRefInst (DeallocPartialRefInst *DPRI) {
2273
2279
require (DPRI->getInstance ()->getType ().isObject (),
@@ -2281,6 +2287,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
2281
2287
->getInstanceType ()->getClassOrBoundGenericClass ();
2282
2288
require (class2,
2283
2289
" Second operand of dealloc_partial_ref must be a class metatype" );
2290
+ require (!class2->isResilient (F.getModule ().getSwiftModule (),
2291
+ F.getResilienceExpansion ()),
2292
+ " cannot directly deallocate resilient class" );
2284
2293
while (class1 != class2) {
2285
2294
class1 = class1->getSuperclassDecl ();
2286
2295
require (class1, " First operand not superclass of second instance type" );
@@ -2453,6 +2462,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
2453
2462
SILType operandTy = EI->getOperand ()->getType ();
2454
2463
ClassDecl *cd = operandTy.getClassOrBoundGenericClass ();
2455
2464
require (cd, " ref_element_addr operand must be a class instance" );
2465
+ require (!cd->isResilient (F.getModule ().getSwiftModule (),
2466
+ F.getResilienceExpansion ()),
2467
+ " cannot access storage of resilient class" );
2456
2468
2457
2469
require (EI->getField ()->getDeclContext () == cd,
2458
2470
" ref_element_addr field must be a member of the class" );
@@ -2473,6 +2485,10 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
2473
2485
SILType operandTy = RTAI->getOperand ()->getType ();
2474
2486
ClassDecl *cd = operandTy.getClassOrBoundGenericClass ();
2475
2487
require (cd, " ref_tail_addr operand must be a class instance" );
2488
+ require (!cd->isResilient (F.getModule ().getSwiftModule (),
2489
+ F.getResilienceExpansion ()),
2490
+ " cannot access storage of resilient class" );
2491
+ require (cd, " ref_tail_addr operand must be a class instance" );
2476
2492
}
2477
2493
2478
2494
void checkDestructureStructInst (DestructureStructInst *DSI) {
0 commit comments