Skip to content

Commit 104379a

Browse files
committed
[silgen] Rename SILGenFunction::emitManagedRetain -> emitManagedCopy.
This is an old API that should have been renamed a long time ago. It just kept its early name due to inertia.
1 parent b234b79 commit 104379a

File tree

6 files changed

+15
-17
lines changed

6 files changed

+15
-17
lines changed

lib/SILGen/SILGenBridging.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static ManagedValue emitManagedParameter(SILGenFunction &SGF, SILLocation loc,
312312

313313
case ParameterConvention::Direct_Unowned:
314314
// We need to independently retain the value.
315-
return SGF.emitManagedRetain(loc, value, valueTL);
315+
return SGF.emitManagedCopy(loc, value, valueTL);
316316

317317
case ParameterConvention::Indirect_Inout:
318318
return ManagedValue::forLValue(value);
@@ -2180,7 +2180,7 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) {
21802180
break;
21812181
case ParameterConvention::Direct_Guaranteed:
21822182
case ParameterConvention::Direct_Unowned:
2183-
param = emitManagedRetain(fd, paramValue);
2183+
param = emitManagedCopy(fd, paramValue);
21842184
break;
21852185
case ParameterConvention::Indirect_Inout:
21862186
case ParameterConvention::Indirect_InoutAliasable:

lib/SILGen/SILGenBuiltin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ static ManagedValue emitBuiltinBridgeFromRawPointer(SILGenFunction &SGF,
406406
SILValue result = SGF.B.createRawPointerToRef(loc, args[0].getUnmanagedValue(),
407407
destType);
408408
// The result has ownership semantics, so retain it with a cleanup.
409-
return SGF.emitManagedRetain(loc, result, destLowering);
409+
return SGF.emitManagedCopy(loc, result, destLowering);
410410
}
411411

412412
static ManagedValue emitBuiltinAddressOfBuiltins(SILGenFunction &SGF,
@@ -924,7 +924,7 @@ static ManagedValue emitBuiltinValueToBridgeObject(SILGenFunction &SGF,
924924
}
925925

926926
SILValue result = SGF.B.createValueToBridgeObject(loc, args[0].getValue());
927-
return SGF.emitManagedRetain(loc, result);
927+
return SGF.emitManagedCopy(loc, result);
928928
}
929929

930930
// This should only accept as an operand type single-refcounted-pointer types,

lib/SILGen/SILGenExpr.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,13 @@
6060
using namespace swift;
6161
using namespace Lowering;
6262

63-
ManagedValue SILGenFunction::emitManagedRetain(SILLocation loc,
64-
SILValue v) {
63+
ManagedValue SILGenFunction::emitManagedCopy(SILLocation loc, SILValue v) {
6564
auto &lowering = getTypeLowering(v->getType());
66-
return emitManagedRetain(loc, v, lowering);
65+
return emitManagedCopy(loc, v, lowering);
6766
}
6867

69-
ManagedValue SILGenFunction::emitManagedRetain(SILLocation loc,
70-
SILValue v,
71-
const TypeLowering &lowering) {
68+
ManagedValue SILGenFunction::emitManagedCopy(SILLocation loc, SILValue v,
69+
const TypeLowering &lowering) {
7270
assert(lowering.getLoweredType() == v->getType());
7371
if (lowering.isTrivial())
7472
return ManagedValue::forRValueWithoutOwnership(v);
@@ -5710,7 +5708,7 @@ class AutoreleasingWritebackComponent : public LogicalPathComponent {
57105708
auto strongType = SILType::getPrimitiveObjectType(
57115709
unowned->getType().castTo<UnmanagedStorageType>().getReferentType());
57125710
auto owned = SGF.B.createUnmanagedToRef(loc, unowned, strongType);
5713-
auto ownedMV = SGF.emitManagedRetain(loc, owned);
5711+
auto ownedMV = SGF.emitManagedCopy(loc, owned);
57145712

57155713
// Then create a mark dependence in between the base and the ownedMV. This
57165714
// is important to ensure that the destroy of the assign is not hoisted

lib/SILGen/SILGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ void SILGenFunction::emitCaptures(SILLocation loc,
864864
capturedArgs.push_back(
865865
ManagedValue::forUnmanaged(Entry.box).borrow(*this, loc));
866866
} else {
867-
capturedArgs.push_back(emitManagedRetain(loc, Entry.box));
867+
capturedArgs.push_back(emitManagedCopy(loc, Entry.box));
868868
}
869869
if (captureCanEscape)
870870
escapesToMark.push_back(val);

lib/SILGen/SILGenFunction.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,9 +1697,9 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
16971697
Type resultType,
16981698
RValue &&operand);
16991699

1700-
ManagedValue emitManagedRetain(SILLocation loc, SILValue v);
1701-
ManagedValue emitManagedRetain(SILLocation loc, SILValue v,
1702-
const TypeLowering &lowering);
1700+
ManagedValue emitManagedCopy(SILLocation loc, SILValue v);
1701+
ManagedValue emitManagedCopy(SILLocation loc, SILValue v,
1702+
const TypeLowering &lowering);
17031703

17041704
ManagedValue emitManagedLoadCopy(SILLocation loc, SILValue v);
17051705
ManagedValue emitManagedLoadCopy(SILLocation loc, SILValue v,

lib/SILGen/SILGenPoly.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ class TranslateArguments : public ExpanderBase<TranslateArguments> {
17561756
// initially owned.
17571757
if (inner.getOwnershipKind() == OwnershipKind::Unowned) {
17581758
assert(!inner.hasCleanup());
1759-
inner = SGF.emitManagedRetain(Loc, inner.getValue());
1759+
inner = SGF.emitManagedCopy(Loc, inner.getValue());
17601760
}
17611761

17621762
// If the inner is unowned or owned, create a borrow.
@@ -4366,7 +4366,7 @@ void ResultPlanner::execute(SmallVectorImpl<SILValue> &innerDirectResultStack,
43664366
"reabstraction of returns_inner_pointer function");
43674367
LLVM_FALLTHROUGH;
43684368
case ResultConvention::Unowned:
4369-
return SGF.emitManagedRetain(Loc, resultValue, resultTL);
4369+
return SGF.emitManagedCopy(Loc, resultValue, resultTL);
43704370
}
43714371
llvm_unreachable("bad result convention!");
43724372
};

0 commit comments

Comments
 (0)