Skip to content

Commit 5f82129

Browse files
committed
Sufficient to check any pair for MustAlias; assumed to be transitive
1 parent efc787b commit 5f82129

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

llvm/lib/Analysis/AliasSetTracker.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,15 @@ void AliasSet::mergeSetIn(AliasSet &AS, AliasSetTracker &AST,
5252
Alias |= AS.Alias;
5353

5454
if (Alias == SetMustAlias) {
55-
// Check that these two merged sets really are must aliases.
56-
// If the pointers are not a must-alias pair, this set becomes a may alias.
57-
[&] {
58-
for (const MemoryLocation &MemLoc : *this)
59-
for (const MemoryLocation &ASMemLoc : AS)
60-
if (!BatchAA.isMustAlias(MemLoc, ASMemLoc)) {
61-
Alias = SetMayAlias;
62-
return;
63-
}
64-
}();
55+
// Check that these two merged sets really are must aliases. If we cannot
56+
// find a must-alias pair between them, this set becomes a may alias.
57+
if (!llvm::any_of(MemoryLocs, [&](const MemoryLocation &MemLoc) {
58+
return llvm::any_of(AS.MemoryLocs,
59+
[&](const MemoryLocation &ASMemLoc) {
60+
return BatchAA.isMustAlias(MemLoc, ASMemLoc);
61+
});
62+
}))
63+
Alias = SetMayAlias;
6564
}
6665

6766
// Merge the list of constituent pointers...
@@ -113,13 +112,14 @@ void AliasSet::removeFromTracker(AliasSetTracker &AST) {
113112

114113
void AliasSet::addPointer(AliasSetTracker &AST, const MemoryLocation &MemLoc,
115114
bool KnownMustAlias) {
116-
// Check to see if we have to downgrade to _may_ alias.
117-
if (isMustAlias() && !KnownMustAlias)
118-
for (const MemoryLocation &ASMemLoc : MemoryLocs)
119-
if (!AST.getAliasAnalysis().isMustAlias(ASMemLoc, MemLoc)) {
120-
Alias = SetMayAlias;
121-
break;
122-
}
115+
if (isMustAlias() && !KnownMustAlias) {
116+
// If we cannot find a must-alias with any of the existing MemoryLocs, we
117+
// must downgrade to may-alias.
118+
if (!llvm::any_of(MemoryLocs, [&](const MemoryLocation &ASMemLoc) {
119+
return AST.getAliasAnalysis().isMustAlias(MemLoc, ASMemLoc);
120+
}))
121+
Alias = SetMayAlias;
122+
}
123123

124124
// Add it to the end of the list...
125125
MemoryLocs.push_back(MemLoc);

0 commit comments

Comments
 (0)