Skip to content

Commit 727aed3

Browse files
committed
Fix ClosureLifetimeFixup to handle pointer escapes.
Fix insertDeallocOfCapturedArguments to conservatively sink deallocs over pointer escapes.
1 parent 2fe155a commit 727aed3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/SILOptimizer/Utils/InstOptUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ void swift::insertDeallocOfCapturedArguments(
15981598
SmallVector<Operand *, 2> uses;
15991599
auto useFinding = findTransitiveUsesForAddress(asi, &uses);
16001600
InstructionSet users(asi->getFunction());
1601-
if (useFinding != AddressUseKind::Unknown) {
1601+
if (useFinding == AddressUseKind::NonEscaping) {
16021602
for (auto use : uses) {
16031603
users.insert(use->getUser());
16041604
}
@@ -1609,7 +1609,7 @@ void swift::insertDeallocOfCapturedArguments(
16091609
if (isa<UnreachableInst>(terminator))
16101610
continue;
16111611
SILInstruction *insertionPoint = nullptr;
1612-
if (useFinding != AddressUseKind::Unknown) {
1612+
if (useFinding == AddressUseKind::NonEscaping) {
16131613
insertionPoint = &block->front();
16141614
for (auto &instruction : llvm::reverse(*block)) {
16151615
if (users.contains(&instruction)) {
@@ -2463,6 +2463,7 @@ SILValue swift::getInitOfTemporaryAllocStack(AllocStackInst *asi) {
24632463

24642464
AddressWalkerState state(asi->getFunction());
24652465
AddressWalker walker(state);
2466+
// Note: ignore pointer escapes for the purpose of finding initializers.
24662467
if (std::move(walker).walk(asi) == AddressUseKind::Unknown ||
24672468
state.foundError)
24682469
return SILValue();

0 commit comments

Comments
 (0)