@@ -817,7 +817,10 @@ extension LifetimeDependenceDefUseWalker {
817
817
}
818
818
819
819
private mutating func walkDownAddressUses( of address: Value ) -> WalkResult {
820
- address. uses. ignoreTypeDependence. walk {
820
+ if !needWalk( for: address) {
821
+ return . continueWalk
822
+ }
823
+ return address. uses. ignoreTypeDependence. walk {
821
824
return classifyAddress ( operand: $0)
822
825
}
823
826
}
@@ -1199,6 +1202,8 @@ protocol LifetimeDependenceUseDefAddressWalker {
1199
1202
// ignored.
1200
1203
var isTrivialScope : Bool { get }
1201
1204
1205
+ mutating func needWalk( for address: Value ) -> Bool
1206
+
1202
1207
mutating func addressIntroducer( _ address: Value , access: AccessBaseAndScopes ) -> WalkResult
1203
1208
1204
1209
// The 'newLifetime' value is not forwarded to its uses. It may be a non-address or an address.
@@ -1221,6 +1226,9 @@ extension LifetimeDependenceUseDefAddressWalker {
1221
1226
}
1222
1227
1223
1228
mutating func walkUpDefault( address: Value , access: AccessBaseAndScopes ) -> WalkResult {
1229
+ if !needWalk( for: address) {
1230
+ return . continueWalk
1231
+ }
1224
1232
if let beginAccess = access. innermostAccess {
1225
1233
// Skip the access scope for unsafe[Mutable]Address. Treat it like a projection of 'self' rather than a separate
1226
1234
// variable access.
@@ -1333,6 +1341,10 @@ struct LifetimeDependenceRootWalker : LifetimeDependenceUseDefValueWalker, Lifet
1333
1341
visitedValues. insert ( value)
1334
1342
}
1335
1343
1344
+ mutating func needWalk( for address: Value ) -> Bool {
1345
+ visitedValues. insert ( address)
1346
+ }
1347
+
1336
1348
mutating func walkUp( newLifetime: Value ) -> WalkResult {
1337
1349
if newLifetime. type. isAddress {
1338
1350
return walkUp ( address: newLifetime)
0 commit comments