Skip to content

Commit 32f2402

Browse files
committed
Reapply "[EquivalenceClasses] Replace findValue with contains (NFC)."
This reverts the revert commit 616f447. It includes updates to remaining users in Polly and Clang, to avoid failures when building those projects.
1 parent bdae91b commit 32f2402

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

clang/lib/Analysis/FlowSensitive/SimplifyConstraints.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ projectToLeaders(const llvm::DenseSet<Atom> &Atoms,
6464
// `LeaderIt`.
6565
static llvm::SmallVector<Atom>
6666
atomsInEquivalenceClass(const llvm::EquivalenceClasses<Atom> &EquivalentAtoms,
67-
llvm::EquivalenceClasses<Atom>::iterator LeaderIt) {
67+
const Atom &At) {
6868
llvm::SmallVector<Atom> Result;
69-
for (auto MemberIt = EquivalentAtoms.member_begin(LeaderIt);
69+
for (auto MemberIt = EquivalentAtoms.findLeader(At);
7070
MemberIt != EquivalentAtoms.member_end(); ++MemberIt)
7171
Result.push_back(*MemberIt);
7272
return Result;
@@ -159,19 +159,17 @@ void simplifyConstraints(llvm::SetVector<const Formula *> &Constraints,
159159
if (TrueAtoms.contains(At) || FalseAtoms.contains(At))
160160
continue;
161161
llvm::SmallVector<Atom> Atoms =
162-
atomsInEquivalenceClass(EquivalentAtoms, It);
162+
atomsInEquivalenceClass(EquivalentAtoms, At);
163163
if (Atoms.size() == 1)
164164
continue;
165165
std::sort(Atoms.begin(), Atoms.end());
166166
Info->EquivalentAtoms.push_back(std::move(Atoms));
167167
}
168168
for (Atom At : TrueAtoms)
169-
Info->TrueAtoms.append(atomsInEquivalenceClass(
170-
EquivalentAtoms, EquivalentAtoms.findValue(At)));
169+
Info->TrueAtoms.append(atomsInEquivalenceClass(EquivalentAtoms, At));
171170
std::sort(Info->TrueAtoms.begin(), Info->TrueAtoms.end());
172171
for (Atom At : FalseAtoms)
173-
Info->FalseAtoms.append(atomsInEquivalenceClass(
174-
EquivalentAtoms, EquivalentAtoms.findValue(At)));
172+
Info->FalseAtoms.append(atomsInEquivalenceClass(EquivalentAtoms, At));
175173
std::sort(Info->FalseAtoms.begin(), Info->FalseAtoms.end());
176174
}
177175
}

llvm/include/llvm/ADT/EquivalenceClasses.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,9 @@ class EquivalenceClasses {
179179
return member_iterator(nullptr);
180180
}
181181

182-
/// findValue - Return an iterator to the specified value. If it does not
183-
/// exist, end() is returned.
184-
iterator findValue(const ElemTy &V) const {
185-
return TheMapping.find(V);
182+
/// Returns true if \p V is contained an equivalence class.
183+
bool contains(const ElemTy &V) const {
184+
return TheMapping.find(V) != TheMapping.end();
186185
}
187186

188187
/// getLeaderValue - Return the leader for the specified value that is in the

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ bool AccessAnalysis::canCheckPtrAtRT(
12301230
[this](const Value *Ptr) {
12311231
MemAccessInfo AccessWrite(const_cast<Value *>(Ptr),
12321232
true);
1233-
return DepCands.findValue(AccessWrite) == DepCands.end();
1233+
return !DepCands.contains(AccessWrite);
12341234
})) &&
12351235
"Can only skip updating CanDoRT below, if all entries in AS "
12361236
"are reads or there is at most 1 entry");

polly/lib/Analysis/ScopBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,8 +1856,7 @@ static void joinOperandTree(EquivalenceClasses<Instruction *> &UnionFind,
18561856
continue;
18571857

18581858
// Check if OpInst is in the BB and is a modeled instruction.
1859-
auto OpVal = UnionFind.findValue(OpInst);
1860-
if (OpVal == UnionFind.end())
1859+
if (!UnionFind.contains(OpInst))
18611860
continue;
18621861

18631862
UnionFind.unionSets(Inst, OpInst);

0 commit comments

Comments
 (0)