Skip to content

Commit a150c67

Browse files
committed
Remove unchecked_ownership_conversion from borrow accessor silgen
1 parent e116df3 commit a150c67

File tree

3 files changed

+2
-27
lines changed

3 files changed

+2
-27
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5479,12 +5479,6 @@ ManagedValue SILGenFunction::applyBorrowMutateAccessor(
54795479
assert(rawResults.size() == 1);
54805480
auto rawResult = rawResults[0];
54815481

5482-
if (fn.getFunction()->getConventions().hasGuaranteedResult()) {
5483-
auto selfArg = args.back().getValue();
5484-
if (isa<LoadBorrowInst>(selfArg)) {
5485-
rawResult = emitUncheckedGuaranteedConversion(rawResult);
5486-
}
5487-
}
54885482
if (rawResult->getType().isMoveOnly()) {
54895483
if (rawResult->getType().isAddress()) {
54905484
auto result = B.createMarkUnresolvedNonCopyableValueInst(

lib/SILGen/SILGenFunction.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,8 +2276,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
22762276
emitBorrowOrMutateAccessorResult(SILLocation loc, Expr *ret,
22772277
SmallVectorImpl<SILValue> &directResults);
22782278

2279-
SILValue emitUncheckedGuaranteedConversion(SILValue value);
2280-
22812279
void emitYield(SILLocation loc, MutableArrayRef<ArgumentSource> yieldValues,
22822280
ArrayRef<AbstractionPattern> origTypes,
22832281
JumpDest unwindDest);

lib/SILGen/SILGenStmt.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -708,21 +708,6 @@ static Expr *lookThroughProjections(Expr *expr) {
708708
return lookThroughProjections(lookupExpr->getBase());
709709
}
710710

711-
SILValue SILGenFunction::emitUncheckedGuaranteedConversion(SILValue value) {
712-
assert(value->getType().isObject());
713-
assert(F.getConventions().hasGuaranteedResult());
714-
auto regularLoc = RegularLocation::getAutoGeneratedLocation();
715-
// Introduce a pair of unchecked_ownership_conversion instructions to
716-
// avoid ownership errors from returning a load borrowed value.
717-
// TODO: Introduce new SIL semantics to allow returning borrowed
718-
// values from within a local borrow scope.
719-
auto result = B.createUncheckedOwnershipConversion(regularLoc, value,
720-
OwnershipKind::Unowned);
721-
result = B.createUncheckedOwnershipConversion(regularLoc, result,
722-
OwnershipKind::Guaranteed);
723-
return result;
724-
}
725-
726711
bool SILGenFunction::emitBorrowOrMutateAccessorResult(
727712
SILLocation loc, Expr *ret, SmallVectorImpl<SILValue> &directResults) {
728713
auto *afd = cast<AbstractFunctionDecl>(FunctionDC->getAsDecl());
@@ -734,9 +719,7 @@ bool SILGenFunction::emitBorrowOrMutateAccessorResult(
734719
assert(guaranteedAddress.getValue()->getType().isAddress());
735720
assert(F.getConventions().hasGuaranteedResult());
736721
auto regularLoc = RegularLocation::getAutoGeneratedLocation();
737-
auto load =
738-
B.createLoadBorrow(regularLoc, guaranteedAddress).getValue();
739-
return emitUncheckedGuaranteedConversion(load);
722+
return B.createLoadBorrow(regularLoc, guaranteedAddress).getValue();
740723
};
741724

742725
// If the return expression is a literal, emit as a regular return
@@ -853,7 +836,7 @@ bool SILGenFunction::emitBorrowOrMutateAccessorResult(
853836
// unnecessary copy_value + mark_unresolved_non_copyable_value
854837
// instructions.
855838
if (selfType.isMoveOnly()) {
856-
result = lookThroughMoveOnlyCheckerPattern(result);
839+
result = lookThroughMoveOnlyCheckerPattern(result);
857840
}
858841
// If the SIL convention is @guaranteed and the generated result is an
859842
// address, emit a load_borrow.

0 commit comments

Comments
 (0)