Skip to content

Commit 7760dbc

Browse files
committed
Fix ClosureLifetimeFixup handling of incomplete liveness.
Correctly handle pointer escapes and dependent uses to avoid miscompiles.
1 parent d73a081 commit 7760dbc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/SILOptimizer/Mandatory/ClosureLifetimeFixup.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -899,10 +899,16 @@ static SILValue tryRewriteToPartialApplyStack(
899899

900900
OrigUnmodifiedDuringClosureLifetimeWalker origUseWalker(
901901
closureLiveness, origIsUnmodifiedDuringClosureLifetime);
902-
auto walkResult = std::move(origUseWalker).walk(orig);
903-
904-
if (walkResult == AddressUseKind::Unknown ||
905-
!origIsUnmodifiedDuringClosureLifetime) {
902+
switch (origUseWalker.walk(orig)) {
903+
case AddressUseKind::NonEscaping:
904+
case AddressUseKind::Dependent:
905+
// Dependent uses are ignored because they cannot modify the original.
906+
break;
907+
case AddressUseKind::PointerEscape:
908+
case AddressUseKind::Unknown:
909+
continue;
910+
}
911+
if (!origIsUnmodifiedDuringClosureLifetime) {
906912
continue;
907913
}
908914

0 commit comments

Comments
 (0)