Skip to content

Commit 5749e05

Browse files
committed
[AddressLowering] Promoted emitEndBorrows.
Made the function available at the top-level so that it can be called outside of the UseRewriter, specifically, so that it can be called when rewriting begin_apply yields.
1 parent ff7b71b commit 5749e05

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,6 +2120,10 @@ void ApplyRewriter::rewriteApply(ArrayRef<SILValue> newCallArgs) {
21202120
// will be deleted with its destructure_tuple.
21212121
}
21222122

2123+
/// Emit end_borrows for a an incomplete BorrowedValue with only nonlifetime
2124+
/// ending uses.
2125+
static void emitEndBorrows(SILValue value, AddressLoweringState &pass);
2126+
21232127
void ApplyRewriter::convertBeginApplyWithOpaqueYield() {
21242128
auto *origCall = cast<BeginApplyInst>(apply.getInstruction());
21252129
SmallVector<SILValue, 4> opValues;
@@ -2762,10 +2766,6 @@ class UseRewriter : SILInstructionVisitor<UseRewriter> {
27622766

27632767
void visitStoreInst(StoreInst *storeInst);
27642768

2765-
/// Emit end_borrows for a an incomplete BorrowedValue with only nonlifetime
2766-
/// ending uses.
2767-
void emitEndBorrows(SILValue value);
2768-
27692769
void emitExtract(SingleValueInstruction *extractInst);
27702770

27712771
void visitSelectEnumInst(SelectEnumInst *sei) {
@@ -2832,7 +2832,7 @@ class UseRewriter : SILInstructionVisitor<UseRewriter> {
28322832
builder.emitLoadBorrowOperation(uncheckedCastInst->getLoc(), destAddr);
28332833
uncheckedCastInst->replaceAllUsesWith(load);
28342834
pass.deleter.forceDelete(uncheckedCastInst);
2835-
emitEndBorrows(load);
2835+
emitEndBorrows(load, pass);
28362836
}
28372837

28382838
void visitUnconditionalCheckedCastInst(
@@ -2944,7 +2944,7 @@ void UseRewriter::visitStoreInst(StoreInst *storeInst) {
29442944

29452945
/// Emit end_borrows for a an incomplete BorrowedValue with only nonlifetime
29462946
/// ending uses. This function inserts end_borrows on the lifetime boundary.
2947-
void UseRewriter::emitEndBorrows(SILValue value) {
2947+
static void emitEndBorrows(SILValue value, AddressLoweringState &pass) {
29482948
assert(BorrowedValue(value));
29492949

29502950
// Place end_borrows that cover the load_borrow uses. It is not necessary to
@@ -3002,7 +3002,7 @@ void UseRewriter::emitExtract(SingleValueInstruction *extractInst) {
30023002
SILValue loadElement =
30033003
builder.emitLoadBorrowOperation(extractInst->getLoc(), extractAddr);
30043004
replaceUsesWithLoad(extractInst, loadElement);
3005-
emitEndBorrows(loadElement);
3005+
emitEndBorrows(loadElement, pass);
30063006
}
30073007

30083008
void UseRewriter::visitStructExtractInst(StructExtractInst *extractInst) {

0 commit comments

Comments
 (0)