@@ -2097,6 +2097,26 @@ static ManagedValue emitBuiltinAddressOfRawLayout(SILGenFunction &SGF,
2097
2097
return ManagedValue::forObjectRValueWithoutOwnership (bi);
2098
2098
}
2099
2099
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
+
2100
2120
static ManagedValue emitBuiltinEmplace (SILGenFunction &SGF,
2101
2121
SILLocation loc,
2102
2122
SubstitutionMap subs,
@@ -2129,15 +2149,7 @@ static ManagedValue emitBuiltinEmplace(SILGenFunction &SGF,
2129
2149
// Aside from providing a modicum of predictability if the memory isn't
2130
2150
// actually initialized, this also serves to communicate to DI that the memory
2131
2151
// 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);
2141
2153
2142
2154
SILValue bufferPtr = SGF.B .createAddressToPointer (loc, buffer,
2143
2155
SILType::getPrimitiveObjectType (SGF.getASTContext ().TheRawPointerType ),
0 commit comments