[semantic-arc] Handle the rest of the unqualified mem opts in SILGen.

Keep in mind that these are approximations that will not impact correctness
since in all cases I ensured that the SIL will be the same after the
OwnershipModelEliminator has run. The cases that I was unsure of I commented
with SEMANTIC ARC TODO. Once we have the verifier any confusion that may have
occurred here will be dealt with.

rdar://28685236
This commit is contained in:
Michael Gottesman
2016-10-31 16:40:31 -07:00
parent 4ee4703ae0
commit 34ec32bc14
105 changed files with 690 additions and 691 deletions

View File

@@ -317,8 +317,9 @@ public:
// load+materialize in some cases, but it's not really important.
SILValue selfValue = self.getValue();
if (selfValue->getType().isAddress()) {
selfValue =
gen.B.createLoad(loc, selfValue, LoadOwnershipQualifier::Unqualified);
// SEMANTIC ARC TODO: We are returning self as a borrowed value. Is this
// correct?
selfValue = gen.B.createLoadBorrow(loc, selfValue);
}
// Do a derived-to-base conversion if necessary.
@@ -651,8 +652,8 @@ MaterializeForSetEmitter::createAddressorCallback(SILFunction &F,
SILValue self) {
auto ownerAddress =
gen.B.createProjectValueBuffer(loc, ownerType, callbackStorage);
auto owner = gen.B.createLoad(loc, ownerAddress,
LoadOwnershipQualifier::Unqualified);
auto owner = gen.B.emitLoadValueOperation(loc, ownerAddress,
LoadOwnershipQualifier::Take);
switch (addressorKind) {
case AddressorKind::NotAddressor:
@@ -764,8 +765,8 @@ MaterializeForSetEmitter::createSetterCallback(SILFunction &F,
SILValue indicesV =
gen.B.createProjectValueBuffer(loc, indicesTy, callbackBuffer);
if (indicesTL->isLoadable())
indicesV = gen.B.createLoad(loc, indicesV,
LoadOwnershipQualifier::Unqualified);
indicesV = indicesTL->emitLoad(gen.B, loc, indicesV,
LoadOwnershipQualifier::Take);
ManagedValue mIndices =
gen.emitManagedRValueWithCleanup(indicesV, *indicesTL);
@@ -785,7 +786,7 @@ MaterializeForSetEmitter::createSetterCallback(SILFunction &F,
value = gen.B.createPointerToAddress(
loc, value, valueTL.getLoweredType().getAddressType(), /*isStrict*/ true);
if (valueTL.isLoadable())
value = gen.B.createLoad(loc, value, LoadOwnershipQualifier::Unqualified);
value = valueTL.emitLoad(gen.B, loc, value, LoadOwnershipQualifier::Take);
ManagedValue mValue = gen.emitManagedRValueWithCleanup(value, valueTL);
RValue rvalue(gen, loc, lvalue.getSubstFormalType(), mValue);