mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AddressLowering] Handle weak copies.
Lower the `strong_copy_weak_value` and `weak_copy_value` to `load_weak` and `store_weak` respectively.
This commit is contained in:
@@ -3483,6 +3483,14 @@ protected:
|
||||
pass.deleter.forceDelete(sei);
|
||||
}
|
||||
|
||||
void visitStrongCopyWeakValueInst(StrongCopyWeakValueInst *scwvi) {
|
||||
auto sourceAddr = addrMat.materializeAddress(use->get());
|
||||
SILValue value =
|
||||
builder.createLoadWeak(scwvi->getLoc(), sourceAddr, IsNotTake);
|
||||
scwvi->replaceAllUsesWith(value);
|
||||
pass.deleter.forceDelete(scwvi);
|
||||
}
|
||||
|
||||
// Extract from an opaque struct.
|
||||
void visitStructExtractInst(StructExtractInst *extractInst);
|
||||
|
||||
@@ -4094,6 +4102,15 @@ protected:
|
||||
|
||||
rewriteUnconditionalCheckedCastInst(uncondCheckedCast, pass);
|
||||
}
|
||||
|
||||
void visitWeakCopyValueInst(WeakCopyValueInst *wcsvi) {
|
||||
auto &storage = pass.valueStorageMap.getStorage(wcsvi);
|
||||
auto destAddr = addrMat.recursivelyMaterializeStorage(
|
||||
storage, /*intoPhiOperand=*/false);
|
||||
|
||||
builder.createStoreWeak(wcsvi->getLoc(), wcsvi->getOperand(), destAddr,
|
||||
IsInitialization);
|
||||
}
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user