Skip to content

Commit 747b1ac

Browse files
committed
Fix OwnershipLivenes.swift visitInnerBorrowUses
Always visit the use even if it is the beginning of an inner borrow. This provides a "better" liveness result in the case of dead borrows and gives the client a chance to see/intercept all uses.
1 parent 0f728f0 commit 747b1ac

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/OwnershipLiveness.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,10 @@ extension InteriorUseWalker: OwnershipUseVisitor {
610610
if useVisitor(operand) == .abortWalk {
611611
return .abortWalk
612612
}
613+
return setPointerEscape(of: operand)
614+
}
615+
616+
mutating func setPointerEscape(of operand: Operand) -> WalkResult {
613617
pointerStatus.setEscaping(operand: operand)
614618
return ignoreEscape ? .continueWalk : .abortWalk
615619
}
@@ -621,7 +625,13 @@ extension InteriorUseWalker: OwnershipUseVisitor {
621625
return .abortWalk
622626
}
623627
}
624-
if visitInnerUses, let innerValue = borrowInst.innerValue {
628+
if useVisitor(operand) == .abortWalk {
629+
return .abortWalk
630+
}
631+
if visitInnerUses {
632+
guard let innerValue = borrowInst.innerValue else {
633+
return setPointerEscape(of: operand)
634+
}
625635
return visitAllUses(of: innerValue)
626636
}
627637
return visitInnerBorrowUses(of: borrowInst, operand: operand)

0 commit comments

Comments
 (0)