@@ -202,6 +202,25 @@ class RecordTypeInfoImpl : public Base,
202202 return emitAssignWithTakeCall (IGF, T, dest, src);
203203 }
204204
205+ if (auto rawLayout = T.getRawLayout ()) {
206+ // Because we have a rawlayout attribute, we know this has to be a struct.
207+ auto structDecl = T.getStructOrBoundGenericStruct ();
208+
209+ if (auto likeType = rawLayout->getResolvedScalarLikeType (structDecl)) {
210+ if (rawLayout->shouldMoveAsLikeType ()) {
211+ auto astT = T.getASTType ();
212+ auto subs = astT->getContextSubstitutionMap (IGF.IGM .getSwiftModule (),
213+ structDecl);
214+ auto loweredLikeType = IGF.IGM .getLoweredType (likeType->subst (subs));
215+ auto &likeTypeInfo = IGF.IGM .getTypeInfo (loweredLikeType);
216+
217+ likeTypeInfo.assignWithTake (IGF, dest, src, loweredLikeType,
218+ isOutlined);
219+ return ;
220+ }
221+ }
222+ }
223+
205224 if (isOutlined || T.hasParameterizedExistential ()) {
206225 auto offsets = asImpl ().getNonFixedOffsets (IGF, T);
207226 for (auto &field : getFields ()) {
@@ -261,7 +280,22 @@ class RecordTypeInfoImpl : public Base,
261280 } else if (!AreFieldsABIAccessible) {
262281 // If the fields are not ABI-accessible, use the value witness table.
263282 return emitInitializeWithTakeCall (IGF, T, dest, src);
264-
283+ } else if (auto rawLayout = T.getRawLayout ()) {
284+ // Because we have a rawlayout attribute, we know this has to be a struct.
285+ auto structDecl = T.getStructOrBoundGenericStruct ();
286+
287+ if (auto likeType = rawLayout->getResolvedScalarLikeType (structDecl)) {
288+ if (rawLayout->shouldMoveAsLikeType ()) {
289+ auto astT = T.getASTType ();
290+ auto subs = astT->getContextSubstitutionMap (IGF.IGM .getSwiftModule (),
291+ structDecl);
292+ auto loweredLikeType = IGF.IGM .getLoweredType (likeType->subst (subs));
293+ auto &likeTypeInfo = IGF.IGM .getTypeInfo (loweredLikeType);
294+
295+ likeTypeInfo.initializeWithTake (IGF, dest, src, loweredLikeType,
296+ isOutlined, zeroizeIfSensitive);
297+ }
298+ }
265299 } else if (isOutlined || T.hasParameterizedExistential ()) {
266300 auto offsets = asImpl ().getNonFixedOffsets (IGF, T);
267301 for (auto &field : getFields ()) {
0 commit comments