Skip to content

Commit 92a1816

Browse files
committed
Fix ValueTracking isUniquelyIdentified to use AccessedStorage.
To clarify and unify logic, improve precision, and behave consistently with other code that does the same thing.
1 parent 7554a6a commit 92a1816

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

include/swift/SILOptimizer/Analysis/ValueTracking.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,21 @@ bool pointsToLocalObject(SILValue V);
5454
/// - an address projection based on an exclusive argument with no levels of
5555
/// indirection (e.g. ref_element_addr, project_box, etc.).
5656
inline bool isUniquelyIdentified(SILValue V) {
57-
return pointsToLocalObject(V)
58-
|| (V->getType().isAddress()
59-
&& isExclusiveArgument(getAccessedAddress(V)));
57+
SILValue objectRef = V;
58+
if (V->getType().isAddress()) {
59+
auto storage = findAccessedStorage(V);
60+
if (!storage)
61+
return false;
62+
63+
if (storage.isUniquelyIdentifiedAfterEnforcement())
64+
return true;
65+
66+
if (!storage.isObjectAccess())
67+
return false;
68+
69+
objectRef = storage.getObject();
70+
}
71+
return pointsToLocalObject(objectRef);
6072
}
6173

6274
enum class IsZeroKind {

0 commit comments

Comments
 (0)