From patchwork Tue Mar 15 11:25:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 51976 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E513F385843F for ; Tue, 15 Mar 2022 11:25:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E513F385843F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1647343556; bh=TP8UbESWpPAZ3sqRId6++z9hySP3oEmysNHvIzRXo+c=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=D3F313YRRLXx4lEZo6lKqlOPY+e5owSrm2mFniLdNyaspm4dD4m4lmXaOralEiKH/ tEj5h5qZBGQumg8eOr0EoT2qj2efZUFzzqTgXojvCVPkvUaIqYCkNPd50/wvTyQJC4 j3eXuzyUxmcBxqB83culUxH83TQCH9HzMKvDCPd8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 8324C3858D20 for ; Tue, 15 Mar 2022 11:25:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8324C3858D20 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22FAKkEL011149; Tue, 15 Mar 2022 11:25:26 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3etryc16pa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Mar 2022 11:25:25 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22FBFHDo031526; Tue, 15 Mar 2022 11:25:25 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3etryc16nk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Mar 2022 11:25:24 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 22FBDDZo015860; Tue, 15 Mar 2022 11:25:22 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 3erjshpfna-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Mar 2022 11:25:22 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22FBPKDW54591814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Mar 2022 11:25:20 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2851CAE051; Tue, 15 Mar 2022 11:25:20 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 738B6AE04D; Tue, 15 Mar 2022 11:25:18 +0000 (GMT) Received: from [9.197.234.95] (unknown [9.197.234.95]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 15 Mar 2022 11:25:18 +0000 (GMT) Message-ID: <6437c783-4741-5cee-4ac0-d93d4a1cf1db@linux.ibm.com> Date: Tue, 15 Mar 2022 19:25:16 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US To: GCC Patches Subject: [PATCH] rs6000: Fix the check of bif argument number [PR104482] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qidcy0dQdFywMKbGUbYhCy1iacS4DCLw X-Proofpoint-ORIG-GUID: mo0a6WfBlJICjThmIojaG9P0LBiE-xNS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-15_01,2022-03-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 mlxscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203150073 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Cc: Peter Bergner , David Edelsohn , Segher Boessenkool Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, PR104482 is one regression about the handlings on different argument numbers from its prototype of built-in function. Without the patch, the code only catches the case when argument number is more than the one of prototype, but it ignores the possibility that the number of arguments can be more as the PR shows. Bootstrapped and regtested on powerpc64-linux-gnu P8 and powerpc64le-linux-gnu P9 and P10. Is it ok for trunk? BR, Kewen ------ PR target/104482 gcc/ChangeLog: * config/rs6000/rs6000-c.cc (altivec_resolve_overloaded_builtin): Fix the equality check for argument number, and adjust this hunk's location. --- gcc/config/rs6000/rs6000-c.cc | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc index d2e480ad7df..2f344e07a40 100644 --- a/gcc/config/rs6000/rs6000-c.cc +++ b/gcc/config/rs6000/rs6000-c.cc @@ -1747,6 +1747,36 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, vec *arglist = static_cast *> (passed_arglist); unsigned int nargs = vec_safe_length (arglist); + /* If the number of arguments did not match the prototype, return NULL + and the generic code will issue the appropriate error message. Skip + this test for functions where we don't fully describe all the possible + overload signatures in rs6000-overload.def (because they aren't relevant + to the expansion here). If we don't, we get confusing error messages. */ + /* As an example, for vec_splats we have: + +; There are no actual builtins for vec_splats. There is special handling for +; this in altivec_resolve_overloaded_builtin in rs6000-c.cc, where the call +; is replaced by a constructor. The single overload here causes +; __builtin_vec_splats to be registered with the front end so that can happen. +[VEC_SPLATS, vec_splats, __builtin_vec_splats] + vsi __builtin_vec_splats (vsi); + ABS_V4SI SPLATS_FAKERY + + So even though __builtin_vec_splats accepts all vector types, the + infrastructure cheats and just records one prototype. We end up getting + an error message that refers to this specific prototype even when we + are handling a different argument type. That is completely confusing + to the user, so it's best to let these cases be handled individually + in the resolve_vec_splats, etc., helper functions. */ + + if (expected_args != nargs + && !(fcode == RS6000_OVLD_VEC_PROMOTE + || fcode == RS6000_OVLD_VEC_SPLATS + || fcode == RS6000_OVLD_VEC_EXTRACT + || fcode == RS6000_OVLD_VEC_INSERT + || fcode == RS6000_OVLD_VEC_STEP)) + return NULL; + for (n = 0; !VOID_TYPE_P (TREE_VALUE (fnargs)) && n < nargs; fnargs = TREE_CHAIN (fnargs), n++) @@ -1806,36 +1836,6 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, types[n] = type; } - /* If the number of arguments did not match the prototype, return NULL - and the generic code will issue the appropriate error message. Skip - this test for functions where we don't fully describe all the possible - overload signatures in rs6000-overload.def (because they aren't relevant - to the expansion here). If we don't, we get confusing error messages. */ - /* As an example, for vec_splats we have: - -; There are no actual builtins for vec_splats. There is special handling for -; this in altivec_resolve_overloaded_builtin in rs6000-c.cc, where the call -; is replaced by a constructor. The single overload here causes -; __builtin_vec_splats to be registered with the front end so that can happen. -[VEC_SPLATS, vec_splats, __builtin_vec_splats] - vsi __builtin_vec_splats (vsi); - ABS_V4SI SPLATS_FAKERY - - So even though __builtin_vec_splats accepts all vector types, the - infrastructure cheats and just records one prototype. We end up getting - an error message that refers to this specific prototype even when we - are handling a different argument type. That is completely confusing - to the user, so it's best to let these cases be handled individually - in the resolve_vec_splats, etc., helper functions. */ - - if (n != expected_args - && !(fcode == RS6000_OVLD_VEC_PROMOTE - || fcode == RS6000_OVLD_VEC_SPLATS - || fcode == RS6000_OVLD_VEC_EXTRACT - || fcode == RS6000_OVLD_VEC_INSERT - || fcode == RS6000_OVLD_VEC_STEP)) - return NULL; - /* Some overloads require special handling. */ tree returned_expr = NULL; resolution res = unresolved;