Skip to content

Commit 9c9ad09

Browse files
committed
SIL: Verifier checks resilience invariants for global variable instructions
1 parent 5e617b5 commit 9c9ad09

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,8 +1477,13 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
14771477
}
14781478

14791479
void checkAllocGlobalInst(AllocGlobalInst *AGI) {
1480+
SILGlobalVariable *RefG = AGI->getReferencedGlobal();
1481+
if (auto *VD = RefG->getDecl()) {
1482+
require(!VD->isResilient(F.getModule().getSwiftModule(),
1483+
F.getResilienceExpansion()),
1484+
"cannot access storage of resilient global");
1485+
}
14801486
if (F.isSerialized()) {
1481-
SILGlobalVariable *RefG = AGI->getReferencedGlobal();
14821487
require(RefG->isSerialized()
14831488
|| hasPublicVisibility(RefG->getLinkage()),
14841489
"alloc_global inside fragile function cannot "
@@ -1490,6 +1495,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
14901495
SILGlobalVariable *RefG = GAI->getReferencedGlobal();
14911496
require(GAI->getType().getObjectType() == RefG->getLoweredType(),
14921497
"global_addr/value must be the type of the variable it references");
1498+
if (auto *VD = RefG->getDecl()) {
1499+
require(!VD->isResilient(F.getModule().getSwiftModule(),
1500+
F.getResilienceExpansion()),
1501+
"cannot access storage of resilient global");
1502+
}
14931503
if (F.isSerialized()) {
14941504
require(RefG->isSerialized()
14951505
|| hasPublicVisibility(RefG->getLinkage()),

0 commit comments

Comments
 (0)