[ownership] Update emitIndirectConditionalCastWithScalar for ownership.

This comes up because when we perform mandatory inlining, we perform the
transform as we inline. So the tests for this are in mandatory_inlining
naturally.
This commit is contained in:
Michael Gottesman
2019-02-18 15:13:33 -08:00
parent ab827a9821
commit 42d184995e
5 changed files with 439 additions and 28 deletions

View File

@@ -716,6 +716,27 @@ public:
BeginBorrowInst(getSILDebugLocation(Loc), LV));
}
SILValue emitLoadBorrowOperation(SILLocation loc, SILValue v) {
if (!hasOwnership()) {
return emitLoadValueOperation(loc, v,
LoadOwnershipQualifier::Unqualified);
}
return createLoadBorrow(loc, v);
}
SILValue emitBeginBorrowOperation(SILLocation loc, SILValue v) {
if (!hasOwnership() ||
v.getOwnershipKind().isCompatibleWith(ValueOwnershipKind::Guaranteed))
return v;
return createBeginBorrow(loc, v);
}
void emitEndBorrowOperation(SILLocation loc, SILValue v) {
if (!hasOwnership())
return;
createEndBorrow(loc, v);
}
// Pass in an address or value, perform a begin_borrow/load_borrow and pass
// the value to the passed in closure. After the closure has finished
// executing, automatically insert the end_borrow. The closure can assume that