From 8f91b9e89a78e7936e0de084d213a43a466a798c Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Sun, 2 Feb 2020 12:44:52 -0800 Subject: [PATCH] [ownership] Get rid of old entrypoint for creatingEndBorrow that takes the original value. The original design was to make it so that end_borrow tied at the use level its original/borrowed value. So we would have: ``` %borrowedVal = begin_borrow %original ... end_borrow %borrowedVal from %original ``` In the end we decided not to use that design and instead just use: ``` %borrowedVal = begin_borrow %original ... end_borrow %borrowedVal ``` In order to enable that transition, I left the old API for end_borrow that took both original and borrowedVal and reimplemented it on top of the new API that just took the borrowedVal (i.e. the original was just a dead arg). Now given where we are in the development, it makes sense to get rid of that transition API and move to just use the new API. --- include/swift/SIL/SILBuilder.h | 6 ------ include/swift/SIL/SILCloner.h | 5 ++--- lib/SILGen/FormalEvaluation.cpp | 3 +-- lib/SILGen/SILGenLValue.cpp | 2 +- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/include/swift/SIL/SILBuilder.h b/include/swift/SIL/SILBuilder.h index bda95ab9f3aca..f7d8bf2f884df 100644 --- a/include/swift/SIL/SILBuilder.h +++ b/include/swift/SIL/SILBuilder.h @@ -806,12 +806,6 @@ class SILBuilder { EndBorrowInst(getSILDebugLocation(loc), borrowedValue)); } - EndBorrowInst *createEndBorrow(SILLocation Loc, SILValue BorrowedValue, - SILValue OriginalValue) { - return insert(new (getModule()) - EndBorrowInst(getSILDebugLocation(Loc), BorrowedValue)); - } - BeginAccessInst *createBeginAccess(SILLocation loc, SILValue address, SILAccessKind accessKind, SILAccessEnforcement enforcement, diff --git a/include/swift/SIL/SILCloner.h b/include/swift/SIL/SILCloner.h index ff751f61d20c2..8563c2dcbe315 100644 --- a/include/swift/SIL/SILCloner.h +++ b/include/swift/SIL/SILCloner.h @@ -1177,9 +1177,8 @@ void SILCloner::visitEndBorrowInst(EndBorrowInst *Inst) { return; recordClonedInstruction( - Inst, - getBuilder().createEndBorrow(getOpLocation(Inst->getLoc()), - getOpValue(Inst->getOperand()), SILValue())); + Inst, getBuilder().createEndBorrow(getOpLocation(Inst->getLoc()), + getOpValue(Inst->getOperand()))); } template diff --git a/lib/SILGen/FormalEvaluation.cpp b/lib/SILGen/FormalEvaluation.cpp index e392b712cb694..b15414b4f1352 100644 --- a/lib/SILGen/FormalEvaluation.cpp +++ b/lib/SILGen/FormalEvaluation.cpp @@ -48,8 +48,7 @@ void FormalAccess::verify(SILGenFunction &SGF) const { //===----------------------------------------------------------------------===// void SharedBorrowFormalAccess::finishImpl(SILGenFunction &SGF) { - SGF.B.createEndBorrow(CleanupLocation::get(loc), borrowedValue, - originalValue); + SGF.B.createEndBorrow(CleanupLocation::get(loc), borrowedValue); } //===----------------------------------------------------------------------===// diff --git a/lib/SILGen/SILGenLValue.cpp b/lib/SILGen/SILGenLValue.cpp index 747c6a97d1922..9cc3be95bdb9d 100644 --- a/lib/SILGen/SILGenLValue.cpp +++ b/lib/SILGen/SILGenLValue.cpp @@ -3711,7 +3711,7 @@ static SILValue emitLoadOfSemanticRValue(SILGenFunction &SGF, if (!isTake) { \ SILValue value = SGF.B.createLoadBorrow(loc, src); \ SILValue strongValue = SGF.B.createStrongCopy##Name##Value(loc, value); \ - SGF.B.createEndBorrow(loc, value, src); \ + SGF.B.createEndBorrow(loc, value); \ return strongValue; \ } \ /* Otherwise perform a load take and destroy the stored value. */ \