Skip to content

Commit

Permalink
Add AccessedStorage::isGuaranteedForFunction
Browse files Browse the repository at this point in the history
to quickly bypass all liveness checking in many cases.
  • Loading branch information
atrick committed Sep 21, 2021
1 parent b750c37 commit 19cff2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/swift/SIL/MemAccessUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@ class AccessedStorage {
return getKind() == Class;
}

/// Return true if this storage is valid for all uses in a function without
/// checking its lifetime.
bool isGuaranteedForFunction() const;

/// Returns the ValueDecl for the underlying storage, if it can be
/// determined. Otherwise returns null.
///
Expand Down
11 changes: 11 additions & 0 deletions lib/SIL/Utils/MemAccessUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,17 @@ void AccessedStorage::visitRoots(
}
}

bool AccessedStorage::isGuaranteedForFunction() const {
if (getKind() == AccessedStorage::Argument) {
return getArgument()->getArgumentConvention().isGuaranteedConvention();
}
if (isObjectAccess()) {
return getRoot().getOwnershipKind() == OwnershipKind::Guaranteed
&& isa<SILFunctionArgument>(getRoot());
}
return false;
}

// Set 'isLet' to true if this storage can be determined to be a 'let' variable.
//
// \p base must be the access base for this storage, as passed to the
Expand Down

0 comments on commit 19cff2e

Please sign in to comment.