@@ -2097,6 +2097,26 @@ static ManagedValue emitBuiltinAddressOfRawLayout(SILGenFunction &SGF,
20972097 return ManagedValue::forObjectRValueWithoutOwnership (bi);
20982098}
20992099
2100+ static ManagedValue emitBuiltinZeroInitializer (SILGenFunction &SGF,
2101+ SILLocation loc,
2102+ SubstitutionMap subs,
2103+ ArrayRef<ManagedValue> args,
2104+ SGFContext C) {
2105+ auto valueType = subs.getReplacementTypes ()[0 ]->getCanonicalType ();
2106+ auto &valueTL = SGF.getTypeLowering (valueType);
2107+ auto loweredValueTy = valueTL.getLoweredType ().getObjectType ();
2108+
2109+ if (valueTL.isLoadable () ||
2110+ !SGF.F .getConventions ().useLoweredAddresses ()) {
2111+ auto value = SGF.B .createZeroInitValue (loc, loweredValueTy);
2112+ return SGF.emitManagedRValueWithCleanup (value, valueTL);
2113+ }
2114+
2115+ SILValue valueAddr = SGF.getBufferForExprResult (loc, loweredValueTy, C);
2116+ SGF.B .createZeroInitAddr (loc, valueAddr);
2117+ return SGF.manageBufferForExprResult (valueAddr, valueTL, C);
2118+ }
2119+
21002120static ManagedValue emitBuiltinEmplace (SILGenFunction &SGF,
21012121 SILLocation loc,
21022122 SubstitutionMap subs,
@@ -2129,15 +2149,7 @@ static ManagedValue emitBuiltinEmplace(SILGenFunction &SGF,
21292149 // Aside from providing a modicum of predictability if the memory isn't
21302150 // actually initialized, this also serves to communicate to DI that the memory
21312151 // is considered initialized from this point.
2132- auto zeroInit = getBuiltinValueDecl (Ctx,
2133- Ctx.getIdentifier (" zeroInitializer" ));
2134- SGF.B .createBuiltin (loc, zeroInit->getBaseIdentifier (),
2135- SILType::getEmptyTupleType (Ctx),
2136- SubstitutionMap::get (zeroInit->getInnermostDeclContext ()
2137- ->getGenericSignatureOfContext (),
2138- {resultASTTy},
2139- LookUpConformanceInModule ()),
2140- buffer);
2152+ SGF.B .createZeroInitAddr (loc, buffer);
21412153
21422154 SILValue bufferPtr = SGF.B .createAddressToPointer (loc, buffer,
21432155 SILType::getPrimitiveObjectType (SGF.getASTContext ().TheRawPointerType ),
0 commit comments