@@ -206,35 +206,48 @@ static ManagedValue emitBuiltinDestroy(SILGenFunction &SGF,
206206 return ManagedValue::forObjectRValueWithoutOwnership (SGF.emitEmptyTuple (loc));
207207}
208208
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" );
215215 assert (substitutions.getReplacementTypes ().size () == 1 &&
216- " assign should have a single substitution" );
216+ " should have a single substitution" );
217217
218218 // 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+
223222 // 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+
233230 std::move (src).ensurePlusOne (SGF, loc).assignInto (SGF, loc, addr);
234231
235232 return ManagedValue::forObjectRValueWithoutOwnership (SGF.emitEmptyTuple (loc));
236233}
237234
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+
243+ static ManagedValue emitBuiltinStoreRaw (SILGenFunction &SGF, SILLocation loc,
244+ SubstitutionMap substitutions,
245+ ArrayRef<ManagedValue> args,
246+ SGFContext C) {
247+ return emitBuiltinStore (SGF, loc, substitutions, args, C, /* isStrict=*/ false ,
248+ /* isInvariant=*/ false , llvm::MaybeAlign (1 ));
249+ }
250+
238251// / Emit Builtin.initialize by evaluating the operand directly into
239252// / the address.
240253static ManagedValue emitBuiltinInit (SILGenFunction &SGF,
0 commit comments