Skip to content

Commit 88df783

Browse files
committed
Add InteriorPointer::ProjectBox.
InteriorPointer needs to handle all access base kinds that may be borrowed.
1 parent 9984b81 commit 88df783

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ class InteriorPointerOperandKind {
649649
RefElementAddr,
650650
RefTailAddr,
651651
OpenExistentialBox,
652+
ProjectBox,
652653
StoreBorrow,
653654
};
654655

@@ -676,6 +677,8 @@ class InteriorPointerOperandKind {
676677
return Kind::RefTailAddr;
677678
case SILInstructionKind::OpenExistentialBoxInst:
678679
return Kind::OpenExistentialBox;
680+
case SILInstructionKind::ProjectBoxInst:
681+
return Kind::ProjectBox;
679682
case SILInstructionKind::StoreBorrowInst:
680683
return Kind::StoreBorrow;
681684
}
@@ -694,6 +697,8 @@ class InteriorPointerOperandKind {
694697
return Kind::RefTailAddr;
695698
case ValueKind::OpenExistentialBoxInst:
696699
return Kind::OpenExistentialBox;
700+
case ValueKind::ProjectBoxInst:
701+
return Kind::ProjectBox;
697702
case ValueKind::StoreBorrowInst:
698703
return Kind::StoreBorrow;
699704
}
@@ -747,6 +752,7 @@ struct InteriorPointerOperand {
747752
case InteriorPointerOperandKind::RefElementAddr:
748753
case InteriorPointerOperandKind::RefTailAddr:
749754
case InteriorPointerOperandKind::OpenExistentialBox:
755+
case InteriorPointerOperandKind::ProjectBox:
750756
case InteriorPointerOperandKind::StoreBorrow: {
751757
// Ok, we have a valid instruction. Return the relevant operand.
752758
auto *op =
@@ -788,6 +794,8 @@ struct InteriorPointerOperand {
788794
return cast<RefTailAddrInst>(operand->getUser());
789795
case InteriorPointerOperandKind::OpenExistentialBox:
790796
return cast<OpenExistentialBoxInst>(operand->getUser());
797+
case InteriorPointerOperandKind::ProjectBox:
798+
return cast<ProjectBoxInst>(operand->getUser());
791799
case InteriorPointerOperandKind::StoreBorrow:
792800
return cast<StoreBorrowInst>(operand->getUser());
793801
}

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,8 @@ bool InteriorPointerOperand::findTransitiveUsesForAddress(
729729
isa<BeginAccessInst>(user) || isa<TailAddrInst>(user) ||
730730
isa<IndexAddrInst>(user) || isa<StoreBorrowInst>(user) ||
731731
isa<UnconditionalCheckedCastAddrInst>(user) ||
732-
isa<UncheckedAddrCastInst>(user)) {
732+
isa<UncheckedAddrCastInst>(user)
733+
|| isa<MarkFunctionEscapeInst>(user)) {
733734
for (SILValue r : user->getResults()) {
734735
llvm::copy(r->getUses(), std::back_inserter(worklist));
735736
}

lib/SILOptimizer/SILCombiner/SILCombinerBuiltinVisitors.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ SILCombiner::optimizeBuiltinCOWBufferForReadingOSSA(BuiltinInst *bi) {
185185
cast<RefTailAddrInst>(intPtrOperand->getUser())->setImmutable();
186186
return;
187187
case InteriorPointerOperandKind::OpenExistentialBox:
188+
case InteriorPointerOperandKind::ProjectBox:
188189
case InteriorPointerOperandKind::StoreBorrow:
189190
// Can not mark this immutable.
190191
return;

0 commit comments

Comments
 (0)