@@ -206,35 +206,40 @@ static ManagedValue emitBuiltinDestroy(SILGenFunction &SGF,
206
206
return ManagedValue::forObjectRValueWithoutOwnership (SGF.emitEmptyTuple (loc));
207
207
}
208
208
209
- static ManagedValue emitBuiltinAssign (SILGenFunction &SGF,
210
- SILLocation loc ,
211
- SubstitutionMap substitutions ,
212
- ArrayRef<ManagedValue> args ,
213
- SGFContext C ) {
214
- assert (args.size () >= 2 && " assign should have two arguments" );
209
+ static ManagedValue emitBuiltinStore (SILGenFunction &SGF, SILLocation loc ,
210
+ SubstitutionMap substitutions ,
211
+ ArrayRef<ManagedValue> args, SGFContext C ,
212
+ bool isStrict, bool isInvariant ,
213
+ llvm::MaybeAlign alignment ) {
214
+ assert (args.size () >= 2 && " should have two arguments" );
215
215
assert (substitutions.getReplacementTypes ().size () == 1 &&
216
- " assign should have a single substitution" );
216
+ " should have a single substitution" );
217
217
218
218
// The substitution determines the type of the thing we're destroying.
219
- CanType assignFormalType =
220
- substitutions.getReplacementTypes ()[0 ]->getCanonicalType ();
221
- SILType assignType = SGF.getLoweredType (assignFormalType);
222
-
219
+ CanType formalTy = substitutions.getReplacementTypes ()[0 ]->getCanonicalType ();
220
+ SILType loweredTy = SGF.getLoweredType (formalTy);
221
+
223
222
// Convert the destination pointer argument to a SIL address.
224
- SILValue addr = SGF.B .createPointerToAddress (loc,
225
- args.back ().getUnmanagedValue (),
226
- assignType.getAddressType (),
227
- /* isStrict*/ true ,
228
- /* isInvariant*/ false );
229
-
230
- // Build the value to be assigned, reconstructing tuples if needed.
231
- auto src = RValue (SGF, args.slice (0 , args.size () - 1 ), assignFormalType);
232
-
223
+ SILValue addr = SGF.B .createPointerToAddress (
224
+ loc, args.back ().getUnmanagedValue (), loweredTy.getAddressType (),
225
+ isStrict, isInvariant, alignment);
226
+
227
+ // Build the value to be stored, reconstructing tuples if needed.
228
+ auto src = RValue (SGF, args.slice (0 , args.size () - 1 ), formalTy);
229
+
233
230
std::move (src).ensurePlusOne (SGF, loc).assignInto (SGF, loc, addr);
234
231
235
232
return ManagedValue::forObjectRValueWithoutOwnership (SGF.emitEmptyTuple (loc));
236
233
}
237
234
235
+ static ManagedValue emitBuiltinAssign (SILGenFunction &SGF, SILLocation loc,
236
+ SubstitutionMap substitutions,
237
+ ArrayRef<ManagedValue> args,
238
+ SGFContext C) {
239
+ return emitBuiltinStore (SGF, loc, substitutions, args, C, /* isStrict=*/ true ,
240
+ /* isInvariant=*/ false , llvm::MaybeAlign ());
241
+ }
242
+
238
243
// / Emit Builtin.initialize by evaluating the operand directly into
239
244
// / the address.
240
245
static ManagedValue emitBuiltinInit (SILGenFunction &SGF,
0 commit comments