Skip to content

Commit 8a1ce59

Browse files
committed
AddressLowering: Don't generate an end_borrow for store_borrow
store_borrow returns the address to be borrowed and not a token Don't generate an end_borrow until this is fixed first
1 parent d6bb2c0 commit 8a1ce59

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,14 +1784,12 @@ void CallArgRewriter::rewriteIndirectArgument(Operand *operand) {
17841784
});
17851785
} else {
17861786
auto borrow = argBuilder.emitBeginBorrowOperation(callLoc, argValue);
1787-
auto *storeInst =
1788-
argBuilder.emitStoreBorrowOperation(callLoc, borrow, allocInst);
1787+
argBuilder.emitStoreBorrowOperation(callLoc, borrow, allocInst);
17891788

17901789
apply.insertAfterFullEvaluation([&](SILBuilder &callBuilder) {
1791-
if (auto *storeBorrow = dyn_cast<StoreBorrowInst>(storeInst)) {
1792-
callBuilder.emitEndBorrowOperation(callLoc, storeBorrow);
1790+
if (borrow != argValue) {
1791+
callBuilder.emitEndBorrowOperation(callLoc, borrow);
17931792
}
1794-
callBuilder.emitEndBorrowOperation(callLoc, borrow);
17951793
callBuilder.createDeallocStack(callLoc, allocInst);
17961794
});
17971795
}

0 commit comments

Comments
 (0)