Skip to content

Commit 5a1a487

Browse files
committed
Fix InteriorUseWalker to handle dependent lifetimes as inner scopes
Inner scopes must all be reported because the walker assumes they are complete. It is up to the client to either complete them or recursively follow them.
1 parent 7f6962a commit 5a1a487

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/OwnershipLiveness.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,10 @@ extension InteriorUseWalker {
785785
}
786786
switch value.ownership {
787787
case .owned:
788+
// Each owned lifetime is an inner scope.
789+
if handleInner(borrowed: value) == .abortWalk {
790+
return .abortWalk
791+
}
788792
return visitInnerScopeUses(of: value)
789793
case .guaranteed:
790794
return visitAllUses(of: value)
@@ -929,6 +933,11 @@ let interiorLivenessTest = FunctionTest("interior_liveness_swift") {
929933
}
930934
defer { visitor.deinitialize() }
931935

936+
visitor.innerScopeHandler = {
937+
print("Inner scope: \($0)")
938+
return .continueWalk
939+
}
940+
932941
let success = visitor.visitUses()
933942

934943
switch visitor.pointerStatus {

0 commit comments

Comments
 (0)