Skip to content

Commit c1dce5c

Browse files
committed
[AliasAnalysis] Document and roll the alias() family of methods. NFC.
Document alias() and roll the mayAlias() family of methods into a single function.
1 parent f6d6f31 commit c1dce5c

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

include/swift/SILAnalysis/AliasAnalysis.h

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,33 +84,26 @@ class AliasAnalysis : public SILAnalysis {
8484

8585
SideEffectAnalysis *getSideEffectAnalysis() const { return SEA; }
8686

87-
/// Perform an alias query to see if V1, V2 refer to the same values.
88-
AliasResult alias(SILValue V1, SILValue V2, SILType TBAAType1 = SILType(),
87+
/// Compute the alias properties of the pointers \p V1 and \p V2.
88+
/// The optional arguments \pTBAAType1 and \p TBAAType2 specify the exact
89+
/// types that the pointers access.
90+
AliasResult alias(SILValue V1, SILValue V2,
91+
SILType TBAAType1 = SILType(),
8992
SILType TBAAType2 = SILType());
9093

91-
/// Convenience method that returns true if V1 and V2 must alias.
92-
bool isMustAlias(SILValue V1, SILValue V2, SILType TBAAType1 = SILType(),
93-
SILType TBAAType2 = SILType()) {
94-
return alias(V1, V2, TBAAType1, TBAAType2) == AliasResult::MustAlias;
94+
#define ALIAS_PROPERTY_CONVENIENCE_METHOD(KIND) \
95+
bool is##KIND(SILValue V1, SILValue V2, \
96+
SILType TBAAType1 = SILType(), \
97+
SILType TBAAType2 = SILType()) { \
98+
return alias(V1, V2, TBAAType1, TBAAType2) == AliasResult::KIND; \
9599
}
96100

97-
/// Convenience method that returns true if V1 and V2 partially alias.
98-
bool isPartialAlias(SILValue V1, SILValue V2, SILType TBAAType1 = SILType(),
99-
SILType TBAAType2 = SILType()) {
100-
return alias(V1, V2, TBAAType1, TBAAType2) == AliasResult::PartialAlias;
101-
}
101+
ALIAS_PROPERTY_CONVENIENCE_METHOD(MustAlias)
102+
ALIAS_PROPERTY_CONVENIENCE_METHOD(PartialAlias)
103+
ALIAS_PROPERTY_CONVENIENCE_METHOD(NoAlias)
104+
ALIAS_PROPERTY_CONVENIENCE_METHOD(MayAlias)
102105

103-
/// Convenience method that returns true if V1, V2 can not alias.
104-
bool isNoAlias(SILValue V1, SILValue V2, SILType TBAAType1 = SILType(),
105-
SILType TBAAType2 = SILType()) {
106-
return alias(V1, V2, TBAAType1, TBAAType2) == AliasResult::NoAlias;
107-
}
108-
109-
/// Convenience method that returns true if V1, V2 may alias.
110-
bool isMayAlias(SILValue V1, SILValue V2, SILType TBAAType1 = SILType(),
111-
SILType TBAAType2 = SILType()) {
112-
return alias(V1, V2, TBAAType1, TBAAType2) == AliasResult::MayAlias;
113-
}
106+
#undef ALIAS_PROPERTY_CONVENIENCE_METHOD
114107

115108
/// Use the alias analysis to determine the memory behavior of Inst with
116109
/// respect to V.

0 commit comments

Comments
 (0)