Skip to content

Commit 1264e6d

Browse files
committed
[NFC] AddressLowering: Promote copy-store check.
Move a cheap check that the one user is a store over the expensive check done when the value copied has guaranteed ownership.
1 parent 8d17dc4 commit 1264e6d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ static bool isStoreCopy(SILValue value) {
347347
if (!copyInst->hasOneUse())
348348
return false;
349349

350+
auto *user = value->getSingleUse()->getUser();
351+
auto *storeInst = dyn_cast<StoreInst>(user);
352+
if (!storeInst)
353+
return false;
354+
350355
auto source = copyInst->getOperand();
351356
if (source->getOwnershipKind() == OwnershipKind::Guaranteed) {
352357
// [in_guaranteed_begin_apply_results] If any root of the source is a
@@ -367,8 +372,7 @@ static bool isStoreCopy(SILValue value) {
367372
}
368373
}
369374

370-
auto *user = value->getSingleUse()->getUser();
371-
return isa<StoreInst>(user);
375+
return true;
372376
}
373377

374378
void ValueStorageMap::insertValue(SILValue value, SILValue storageAddress) {

0 commit comments

Comments
 (0)