[llvm] 1efbef4 - [MI] Don't use std::function for all_uses/all_defs iterators (NFC)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 12:55:37 PDT 2023
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)
On Fri, Jun 2, 2023 at 12:47 AM Nikita Popov via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
>
> Author: Nikita Popov
> Date: 2023-06-02T09:47:29+02:00
> New Revision: 1efbef4085fbe7098af4bb7013c6295ed3682cdf
>
> URL:
> https://github.com/llvm/llvm-project/commit/1efbef4085fbe7098af4bb7013c6295ed3682cdf
> DIFF:
> https://github.com/llvm/llvm-project/commit/1efbef4085fbe7098af4bb7013c6295ed3682cdf.diff
>
> LOG: [MI] Don't use std::function for all_uses/all_defs iterators (NFC)
>
> This mitigates the compile-time regression from D151424. The use
> of std::function is not necessary here, as we're passing in a
> static function.
>
> Added:
>
>
> Modified:
> llvm/include/llvm/CodeGen/MachineInstr.h
>
> Removed:
>
>
>
>
> ################################################################################
> diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h
> b/llvm/include/llvm/CodeGen/MachineInstr.h
> index 609aa5466ac3e..fa287becb60fe 100644
> --- a/llvm/include/llvm/CodeGen/MachineInstr.h
> +++ b/llvm/include/llvm/CodeGen/MachineInstr.h
> @@ -710,33 +710,28 @@ class MachineInstr
> }
>
> using filtered_mop_iterator =
> - filter_iterator<mop_iterator, std::function<bool(MachineOperand
> &)>>;
> + filter_iterator<mop_iterator, bool (*)(const MachineOperand &)>;
> using filtered_const_mop_iterator =
> - filter_iterator<const_mop_iterator,
> - std::function<bool(const MachineOperand &)>>;
> + filter_iterator<const_mop_iterator, bool (*)(const MachineOperand
> &)>;
>
> /// Returns an iterator range over all operands that are (explicit or
> /// implicit) register defs.
> iterator_range<filtered_mop_iterator> all_defs() {
> - return make_filter_range(operands(),
> - std::function<bool(MachineOperand
> &)>(opIsRegDef));
> + return make_filter_range(operands(), opIsRegDef);
> }
> /// \copydoc all_defs()
> iterator_range<filtered_const_mop_iterator> all_defs() const {
> - return make_filter_range(
> - operands(), std::function<bool(const MachineOperand
> &)>(opIsRegDef));
> + return make_filter_range(operands(), opIsRegDef);
> }
>
> /// Returns an iterator range over all operands that are (explicit or
> /// implicit) register uses.
> iterator_range<filtered_mop_iterator> all_uses() {
> - return make_filter_range(uses(),
> - std::function<bool(MachineOperand
> &)>(opIsRegUse));
> + return make_filter_range(uses(), opIsRegUse);
> }
> /// \copydoc all_uses()
> iterator_range<filtered_const_mop_iterator> all_uses() const {
> - return make_filter_range(
> - uses(), std::function<bool(const MachineOperand &)>(opIsRegUse));
> + return make_filter_range(uses(), opIsRegUse);
> }
>
> /// Returns the number of the operand iterator \p I points to.
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230605/d702f35d/attachment.html>
More information about the llvm-commits
mailing list