Skip to content

[6.2] LifetimeDependenceDefUseAddressWalker: avoid infinite recursion. #81247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ struct VariableIntroducerUseDefWalker : LifetimeDependenceUseDefValueWalker, Lif
visitedValues.insert(value)
}

mutating func needWalk(for address: Value) -> Bool {
visitedValues.insert(address)
}

mutating func walkUp(newLifetime: Value) -> WalkResult {
if newLifetime.type.isAddress {
return walkUp(address: newLifetime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,10 @@ extension LifetimeDependenceDefUseWalker {
}

private mutating func walkDownAddressUses(of address: Value) -> WalkResult {
address.uses.ignoreTypeDependence.walk {
if !needWalk(for: address) {
return .continueWalk
}
return address.uses.ignoreTypeDependence.walk {
return classifyAddress(operand: $0)
}
}
Expand Down Expand Up @@ -1199,6 +1202,8 @@ protocol LifetimeDependenceUseDefAddressWalker {
// ignored.
var isTrivialScope: Bool { get }

mutating func needWalk(for address: Value) -> Bool

mutating func addressIntroducer(_ address: Value, access: AccessBaseAndScopes) -> WalkResult

// The 'newLifetime' value is not forwarded to its uses. It may be a non-address or an address.
Expand All @@ -1221,6 +1226,9 @@ extension LifetimeDependenceUseDefAddressWalker {
}

mutating func walkUpDefault(address: Value, access: AccessBaseAndScopes) -> WalkResult {
if !needWalk(for: address) {
return .continueWalk
}
if let beginAccess = access.innermostAccess {
// Skip the access scope for unsafe[Mutable]Address. Treat it like a projection of 'self' rather than a separate
// variable access.
Expand Down Expand Up @@ -1333,6 +1341,10 @@ struct LifetimeDependenceRootWalker : LifetimeDependenceUseDefValueWalker, Lifet
visitedValues.insert(value)
}

mutating func needWalk(for address: Value) -> Bool {
visitedValues.insert(address)
}

mutating func walkUp(newLifetime: Value) -> WalkResult {
if newLifetime.type.isAddress {
return walkUp(address: newLifetime)
Expand Down