swift
a19b02d6 - DCE: fix a missing `end_borrow` when a dead reborrow phi is removed

Commit
7 days ago
DCE: fix a missing `end_borrow` when a dead reborrow phi is removed When a reborrow phi is dead, DCE removes it and puts an `end_borrow` of the incoming value at the branch in each predecessor block. However, those predecessor blocks may contain no live instructions. In that case the terminator controlling them was considered dead and replaced by a jump to the nearest useful post-dominator. The predecessor blocks, including the newly inserted `end_borrow`s, then became unreachable and were removed, and the borrow scope leaked on that path. Fix this by keeping the controlling terminators of reborrowing branch blocks live whenever the reborrowed guaranteed value is live. This is the same as for an explicit `end_borrow`, which is live whenever its operand is live. Fixes an ownership verifier error: "Found a leak due to a consuming post-dominance failure" https://github.com/swiftlang/swift/issues/92857 rdar://189011173
Author
Committer
Parents
Loading