@@ -131,7 +131,8 @@ bool swift::canOpcodeForwardOwnedValues(Operand *use) {
131
131
// Find all use points of \p guaranteedValue within its borrow scope. All uses
132
132
// are naturally dominated by \p guaranteedValue. If a PointerEscape is found,
133
133
// then no assumption can be made about \p guaranteedValue's lifetime. Therefore
134
- // the use points are incomplete and this returns false.
134
+ // the use points are incomplete and this returns false. The escape point that
135
+ // was found must still be in \p usePoints to distinguish from dead addresses.
135
136
//
136
137
// Accumulate results in \p usePoints, ignoring existing elements.
137
138
//
@@ -982,6 +983,8 @@ swift::findTransitiveUsesForAddress(SILValue projectedAddress,
982
983
983
984
AddressUseKind result = AddressUseKind::NonEscaping;
984
985
986
+ // Record all uses that aren't transitively followed. These are either
987
+ // instanteneous uses of the addres, or cause a pointer escape.
985
988
auto leafUse = [foundUses](Operand *use) {
986
989
if (foundUses)
987
990
foundUses->push_back (use);
@@ -1011,6 +1014,7 @@ swift::findTransitiveUsesForAddress(SILValue projectedAddress,
1011
1014
// the apply to be a use point.
1012
1015
if (isa<PartialApplyInst>(user) || isa<AddressToPointerInst>(user)) {
1013
1016
result = meet (result, AddressUseKind::PointerEscape);
1017
+ leafUse (op);
1014
1018
continue ;
1015
1019
}
1016
1020
// First, eliminate "end point uses" that we just need to check liveness at
@@ -1035,6 +1039,7 @@ swift::findTransitiveUsesForAddress(SILValue projectedAddress,
1035
1039
if (isa<UnconditionalCheckedCastAddrInst>(user)
1036
1040
|| isa<MarkFunctionEscapeInst>(user)) {
1037
1041
assert (!user->hasResults ());
1042
+ leafUse (op);
1038
1043
continue ;
1039
1044
}
1040
1045
@@ -1108,6 +1113,7 @@ swift::findTransitiveUsesForAddress(SILValue projectedAddress,
1108
1113
(*onError)(op);
1109
1114
}
1110
1115
result = meet (result, AddressUseKind::Unknown);
1116
+ leafUse (op);
1111
1117
}
1112
1118
return result;
1113
1119
}
0 commit comments