Skip to content

Commit aedb661

Browse files
committed
[MachineVerifier] Use the for_range loop to instead llvm::any_of
Summary: In the patch D78849, it uses llvm::any_of to instead of for loop to simplify the function addRequired(). It's obvious that above code is not a NFC conversion. Because any_of will return if any addRequired(Reg) is true immediately, but we want every element to call addRequired(Reg). This patch uses for_range loop to fix above any_of bug. Reviewed By: MaskRay, nickdesaulniers Differential Revision: https://reviews.llvm.org/D79872
1 parent dad2e92 commit aedb661

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,18 @@ namespace {
168168

169169
// Same for a full set.
170170
bool addRequired(const RegSet &RS) {
171-
return llvm::any_of(
172-
RS, [this](unsigned Reg) { return this->addRequired(Reg); });
171+
bool Changed = false;
172+
for (unsigned Reg : RS)
173+
Changed |= addRequired(Reg);
174+
return Changed;
173175
}
174176

175177
// Same for a full map.
176178
bool addRequired(const RegMap &RM) {
177-
return llvm::any_of(
178-
RM, [this](const auto &P) { return this->addRequired(P.first); });
179+
bool Changed = false;
180+
for (const auto &I : RM)
181+
Changed |= addRequired(I.first);
182+
return Changed;
179183
}
180184

181185
// Live-out registers are either in regsLiveOut or vregsPassed.

0 commit comments

Comments
 (0)