Skip to content

Commit 5f11629

Browse files
committed
Add AccessBase::getOwnershipReferenceRoot.
Trivial convenience helper for OSSA utilities, where it's very common to need the reference whose ownership lifetime or scope covers the current access.
1 parent af4c2f4 commit 5f11629

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/swift/SIL/MemAccessUtils.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,20 @@ class AccessBase : public AccessRepresentation {
576576
/// Precondition: isReference() is true.
577577
SILValue getReference() const;
578578

579+
/// Return the OSSA root of the reference being accessed.
580+
///
581+
/// Precondition: isReference() is true.
582+
SILValue getOwnershipReferenceRoot() const {
583+
return findOwnershipReferenceRoot(getReference());
584+
}
585+
586+
/// Return the storage root of the reference being accessed.
587+
///
588+
/// Precondition: isReference() is true.
589+
SILValue getStorageReferenceRoot() const {
590+
return findReferenceRoot(getReference());
591+
}
592+
579593
/// Return the global variable being accessed.
580594
///
581595
/// Precondition: getKind() == Global

0 commit comments

Comments
 (0)