Skip to content

Commit b99a140

Browse files
committed
[SIL] Add hasPointerEscape(SILValue).
There is a preexisting function with this name that takes a BorrowedValue. The new function calls that preexisting function if a BorrowedValue can be constructed from the SILValue. Otherwise, it looks for direct uses of the value which qualify as "pointer escapes".
1 parent f284e72 commit b99a140

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ inline bool isForwardingConsume(SILValue value) {
122122

123123
bool hasPointerEscape(BorrowedValue value);
124124

125+
bool hasPointerEscape(SILValue value);
126+
125127
/// Find leaf "use points" of \p guaranteedValue that determine its lifetime
126128
/// requirement. Return true if no PointerEscape use was found.
127129
///

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ bool swift::hasPointerEscape(BorrowedValue value) {
8383
return false;
8484
}
8585

86+
bool swift::hasPointerEscape(SILValue value) {
87+
if (auto borrowedValue = BorrowedValue(value)) {
88+
return hasPointerEscape(borrowedValue);
89+
}
90+
for (auto use : value->getUses()) {
91+
switch (use->getOperandOwnership()) {
92+
case OperandOwnership::PointerEscape:
93+
case OperandOwnership::ForwardingUnowned:
94+
return true;
95+
default:
96+
break;
97+
}
98+
}
99+
return false;
100+
}
101+
86102
bool swift::canOpcodeForwardInnerGuaranteedValues(SILValue value) {
87103
// If we have an argument from a transforming terminator, we can forward
88104
// guaranteed.

0 commit comments

Comments
 (0)