<div dir="ltr">There's probably no particular benefit to all_defs and all_uses returning the same iterator type - so these could be distinct types with named functors, removing any indirection to the filter function (& reducing the size of the iterator, potentially - since no state would be required if the functor is stateless and encoded in the type)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 2, 2023 at 12:47 AM Nikita Popov 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: Nikita Popov<br>
Date: 2023-06-02T09:47:29+02:00<br>
New Revision: 1efbef4085fbe7098af4bb7013c6295ed3682cdf<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/1efbef4085fbe7098af4bb7013c6295ed3682cdf" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/1efbef4085fbe7098af4bb7013c6295ed3682cdf</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/1efbef4085fbe7098af4bb7013c6295ed3682cdf.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/1efbef4085fbe7098af4bb7013c6295ed3682cdf.diff</a><br>
<br>
LOG: [MI] Don't use std::function for all_uses/all_defs iterators (NFC)<br>
<br>
This mitigates the compile-time regression from D151424. The use<br>
of std::function is not necessary here, as we're passing in a<br>
static function.<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    llvm/include/llvm/CodeGen/MachineInstr.h<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h<br>
index 609aa5466ac3e..fa287becb60fe 100644<br>
--- a/llvm/include/llvm/CodeGen/MachineInstr.h<br>
+++ b/llvm/include/llvm/CodeGen/MachineInstr.h<br>
@@ -710,33 +710,28 @@ class MachineInstr<br>
   }<br>
<br>
   using filtered_mop_iterator =<br>
-      filter_iterator<mop_iterator, std::function<bool(MachineOperand &)>>;<br>
+      filter_iterator<mop_iterator, bool (*)(const MachineOperand &)>;<br>
   using filtered_const_mop_iterator =<br>
-      filter_iterator<const_mop_iterator,<br>
-                      std::function<bool(const MachineOperand &)>>;<br>
+      filter_iterator<const_mop_iterator, bool (*)(const MachineOperand &)>;<br>
<br>
   /// Returns an iterator range over all operands that are (explicit or<br>
   /// implicit) register defs.<br>
   iterator_range<filtered_mop_iterator> all_defs() {<br>
-    return make_filter_range(operands(),<br>
-                             std::function<bool(MachineOperand &)>(opIsRegDef));<br>
+    return make_filter_range(operands(), opIsRegDef);<br>
   }<br>
   /// \copydoc all_defs()<br>
   iterator_range<filtered_const_mop_iterator> all_defs() const {<br>
-    return make_filter_range(<br>
-        operands(), std::function<bool(const MachineOperand &)>(opIsRegDef));<br>
+    return make_filter_range(operands(), opIsRegDef);<br>
   }<br>
<br>
   /// Returns an iterator range over all operands that are (explicit or<br>
   /// implicit) register uses.<br>
   iterator_range<filtered_mop_iterator> all_uses() {<br>
-    return make_filter_range(uses(),<br>
-                             std::function<bool(MachineOperand &)>(opIsRegUse));<br>
+    return make_filter_range(uses(), opIsRegUse);<br>
   }<br>
   /// \copydoc all_uses()<br>
   iterator_range<filtered_const_mop_iterator> all_uses() const {<br>
-    return make_filter_range(<br>
-        uses(), std::function<bool(const MachineOperand &)>(opIsRegUse));<br>
+    return make_filter_range(uses(), opIsRegUse);<br>
   }<br>
<br>
   /// Returns the number of the operand iterator \p I points to.<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>