From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 1255A3850421; Thu, 6 Aug 2020 06:39:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1255A3850421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1596695982; bh=ErxNBc/b+hv8eEjh/pikIIUXeAukHH8IOeqv/TOZ41Q=; h=From:To:Subject:Date:From; b=JflsyGPQE25n04utF2jD98ODDEXFHg1/aMC+fHHLNUmv6n9So96S/RFvKeLBYAWoG hWZcIRuyrkqvHIRx9DQPS7Kjpsji7kD6beQBwrH5IO5Ps2OHpoiIIOFo+/mVLbcf37 o0+Yx3xPwENqTXx8yYiy5IyK8nlnoG4mMlEjs5ps= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] genmatch: Avoid unused parameter warnings in generated code. X-Act-Checkin: gcc X-Git-Author: Roger Sayle X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: d2ae6d5c053315c94143103eeae1d3cba005ad9d X-Git-Newrev: ef59e1fb372c91c882784392b98c44a8550ff455 Message-Id: <20200806063942.1255A3850421@sourceware.org> Date: Thu, 6 Aug 2020 06:39:42 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Aug 2020 06:39:42 -0000 https://gcc.gnu.org/g:ef59e1fb372c91c882784392b98c44a8550ff455 commit ef59e1fb372c91c882784392b98c44a8550ff455 Author: Roger Sayle Date: Mon Aug 3 13:10:45 2020 +0100 genmatch: Avoid unused parameter warnings in generated code. 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. 2020-08-03 Roger Sayle gcc/ChangeLog * genmatch.c (decision_tree::gen): Emit stub functions for tree code operand counts that have no simplifications. (main): Correct comment typo. Diff: --- gcc/genmatch.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/gcc/genmatch.c b/gcc/genmatch.c index 109dce2d469..4e13bc51579 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -3803,6 +3803,8 @@ decision_tree::gen (FILE *f, bool gimple) for (unsigned n = 1; n <= 5; ++n) { + bool has_kids_p = false; + /* First generate split-out functions. */ for (unsigned j = 0; j < root->kids.length (); j++) { @@ -3841,6 +3843,32 @@ decision_tree::gen (FILE *f, bool gimple) else fprintf (f, " return NULL_TREE;\n"); fprintf (f, "}\n"); + has_kids_p = true; + } + + /* If this main entry has no children, avoid generating code + with compiler warnings, by generating a simple stub. */ + if (! has_kids_p) + { + if (gimple) + fprintf (f, "\nstatic bool\n" + "gimple_simplify (gimple_match_op*, gimple_seq*,\n" + " tree (*)(tree), code_helper,\n" + " const tree"); + else + fprintf (f, "\ntree\n" + "generic_simplify (location_t, enum tree_code,\n" + " const tree"); + for (unsigned i = 0; i < n; ++i) + fprintf (f, ", tree"); + fprintf (f, ")\n"); + fprintf (f, "{\n"); + if (gimple) + fprintf (f, " return false;\n"); + else + fprintf (f, " return NULL_TREE;\n"); + fprintf (f, "}\n"); + continue; } /* Then generate the main entry with the outermost switch and @@ -5079,7 +5107,7 @@ round_alloc_size (size_t s) } -/* The genmatch generator progam. It reads from a pattern description +/* The genmatch generator program. It reads from a pattern description and outputs GIMPLE or GENERIC IL matching and simplification routines. */ int