Skip to content

Commit 123ea69

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 123ea69

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-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
}

test/SILGen/opaque_values_silgen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-emit-silgen -enable-sil-opaque-values -Xllvm -sil-full-demangle %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
2+
// RUN: %target-swift-emit-sil -enable-sil-opaque-values -Xllvm -sil-full-demangle %s
23

34
// Test SILGen -enable-sil-opaque-values with tests that depend on the stdlib.
45

0 commit comments

Comments
 (0)