On Sat, Aug 1, 2020 at 8:46 PM Roger Sayle <ro...@nextmovesoftware.com> wrote:
>
>
> This patch silences a number of unused parameter warnings whilst
> compiling both generic-match.c and gimple-match.c.  The problem is
> that multiple (polymorphic) functions are generated for generic_simplify
> and gimple_simplify, each handling tree codes with a specific number
> of children.  Currently, there are no simplifications for tree codes
> with four or five children, leading to functions with "empty" bodies
> and unused function arguments.  This patch detects those cases, and
> generates stub functions (with anonymous arguments) to silence these
> warnings.
>
> Previously, genmatch would generate:
>
> static bool
> gimple_simplify (gimple_match_op *res_op, gimple_seq *seq,
>                  tree (*valueize)(tree) ATTRIBUTE_UNUSED,
>                  code_helper code, const tree type, tree _p0, tree _p1, tree
> _p2, tree _p3)
> {
>   switch (code.get_rep())
>     {
>     default:;
>     }
>   return false;
> }
>
> which results in:
>  gimple_simplify (gimple_match_op *res_op, gimple_seq *seq,
>  ^
> gimple-match.c:130408:1: warning: unused parameter 'seq'
> [-Wunused-parameter]
> gimple-match.c:130408:1: warning: unused parameter 'type'
> [-Wunused-parameter]
> gimple-match.c:130408:1: warning: unused parameter '_p0'
> [-Wunused-parameter]
> gimple-match.c:130408:1: warning: unused parameter '_p1'
> [-Wunused-parameter]
> gimple-match.c:130408:1: warning: unused parameter '_p2'
> [-Wunused-parameter]
> gimple-match.c:130408:1: warning: unused parameter '_p3'
> [-Wunused-parameter]
> gimple-match.c:130420:1: warning: unused parameter 'res_op'
> [-Wunused-parameter]
>
> With this patch genmatch now generates:
> static bool
> gimple_simplify (gimple_match_op*, gimple_seq*,
>                  tree (*)(tree), code_helper,
>                  const tree, tree, tree, tree, tree)
> {
>   return false;
> }
>
> which has the same signature but no compilation warnings.
>
> This patch has been tested on x86_64-pc-linux-gnu with a full
> "make bootstrap" and "make -k check" with no new failures.
> Ok for mainline?

OK.

Thanks,
Richard.

>
> 2020-08-01  Roger Sayle  <ro...@nextmovesoftware.com>
>
>         * gcc/genmatch.c (decision_tree::gen): Emit stub functions for
>         tree code operand counts that have no simplifications.
>         (main): Correct comment typo.
>
> Thanks in advance,
> Roger
> --
> Roger Sayle
> NextMove Software
> Cambridge, UK
>

Reply via email to