<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 14, 2020 at 7:36 PM Kang Zhang via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Kang Zhang<br>
Date: 2020-05-15T02:35:33Z<br>
New Revision: aedb6615a8d08d7dfeba17bf22ff4c6fd104cadc<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/aedb6615a8d08d7dfeba17bf22ff4c6fd104cadc" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/aedb6615a8d08d7dfeba17bf22ff4c6fd104cadc</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/aedb6615a8d08d7dfeba17bf22ff4c6fd104cadc.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/aedb6615a8d08d7dfeba17bf22ff4c6fd104cadc.diff</a><br>
<br>
LOG: [MachineVerifier] Use the for_range loop to instead llvm::any_of<br>
<br>
Summary:<br>
In the patch D78849, it uses llvm::any_of to instead of for loop to<br>
simplify the function addRequired().<br>
It's obvious that above code is not a NFC conversion. Because any_of<br>
will return if any addRequired(Reg) is true immediately, but we want<br>
every element to call addRequired(Reg).<br>
<br>
This patch uses for_range loop to fix above any_of bug.<br>
<br>
Reviewed By: MaskRay, nickdesaulniers<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D79872" rel="noreferrer" target="_blank">https://reviews.llvm.org/D79872</a><br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    llvm/lib/CodeGen/MachineVerifier.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp<br>
index 5733798fdc9c..f626c1291607 100644<br>
--- a/llvm/lib/CodeGen/MachineVerifier.cpp<br>
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp<br>
@@ -168,14 +168,18 @@ namespace {<br>
<br>
       // Same for a full set.<br>
       bool addRequired(const RegSet &RS) {<br>
-        return llvm::any_of(<br>
-            RS, [this](unsigned Reg) { return this->addRequired(Reg); });<br>
+        bool Changed = false;<br>
+        for (unsigned Reg : RS)<br>
+          Changed |= addRequired(Reg);<br>
+        return Changed;<br>
       }<br>
<br>
       // Same for a full map.<br>
       bool addRequired(const RegMap &RM) {<br>
-        return llvm::any_of(<br>
-            RM, [this](const auto &P) { return this->addRequired(P.first); });<br>
+        bool Changed = false;<br>
+        for (const auto &I : RM)<br>
+          Changed |= addRequired(I.first);<br>
+        return Changed;<br></blockquote><div><br>FWIW, I'd generally encouraged capturing by "[&]" for any locally-scoped/non-escaping lambdas (especially those used wholely within the same statement they're defined in) - like normal scopes (for/if/etc) it's quite reasonable/readable for a lambda scope to have access to any/all enclosing variables without having to explicitly enumerate them.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
       }<br>
<br>
       // Live-out registers are either in regsLiveOut or vregsPassed.<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>