Skip to content

Commit 6346bf5

Browse files
committed
Rename areUsesWithinTransitiveScope to ...ExtendedScope
Start using consistent terminolfy in ownership utils. A transitive use set follows transitive uses within an ownership lifetime. It does not rely on complete inner scopes. An extended use set is not necessarilly transitive but does look across lifetime-ending uses: copies of owned values and/or reborrows of guaranteed values. Whether lifetime extension refers to copies or reborrow is context dependent.
1 parent 2244875 commit 6346bf5

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ struct BorrowedValue {
582582
///
583583
/// \p deadEndBlocks is optional during transition. It will be completely
584584
/// removed in an upcoming commit.
585-
bool areUsesWithinTransitiveScope(ArrayRef<Operand *> uses,
586-
DeadEndBlocks *deadEndBlocks) const;
585+
bool areUsesWithinExtendedScope(ArrayRef<Operand *> uses,
586+
DeadEndBlocks *deadEndBlocks) const;
587587

588588
/// Given a local borrow scope introducer, visit all non-forwarding consuming
589589
/// users. This means that this looks through guaranteed block arguments. \p

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ computeTransitiveLiveness(MultiDefPrunedLiveness &liveness) const {
769769
});
770770
}
771771

772-
bool BorrowedValue::areUsesWithinTransitiveScope(
772+
bool BorrowedValue::areUsesWithinExtendedScope(
773773
ArrayRef<Operand *> uses, DeadEndBlocks *deadEndBlocks) const {
774774
// First make sure that we actually have a local scope. If we have a non-local
775775
// scope, then we have something (like a SILFunctionArgument) where a larger
@@ -1087,7 +1087,7 @@ bool AddressOwnership::areUsesWithinLifetime(
10871087
SILValue root = base.getOwnershipReferenceRoot();
10881088
BorrowedValue borrow(root);
10891089
if (borrow)
1090-
return borrow.areUsesWithinTransitiveScope(uses, &deadEndBlocks);
1090+
return borrow.areUsesWithinExtendedTransitiveScope(uses, &deadEndBlocks);
10911091

10921092
// --- A reference with no borrow scope! Currently happens for project_box.
10931093

lib/SILOptimizer/SemanticARC/CopyValueOpts.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
155155
// TODO: There may be some way of sinking this into the loop below.
156156
//
157157
// FIXME: The haveAnyLocalScopes and destroy.empty() checks are relics of
158-
// attempts to handle dead end blocks during areUsesWithinTransitiveScope. If
158+
// attempts to handle dead end blocks during areUsesWithinExtendedScope. If
159159
// we don't use dead end blocks at all, they should not be relevant.
160160
bool haveAnyLocalScopes =
161161
llvm::any_of(borrowScopeIntroducers, [](BorrowedValue borrowScope) {
@@ -182,13 +182,13 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
182182
// need to insert an end_borrow since all of our borrow introducers are
183183
// non-local scopes.
184184
//
185-
// The call to areUsesWithinTransitiveScope cannot consider dead-end blocks. A
185+
// The call to areUsesWithinExtendedScope cannot consider dead-end blocks. A
186186
// local borrow scope requires all its inner uses to be inside the borrow
187187
// scope, regardless of whether the end of the scope is inside a dead-end
188188
// block.
189189
{
190190
if (llvm::any_of(borrowScopeIntroducers, [&](BorrowedValue borrowScope) {
191-
return !borrowScope.areUsesWithinTransitiveScope(
191+
return !borrowScope.areUsesWithinExtendedScope(
192192
lr.getAllConsumingUses(), nullptr);
193193
})) {
194194
return false;
@@ -217,7 +217,7 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(
217217
}
218218

219219
if (llvm::any_of(borrowScopeIntroducers, [&](BorrowedValue borrowScope) {
220-
return !borrowScope.areUsesWithinTransitiveScope(
220+
return !borrowScope.areUsesWithinExtendedScope(
221221
phiArgLR.getAllConsumingUses(), nullptr);
222222
})) {
223223
return false;

0 commit comments

Comments
 (0)