Skip to content

Commit 78ce13d

Browse files
committed
WalkUtils: Don't treat end_access as leaf-use in the AddressDefUseWalker
Instead just ignore it.
1 parent ee2924f commit 78ce13d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/WalkUtils.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,17 @@ extension AddressDefUseWalker {
470470
} else {
471471
return unmatchedPath(address: operand, path: path)
472472
}
473-
case is InitExistentialAddrInst, is OpenExistentialAddrInst, is BeginAccessInst,
474-
is IndexAddrInst, is MarkMustCheckInst:
473+
case is InitExistentialAddrInst, is OpenExistentialAddrInst,
474+
is IndexAddrInst, is MarkMustCheckInst:
475475
// FIXME: for now `index_addr` is treated as a forwarding instruction since
476476
// SmallProjectionPath does not track indices.
477477
// This is ok since `index_addr` is eventually preceeded by a `tail_addr`
478478
// which has pushed a `"ct"` component on the path that matches any
479479
// `index_addr` address.
480480
return walkDownUses(ofAddress: instruction as! SingleValueInstruction, path: path)
481+
case let ba as BeginAccessInst:
482+
// Don't treat `end_access` as leaf-use. Just ignore it.
483+
return walkDownNonEndAccessUses(of: ba, path: path)
481484
case let mdi as MarkDependenceInst:
482485
if operand.index == 0 {
483486
return walkDownUses(ofAddress: mdi, path: path)
@@ -497,6 +500,16 @@ extension AddressDefUseWalker {
497500
}
498501
return .continueWalk
499502
}
503+
504+
private mutating func walkDownNonEndAccessUses(of beginAccess: BeginAccessInst, path: Path) -> WalkResult {
505+
for operand in beginAccess.uses where !operand.isTypeDependent {
506+
if !(operand.instruction is EndAccessInst),
507+
walkDown(address: operand, path: path) == .abortWalk {
508+
return .abortWalk
509+
}
510+
}
511+
return .continueWalk
512+
}
500513
}
501514

502515
/// - A `UseDefWalker` can be used to find all "generating" definitions of

0 commit comments

Comments
 (0)