mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
OSSA: Rewrite address cloning code to fix issues.
Generalize the AccessUseDefChainCloner in MemAccessUtils. It was always meant to work this way, just needed a client. Add a new API AccessUseDefChainCloner::canCloneUseDefChain(). Add a bailout for begin_borrow and mark_dependence. Those projections may appear on an access path, but they can't be individually cloned without compensating. Delete InteriorPointerAddressRebaseUseDefChainCloner. Add a check in OwnershipRAUWHelper for canCloneUseDefChain. Add test cases for begin_borrow and mark_dependence.
This commit is contained in:
@@ -1340,11 +1340,21 @@ hoistLoadsAndStores(AccessPath accessPath, SILLoop *loop) {
|
||||
}
|
||||
}
|
||||
assert(storeAddr && "hoistLoadsAndStores requires a store in the loop");
|
||||
SILValue initialAddr = cloneUseDefChain(
|
||||
storeAddr, preheader->getTerminator(), [&](SILValue srcAddr) {
|
||||
// Clone projections until the address dominates preheader.
|
||||
return !DomTree->dominates(srcAddr->getParentBlock(), preheader);
|
||||
});
|
||||
auto checkBase = [&](SILValue srcAddr) {
|
||||
// Clone projections until the address dominates preheader.
|
||||
if (DomTree->dominates(srcAddr->getParentBlock(), preheader))
|
||||
return srcAddr;
|
||||
|
||||
// return an invalid SILValue to continue cloning.
|
||||
return SILValue();
|
||||
};
|
||||
SILValue initialAddr =
|
||||
cloneUseDefChain(storeAddr, preheader->getTerminator(), checkBase);
|
||||
// cloneUseDefChain may currently fail if a begin_borrow or mark_dependence is
|
||||
// in the chain.
|
||||
if (!initialAddr)
|
||||
return;
|
||||
|
||||
LoadInst *initialLoad =
|
||||
B.createLoad(preheader->getTerminator()->getLoc(), initialAddr,
|
||||
LoadOwnershipQualifier::Unqualified);
|
||||
|
||||
Reference in New Issue
Block a user