@@ -77,8 +77,9 @@ inline bool isForwardingConsume(SILValue value) {
77
77
return canOpcodeForwardOwnedValues (value);
78
78
}
79
79
80
- // / Find all "use points" of \p guaranteedValue that determine its lifetime
81
- // / requirement.
80
+ // / Find leaf "use points" of \p guaranteedValue that determine its lifetime
81
+ // / requirement. If \p usePoints is nullptr, then the simply returns true if no
82
+ // / PointerEscape use was found.
82
83
// /
83
84
// / Precondition: \p guaranteedValue is not a BorrowedValue.
84
85
// /
@@ -99,10 +100,10 @@ inline bool isForwardingConsume(SILValue value) {
99
100
// / When this is called on a value that does not introduce a new scope, none of
100
101
// / the use points can be EndBorrows or Reborrows. Those uses are only allowed
101
102
// / on borrow-introducing values.
102
- bool findInnerTransitiveGuaranteedUses (SILValue guaranteedValue,
103
- SmallVectorImpl<Operand *> & usePoints);
103
+ bool findInnerTransitiveGuaranteedUses (
104
+ SILValue guaranteedValue, SmallVectorImpl<Operand *> * usePoints = nullptr );
104
105
105
- // / Find all "use points" of a guaranteed value within its enclosing borrow
106
+ // / Find leaf "use points" of a guaranteed value within its enclosing borrow
106
107
// / scope (without looking through reborrows). To find the use points of the
107
108
// / extended borrow scope, after looking through reborrows, use
108
109
// / findExtendedTransitiveGuaranteedUses() instead.
@@ -662,12 +663,19 @@ bool getAllBorrowIntroducingValues(SILValue value,
662
663
// / introducer, then we return a .some(BorrowScopeIntroducingValue).
663
664
BorrowedValue getSingleBorrowIntroducingValue (SILValue inputValue);
664
665
666
+ enum class AddressUseKind { NonEscaping, PointerEscape, Unknown };
667
+
668
+ inline AddressUseKind meet (AddressUseKind lhs, AddressUseKind rhs) {
669
+ return (lhs > rhs) ? lhs : rhs;
670
+ }
671
+
665
672
// / The algorithm that is used to determine what the verifier will consider to
666
673
// / be transitive uses of the given address. Used to implement \see
667
674
// / findTransitiveUses.
668
- bool findTransitiveUsesForAddress (
669
- SILValue address, SmallVectorImpl<Operand *> &foundUses,
670
- std::function<void (Operand *)> *onError = nullptr);
675
+ AddressUseKind
676
+ findTransitiveUsesForAddress (SILValue address,
677
+ SmallVectorImpl<Operand *> *foundUses = nullptr ,
678
+ std::function<void (Operand *)> *onError = nullptr );
671
679
672
680
class InteriorPointerOperandKind {
673
681
public:
@@ -834,15 +842,19 @@ struct InteriorPointerOperand {
834
842
llvm_unreachable (" Covered switch isn't covered?!" );
835
843
}
836
844
837
- // / Transitively compute the list of uses that this interior pointer operand
838
- // / puts on its parent guaranted value.
845
+ // / Transitively compute the list of leaf uses that this interior pointer
846
+ // / operand puts on its parent guaranted value.
847
+ // /
848
+ // / If \p foundUses is nullptr, this simply returns true if no PointerEscapes
849
+ // / were found.
839
850
// /
840
851
// / Example: Uses of a ref_element_addr can not occur outside of the lifetime
841
852
// / of the instruction's operand. The uses of that address act as liveness
842
853
// / requirements to ensure that the underlying class is alive at all use
843
854
// / points.
844
- bool findTransitiveUses (SmallVectorImpl<Operand *> &foundUses,
845
- std::function<void (Operand *)> *onError = nullptr) {
855
+ AddressUseKind
856
+ findTransitiveUses (SmallVectorImpl<Operand *> *foundUses = nullptr ,
857
+ std::function<void (Operand *)> *onError = nullptr ) {
846
858
return findTransitiveUsesForAddress (getProjectedAddress (), foundUses,
847
859
onError);
848
860
}
@@ -912,8 +924,8 @@ struct AddressOwnership {
912
924
}
913
925
914
926
// / Transitively compute uses of this base address.
915
- bool findTransitiveUses (SmallVectorImpl<Operand *> &foundUses) {
916
- return findTransitiveUsesForAddress (base.getBaseAddress (), foundUses);
927
+ AddressUseKind findTransitiveUses (SmallVectorImpl<Operand *> &foundUses) {
928
+ return findTransitiveUsesForAddress (base.getBaseAddress (), & foundUses);
917
929
}
918
930
919
931
// / Return true of all \p uses occur before the end of the address' lifetime
0 commit comments