Skip to content

Commit ae695b2

Browse files
authored
Merge pull request #35828 from gottesmm/pr-da5b78d526300f0503471e9040d28e518aeb2bea
[ownership] Change store_borrow to be an interior pointer and update interior pointer formalism to use it.
2 parents 08d5779 + 421adda commit ae695b2

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,11 @@ BorrowedValue getSingleBorrowIntroducingValue(SILValue inputValue);
618618
class InteriorPointerOperandKind {
619619
public:
620620
enum Kind : uint8_t {
621-
Invalid=0,
621+
Invalid = 0,
622622
RefElementAddr,
623623
RefTailAddr,
624624
OpenExistentialBox,
625+
StoreBorrow,
625626
};
626627

627628
private:
@@ -648,6 +649,8 @@ class InteriorPointerOperandKind {
648649
return Kind::RefTailAddr;
649650
case SILInstructionKind::OpenExistentialBoxInst:
650651
return Kind::OpenExistentialBox;
652+
case SILInstructionKind::StoreBorrowInst:
653+
return Kind::StoreBorrow;
651654
}
652655
}
653656

@@ -664,6 +667,8 @@ class InteriorPointerOperandKind {
664667
return Kind::RefTailAddr;
665668
case ValueKind::OpenExistentialBoxInst:
666669
return Kind::OpenExistentialBox;
670+
case ValueKind::StoreBorrowInst:
671+
return Kind::StoreBorrow;
667672
}
668673
}
669674

@@ -714,7 +719,8 @@ struct InteriorPointerOperand {
714719
return {};
715720
case InteriorPointerOperandKind::RefElementAddr:
716721
case InteriorPointerOperandKind::RefTailAddr:
717-
case InteriorPointerOperandKind::OpenExistentialBox: {
722+
case InteriorPointerOperandKind::OpenExistentialBox:
723+
case InteriorPointerOperandKind::StoreBorrow: {
718724
// Ok, we have a valid instruction. Return the relevant operand.
719725
auto *op =
720726
&cast<SingleValueInstruction>(resultValue)->getAllOperands()[0];
@@ -754,6 +760,8 @@ struct InteriorPointerOperand {
754760
return cast<RefTailAddrInst>(operand->getUser());
755761
case InteriorPointerOperandKind::OpenExistentialBox:
756762
return cast<OpenExistentialBoxInst>(operand->getUser());
763+
case InteriorPointerOperandKind::StoreBorrow:
764+
return cast<StoreBorrowInst>(operand->getUser());
757765
}
758766
llvm_unreachable("Covered switch isn't covered?!");
759767
}

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ OperandOwnership OperandOwnershipClassifier::visitBranchInst(BranchInst *bi) {
391391
OperandOwnership
392392
OperandOwnershipClassifier::visitStoreBorrowInst(StoreBorrowInst *i) {
393393
if (getValue() == i->getSrc()) {
394-
return OperandOwnership::ForwardingBorrow;
394+
return OperandOwnership::InteriorPointer;
395395
}
396396
return OperandOwnership::TrivialUse;
397397
}

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::StoreBorrow:
188189
// Can not mark this immutable.
189190
return;
190191
}

0 commit comments

Comments
 (0)