Skip to content

Commit ddb93df

Browse files
committed
[AES] See through borrows.
1 parent 7b6fb3f commit ddb93df

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/SILOptimizer/Mandatory/AccessEnforcementSelection.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ void SelectEnforcement::analyzeUsesOfBox(SingleValueInstruction *source) {
227227
for (auto use : source->getUses()) {
228228
auto user = use->getUser();
229229

230+
if (auto BBI = dyn_cast<BeginBorrowInst>(user)) {
231+
analyzeUsesOfBox(BBI);
232+
continue;
233+
}
234+
230235
if (auto MUI = dyn_cast<MarkUninitializedInst>(user)) {
231236
analyzeUsesOfBox(MUI);
232237
continue;
@@ -238,10 +243,9 @@ void SelectEnforcement::analyzeUsesOfBox(SingleValueInstruction *source) {
238243
}
239244

240245
// Ignore certain other uses that do not capture the value.
241-
if (isa<StrongRetainInst>(user) ||
242-
isa<StrongReleaseInst>(user) ||
243-
isa<DestroyValueInst>(user) ||
244-
isa<DeallocBoxInst>(user))
246+
if (isa<StrongRetainInst>(user) || isa<StrongReleaseInst>(user) ||
247+
isa<DestroyValueInst>(user) || isa<DeallocBoxInst>(user) ||
248+
isa<EndBorrowInst>(user))
245249
continue;
246250

247251
// Treat everything else as an escape.
@@ -667,6 +671,8 @@ void AccessEnforcementSelection::processFunction(SILFunction *F) {
667671
SourceAccess
668672
AccessEnforcementSelection::getAccessKindForBox(ProjectBoxInst *projection) {
669673
SILValue source = projection->getOperand();
674+
if (auto *BBI = dyn_cast<BeginBorrowInst>(source))
675+
source = BBI->getOperand();
670676
if (auto *MUI = dyn_cast<MarkUninitializedInst>(source))
671677
source = MUI->getOperand();
672678

0 commit comments

Comments
 (0)