Skip to content

Commit 19cff2e

Browse files
committed
Add AccessedStorage::isGuaranteedForFunction
to quickly bypass all liveness checking in many cases.
1 parent b750c37 commit 19cff2e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

include/swift/SIL/MemAccessUtils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,10 @@ class AccessedStorage {
591591
return getKind() == Class;
592592
}
593593

594+
/// Return true if this storage is valid for all uses in a function without
595+
/// checking its lifetime.
596+
bool isGuaranteedForFunction() const;
597+
594598
/// Returns the ValueDecl for the underlying storage, if it can be
595599
/// determined. Otherwise returns null.
596600
///

lib/SIL/Utils/MemAccessUtils.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,17 @@ void AccessedStorage::visitRoots(
570570
}
571571
}
572572

573+
bool AccessedStorage::isGuaranteedForFunction() const {
574+
if (getKind() == AccessedStorage::Argument) {
575+
return getArgument()->getArgumentConvention().isGuaranteedConvention();
576+
}
577+
if (isObjectAccess()) {
578+
return getRoot().getOwnershipKind() == OwnershipKind::Guaranteed
579+
&& isa<SILFunctionArgument>(getRoot());
580+
}
581+
return false;
582+
}
583+
573584
// Set 'isLet' to true if this storage can be determined to be a 'let' variable.
574585
//
575586
// \p base must be the access base for this storage, as passed to the

0 commit comments

Comments
 (0)