@@ -1232,6 +1232,14 @@ class SILBuilder {
1232
1232
operand, poisonRefs));
1233
1233
}
1234
1234
1235
+ MoveValueInst *createMoveValue (SILLocation loc, SILValue operand) {
1236
+ assert (!operand->getType ().isTrivial (getFunction ()) &&
1237
+ " Should not be passing trivial values to this api. Use instead "
1238
+ " emitMoveValueOperation" );
1239
+ return insert (new (getModule ())
1240
+ MoveValueInst (getSILDebugLocation (loc), operand));
1241
+ }
1242
+
1235
1243
UnconditionalCheckedCastInst *
1236
1244
createUnconditionalCheckedCast (SILLocation Loc, SILValue op,
1237
1245
SILType destLoweredTy,
@@ -2466,6 +2474,17 @@ class SILBuilder {
2466
2474
createDestroyAddr (loc, v);
2467
2475
}
2468
2476
2477
+ // / Convenience function that is a no-op for trivial values and inserts a
2478
+ // / move_value on non-trivial instructions.
2479
+ SILValue emitMoveValueOperation (SILLocation Loc, SILValue v) {
2480
+ assert (!v->getType ().isAddress ());
2481
+ if (v->getType ().isTrivial (*getInsertionBB ()->getParent ()))
2482
+ return v;
2483
+ assert (v.getOwnershipKind () == OwnershipKind::Owned &&
2484
+ " move_value consumes its argument" );
2485
+ return createMoveValue (Loc, v);
2486
+ }
2487
+
2469
2488
SILValue emitTupleExtract (SILLocation Loc, SILValue Operand, unsigned FieldNo,
2470
2489
SILType ResultTy) {
2471
2490
// Fold tuple_extract(tuple(x,y,z),2)
0 commit comments