@@ -218,7 +218,7 @@ static ManagedValue borrowedCastToOriginalSelfType(SILGenFunction &SGF,
218218 if (originalSelfType.is <AnyMetatypeType>()) {
219219 assert (originalSelfType.isTrivial (SGF.F ) &&
220220 " Metatypes should always be trivial" );
221- return ManagedValue::forUnmanaged (originalSelf);
221+ return ManagedValue::forObjectRValueWithoutOwnership (originalSelf);
222222 }
223223
224224 // Otherwise, we have a non-metatype. Use a borrow+unchecked_ref_cast.
@@ -629,14 +629,14 @@ class Callee {
629629 auto constantInfo =
630630 SGF.getConstantInfo (SGF.getTypeExpansionContext (), *constant);
631631 SILValue ref = SGF.emitGlobalFunctionRef (Loc, *constant, constantInfo);
632- return ManagedValue::forUnmanaged (ref);
632+ return ManagedValue::forObjectRValueWithoutOwnership (ref);
633633 }
634634 case Kind::StandaloneFunctionDynamicallyReplaceableImpl: {
635635 auto constantInfo =
636636 SGF.getConstantInfo (SGF.getTypeExpansionContext (), *constant);
637637 SILValue ref =
638638 SGF.emitGlobalFunctionRef (Loc, *constant, constantInfo, true );
639- return ManagedValue::forUnmanaged (ref);
639+ return ManagedValue::forObjectRValueWithoutOwnership (ref);
640640 }
641641 case Kind::ClassMethod: {
642642 auto methodTy = SGF.SGM .Types .getConstantOverrideType (
@@ -655,7 +655,7 @@ class Callee {
655655 SILType::getPrimitiveObjectType (methodTy));
656656 }
657657 S.pop ();
658- return ManagedValue::forUnmanaged (methodVal);
658+ return ManagedValue::forObjectRValueWithoutOwnership (methodVal);
659659 }
660660 case Kind::SuperMethod: {
661661 ArgumentScope S (SGF, Loc);
@@ -709,7 +709,7 @@ class Callee {
709709 *constant, constantInfo.getSILType ());
710710 }
711711 S.pop ();
712- return ManagedValue::forUnmanaged (fn);
712+ return ManagedValue::forObjectRValueWithoutOwnership (fn);
713713 }
714714 case Kind::DynamicMethod: {
715715 auto closureType = getDynamicMethodLoweredType (
@@ -720,7 +720,7 @@ class Callee {
720720 Loc, borrowedSelf->getValue (), *constant,
721721 closureType);
722722 S.pop ();
723- return ManagedValue::forUnmanaged (fn);
723+ return ManagedValue::forObjectRValueWithoutOwnership (fn);
724724 }
725725 }
726726 llvm_unreachable (" unhandled kind" );
@@ -1010,7 +1010,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
10101010 llvm_unreachable (" shouldn't happen" );
10111011 }
10121012
1013- auto result = ManagedValue::forUnmanaged (convertedValue);
1013+ auto result = ManagedValue::forObjectRValueWithoutOwnership (convertedValue);
10141014 return {result, SGF.getLoweredType (instanceType)};
10151015 }
10161016
@@ -1550,9 +1550,12 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
15501550 self = SGF.emitUndef (selfFormalType);
15511551 } else if (SGF.AllocatorMetatype ) {
15521552 self = emitCorrespondingSelfValue (
1553- ManagedValue::forUnmanaged (SGF.AllocatorMetatype ), arg);
1553+ ManagedValue::forObjectRValueWithoutOwnership (
1554+ SGF.AllocatorMetatype ),
1555+ arg);
15541556 } else {
1555- self = ManagedValue::forUnmanaged (SGF.emitMetatypeOfValue (expr, arg));
1557+ self = ManagedValue::forObjectRValueWithoutOwnership (
1558+ SGF.emitMetatypeOfValue (expr, arg));
15561559 }
15571560 } else {
15581561 // If we haven't allocated "self" yet at this point, do so.
@@ -1565,10 +1568,10 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
15651568 // initializer is @objc.
15661569 usesObjCAllocation = true ;
15671570 }
1568-
1569- self = allocateObject (
1570- ManagedValue::forUnmanaged ( SGF.AllocatorMetatype ), arg ,
1571- usesObjCAllocation);
1571+
1572+ self = allocateObject (ManagedValue::forObjectRValueWithoutOwnership (
1573+ SGF.AllocatorMetatype ),
1574+ arg, usesObjCAllocation);
15721575
15731576 // Perform any adjustments needed to 'self'.
15741577 self = emitCorrespondingSelfValue (self, arg);
@@ -1819,7 +1822,8 @@ static PreparedArguments emitStringLiteralArgs(SILGenFunction &SGF, SILLocation
18191822 AnyFunctionType::Param param (Int32Ty.getASTType ());
18201823 PreparedArguments args (llvm::ArrayRef<AnyFunctionType::Param>{param});
18211824 args.add (E, RValue (SGF, E, Int32Ty.getASTType (),
1822- ManagedValue::forUnmanaged (UnicodeScalarValue)));
1825+ ManagedValue::forObjectRValueWithoutOwnership (
1826+ UnicodeScalarValue)));
18231827 return args;
18241828 }
18251829 }
@@ -1836,10 +1840,9 @@ static PreparedArguments emitStringLiteralArgs(SILGenFunction &SGF, SILLocation
18361840 auto *isASCIIInst = SGF.B .createIntegerLiteral (E, Int1Ty, isASCII);
18371841
18381842 ManagedValue EltsArray[] = {
1839- ManagedValue::forUnmanaged (string),
1840- ManagedValue::forUnmanaged (lengthInst),
1841- ManagedValue::forUnmanaged (isASCIIInst)
1842- };
1843+ ManagedValue::forObjectRValueWithoutOwnership (string),
1844+ ManagedValue::forObjectRValueWithoutOwnership (lengthInst),
1845+ ManagedValue::forObjectRValueWithoutOwnership (isASCIIInst)};
18431846
18441847 AnyFunctionType::Param TypeEltsArray[] = {
18451848 AnyFunctionType::Param (EltsArray[0 ].getType ().getASTType ()),
@@ -2043,7 +2046,8 @@ buildBuiltinLiteralArgs(SILGenFunction &SGF, SGFContext C,
20432046 auto i1Ty = SILType::getBuiltinIntegerType (1 , SGF.getASTContext ());
20442047 SILValue boolValue = SGF.B .createIntegerLiteral (booleanLiteral, i1Ty,
20452048 booleanLiteral->getValue ());
2046- ManagedValue boolManaged = ManagedValue::forUnmanaged (boolValue);
2049+ ManagedValue boolManaged =
2050+ ManagedValue::forObjectRValueWithoutOwnership (boolValue);
20472051 CanType ty = boolManaged.getType ().getASTType ()->getCanonicalType ();
20482052 builtinLiteralArgs.emplace (AnyFunctionType::Param (ty));
20492053 builtinLiteralArgs.add (booleanLiteral, RValue (SGF, {boolManaged}, ty));
@@ -2055,7 +2059,7 @@ buildBuiltinLiteralArgs(SILGenFunction &SGF, SGFContext C,
20552059 IntegerLiteralExpr *integerLiteral) {
20562060 PreparedArguments builtinLiteralArgs;
20572061 ManagedValue integerManaged =
2058- ManagedValue::forUnmanaged (SGF.B .createIntegerLiteral (
2062+ ManagedValue::forObjectRValueWithoutOwnership (SGF.B .createIntegerLiteral (
20592063 integerLiteral,
20602064 SILType::getBuiltinIntegerLiteralType (SGF.getASTContext ()),
20612065 integerLiteral->getRawValue ()));
@@ -2071,7 +2075,7 @@ buildBuiltinLiteralArgs(SILGenFunction &SGF, SGFContext C,
20712075 PreparedArguments builtinLiteralArgs;
20722076 auto *litTy = floatLiteral->getBuiltinType ()->castTo <BuiltinFloatType>();
20732077 ManagedValue floatManaged =
2074- ManagedValue::forUnmanaged (SGF.B .createFloatLiteral (
2078+ ManagedValue::forObjectRValueWithoutOwnership (SGF.B .createFloatLiteral (
20752079 floatLiteral,
20762080 SILType::getBuiltinFloatType (litTy->getFPKind (), SGF.getASTContext ()),
20772081 floatLiteral->getValue ()));
@@ -2100,7 +2104,7 @@ buildBuiltinLiteralArgs(SILGenFunction &SGF, SGFContext C,
21002104 // The version of the regex string.
21012105 // %3 = integer_literal $Builtin.IntLiteral <version>
21022106 auto versionIntLiteral =
2103- ManagedValue::forUnmanaged (SGF.B .createIntegerLiteral (
2107+ ManagedValue::forObjectRValueWithoutOwnership (SGF.B .createIntegerLiteral (
21042108 expr, SILType::getBuiltinIntegerLiteralType (SGF.getASTContext ()),
21052109 expr->getVersion ()));
21062110
@@ -2187,7 +2191,8 @@ buildBuiltinLiteralArgs(SILGenFunction &SGF, SGFContext C,
21872191 auto silTy = SILType::getBuiltinIntegerLiteralType (ctx);
21882192 auto ty = silTy.getASTType ();
21892193 SILValue integer = SGF.B .createIntegerLiteral (magicLiteral, silTy, Value);
2190- ManagedValue integerManaged = ManagedValue::forUnmanaged (integer);
2194+ ManagedValue integerManaged =
2195+ ManagedValue::forObjectRValueWithoutOwnership (integer);
21912196 PreparedArguments builtinLiteralArgs;
21922197 builtinLiteralArgs.emplace (AnyFunctionType::Param (ty));
21932198 builtinLiteralArgs.add (magicLiteral, RValue (SGF, {integerManaged}, ty));
@@ -6090,7 +6095,7 @@ RValue SILGenFunction::emitApplyAllocatingInitializer(SILLocation loc,
60906095 if (selfMetaTy != selfParamMetaTy)
60916096 selfMeta = B.createUpcast (loc, selfMeta, selfParamMetaTy);
60926097
6093- selfMetaVal = ManagedValue::forUnmanaged (selfMeta);
6098+ selfMetaVal = ManagedValue::forObjectRValueWithoutOwnership (selfMeta);
60946099 }
60956100
60966101 // Form the callee.
@@ -6221,10 +6226,9 @@ SILGenFunction::emitUninitializedArrayAllocation(Type ArrayTy,
62216226 // Invoke the intrinsic, which returns a tuple.
62226227 auto subMap = ArrayTy->getContextSubstitutionMap (SGM.M .getSwiftModule (),
62236228 Ctx.getArrayDecl ());
6224- auto result = emitApplyOfLibraryIntrinsic (Loc, allocate,
6225- subMap,
6226- ManagedValue::forUnmanaged (Length),
6227- SGFContext ());
6229+ auto result = emitApplyOfLibraryIntrinsic (
6230+ Loc, allocate, subMap,
6231+ ManagedValue::forObjectRValueWithoutOwnership (Length), SGFContext ());
62286232
62296233 // Explode the tuple.
62306234 SmallVector<ManagedValue, 2 > resultElts;
@@ -6935,7 +6939,7 @@ ManagedValue SILGenFunction::emitAsyncLetStart(
69356939 getLoweredType (ctx.TheRawPointerType ), subs,
69366940 {taskOptions, taskFunction.getValue (), resultBuf});
69376941
6938- return ManagedValue::forUnmanaged (apply);
6942+ return ManagedValue::forObjectRValueWithoutOwnership (apply);
69396943}
69406944
69416945ManagedValue SILGenFunction::emitCancelAsyncTask (
@@ -6946,7 +6950,7 @@ ManagedValue SILGenFunction::emitCancelAsyncTask(
69466950 ctx.getIdentifier (getBuiltinName (BuiltinValueKind::CancelAsyncTask)),
69476951 getLoweredType (ctx.TheEmptyTupleType ), SubstitutionMap (),
69486952 { task });
6949- return ManagedValue::forUnmanaged (apply);
6953+ return ManagedValue::forObjectRValueWithoutOwnership (apply);
69506954}
69516955
69526956ManagedValue SILGenFunction::emitReadAsyncLetBinding (SILLocation loc,
@@ -6967,11 +6971,12 @@ ManagedValue SILGenFunction::emitReadAsyncLetBinding(SILLocation loc,
69676971
69686972 // The intrinsic returns a pointer to the address of the result value inside
69696973 // the async let task context.
6970- emitApplyOfLibraryIntrinsic (loc, asyncLetGet, {},
6971- {ManagedValue::forTrivialObjectRValue (childTask.asyncLet ),
6972- ManagedValue::forTrivialObjectRValue (childTask.resultBuf )},
6973- SGFContext ());
6974-
6974+ emitApplyOfLibraryIntrinsic (
6975+ loc, asyncLetGet, {},
6976+ {ManagedValue::forObjectRValueWithoutOwnership (childTask.asyncLet ),
6977+ ManagedValue::forObjectRValueWithoutOwnership (childTask.resultBuf )},
6978+ SGFContext ());
6979+
69756980 auto resultAddr = B.createPointerToAddress (loc, childTask.resultBuf ,
69766981 loweredOpaquePatternType.getAddressType (),
69776982 /* strict*/ true ,
@@ -7054,10 +7059,11 @@ void SILGenFunction::emitFinishAsyncLet(
70547059 SILLocation loc, SILValue asyncLet, SILValue resultPtr) {
70557060 // This runtime function cancels the task, awaits its completion, and
70567061 // destroys the value in the result buffer if necessary.
7057- emitApplyOfLibraryIntrinsic (loc, SGM.getFinishAsyncLet (), {},
7058- {ManagedValue::forTrivialObjectRValue (asyncLet),
7059- ManagedValue::forTrivialObjectRValue (resultPtr)},
7060- SGFContext ());
7062+ emitApplyOfLibraryIntrinsic (
7063+ loc, SGM.getFinishAsyncLet (), {},
7064+ {ManagedValue::forObjectRValueWithoutOwnership (asyncLet),
7065+ ManagedValue::forObjectRValueWithoutOwnership (resultPtr)},
7066+ SGFContext ());
70617067 // This builtin ends the lifetime of the allocation for the async let.
70627068 auto &ctx = getASTContext ();
70637069 B.createBuiltin (loc,
0 commit comments