Skip to content

Commit 88a2b43

Browse files
committed
Verify that exclusivity access marker producers are well-formed in SILVerifier.
This is necessary for the correctness of optimizations that remove markers. We must know that an unidentified access can never see class or global properties.
1 parent 8d67ce1 commit 88a2b43

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "swift/SIL/DebugUtils.h"
2626
#include "swift/SIL/Dominance.h"
2727
#include "swift/SIL/DynamicCasts.h"
28+
#include "swift/SIL/MemAccessUtils.h"
2829
#include "swift/SIL/PostOrder.h"
2930
#include "swift/SIL/PrettyStackTrace.h"
3031
#include "swift/SIL/SILDebugScope.h"
@@ -1581,8 +1582,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
15811582
}
15821583

15831584
void checkBeginAccessInst(BeginAccessInst *BAI) {
1584-
auto op = BAI->getOperand();
1585-
requireSameType(BAI->getType(), op->getType(),
1585+
auto sourceOper = BAI->getOperand();
1586+
requireSameType(BAI->getType(), sourceOper->getType(),
15861587
"result must be same type as operand");
15871588
require(BAI->getType().isAddress(),
15881589
"begin_access operand must have address type");
@@ -1603,6 +1604,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
16031604
case SILAccessKind::Modify:
16041605
break;
16051606
}
1607+
1608+
// For dynamic Read/Modify access, AccessEnforcementWMO assumes a valid
1609+
// AccessedStorage and runs very late in the optimizer pipeline.
1610+
// TODO: eventually, make this true for any kind of access.
1611+
findAccessedStorage(sourceOper);
16061612
}
16071613

16081614
void checkEndAccessInst(EndAccessInst *EAI) {

0 commit comments

Comments
 (0)