Skip to content

Commit 4affa11

Browse files
committed
OwnershipUtils: let visitTransitiveEndBorrows work with a BorrowedValue.
... and not only with a begin_borrow
1 parent ed7a802 commit 4affa11

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,10 +1076,10 @@ void findTransitiveReborrowBaseValuePairs(
10761076
BorrowingOperand initialScopeOperand, SILValue origBaseValue,
10771077
function_ref<void(SILPhiArgument *, SILValue)> visitReborrowBaseValuePair);
10781078

1079-
/// Given a begin_borrow visit all end_borrow users of the borrow or its
1080-
/// reborrows.
1079+
/// Given a begin of a borrow scope, visit all end_borrow users of the borrow or
1080+
/// its reborrows.
10811081
void visitTransitiveEndBorrows(
1082-
BeginBorrowInst *borrowInst,
1082+
BorrowedValue beginBorrow,
10831083
function_ref<void(EndBorrowInst *)> visitEndBorrow);
10841084

10851085
} // namespace swift

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,10 +1327,10 @@ void swift::findTransitiveReborrowBaseValuePairs(
13271327
}
13281328

13291329
void swift::visitTransitiveEndBorrows(
1330-
BeginBorrowInst *borrowInst,
1330+
BorrowedValue beginBorrow,
13311331
function_ref<void(EndBorrowInst *)> visitEndBorrow) {
13321332
SmallSetVector<SILValue, 4> worklist;
1333-
worklist.insert(borrowInst);
1333+
worklist.insert(beginBorrow.value);
13341334

13351335
while (!worklist.empty()) {
13361336
auto val = worklist.pop_back_val();

lib/SILOptimizer/Transforms/DeadCodeElimination.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,10 @@ void DCE::markLive() {
282282
OwnershipKind::Owned) {
283283
markInstructionLive(borrowInst);
284284
// Visit all end_borrows and mark them live
285-
auto visitEndBorrow = [&](EndBorrowInst *endBorrow) {
286-
markInstructionLive(endBorrow);
287-
};
288-
visitTransitiveEndBorrows(borrowInst, visitEndBorrow);
285+
visitTransitiveEndBorrows(BorrowedValue(borrowInst),
286+
[&](EndBorrowInst *endBorrow) {
287+
markInstructionLive(endBorrow);
288+
});
289289
continue;
290290
}
291291
// If not populate reborrowDependencies for this borrow

0 commit comments

Comments
 (0)