From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 61D1E3858C83 for ; Mon, 29 Aug 2022 06:26:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61D1E3858C83 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27T5mlq1030572; Mon, 29 Aug 2022 06:26:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=rm3Boi6n7YaVmrrlxoNA1KSNl5lDDa1KmJAjc62X3d0=; b=cl0ZnQbcbp59pP5nQs0XGhUBOGejqxIvOrNsc1P9ZGpNKr4FC6DyqBxLlpl9oWc9+U27 XazBzcVLNxxgRxnYeCAFeiHlBqJblR2y2tcNMbpL/s/rFVI4c+mf7PDT99Zkwm4AnYO0 U/2O0fXCG2unTgUxoY9ZCICBK6dflArLkYx8iiEaNYNPIy9+gFrthjREzeRrB2rTzXji vMZ9a+3Fv2z5694y7q7EZRYA8u6WGqVW68jnXHAwAZY8qvtYTxRv4d+GP3KHWPCRp4K1 HOdjwhN1FULmZtPwF99y7mpqh6/65B7b8CIKrLcjkg1oiGZp/xsYDc4aUjq/EpV0hUDA Iw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3j8qmv8v0x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Aug 2022 06:26:23 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27T5u2FH022336; Mon, 29 Aug 2022 06:26:23 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3j8qmv8v04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Aug 2022 06:26:23 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27T6LOHG001679; Mon, 29 Aug 2022 06:26:20 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 3j7aw8swba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Aug 2022 06:26:20 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27T6QIoU34406868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Aug 2022 06:26:18 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D2194C046; Mon, 29 Aug 2022 06:26:18 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD63E4C040; Mon, 29 Aug 2022 06:26:16 +0000 (GMT) Received: from [9.197.231.116] (unknown [9.197.231.116]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 29 Aug 2022 06:26:16 +0000 (GMT) Message-ID: Date: Mon, 29 Aug 2022 14:26:15 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: PING^5 [PATCH] rs6000: Handle unresolved overloaded builtin [PR105485] Content-Language: en-US To: GCC Patches Cc: Peter Bergner , David Edelsohn , Segher Boessenkool References: <340fcec1-eb5e-e0f6-e8d1-ea819d4fd165@linux.ibm.com> <79282dcf-cca9-7ff3-aa25-e0d380e3b185@linux.ibm.com> From: "Kewen.Lin" In-Reply-To: Content-Type: text/plain; charset=UTF-8 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: QUNCyX4G4-SDAoh27cnNPAku-UxCEyqn X-Proofpoint-GUID: 1X_cF_vSMkQIsPd_Tav-6uG2hNcD1v05 Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-29_03,2022-08-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 suspectscore=0 impostorscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208290029 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, Gentle ping https://gcc.gnu.org/pipermail/gcc-patches/2022-May/594699.html I think this is a reasonable fix, the behavior is consistent with what we have in the previous built-in framework, I'm going to push this a week later if no objections. :) BR, Kewen >>> >>>> on 2022/5/13 13:29, Kewen.Lin via Gcc-patches wrote: >>>>> Hi, >>>>> >>>>> PR105485 exposes that new builtin function framework doesn't handle >>>>> unresolved overloaded builtin function well. With new builtin >>>>> function support, we don't have builtin info for any overloaded >>>>> rs6000_gen_builtins enum, since they are expected to be resolved to >>>>> one specific instance. So when function rs6000_gimple_fold_builtin >>>>> faces one unresolved overloaded builtin, the access for builtin info >>>>> becomes out of bound and gets ICE then. >>>>> >>>>> We should not try to fold one unresolved overloaded builtin there >>>>> and as the previous support we should emit one error message during >>>>> expansion phase like "unresolved overload for builtin ...". >>>>> >>>>> Bootstrapped and regtested on powerpc64-linux-gnu P8 and >>>>> powerpc64le-linux-gnu P9 and P10. >>>>> >>>>> Is it ok for trunk? >>>>> >>>>> BR, >>>>> Kewen >>>>> ----- >>>>> PR target/105485 >>>>> >>>>> gcc/ChangeLog: >>>>> >>>>> * config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_builtin): Add >>>>> the handling for unresolved overloaded builtin function. >>>>> (rs6000_expand_builtin): Likewise. >>>>> >>>>> gcc/testsuite/ChangeLog: >>>>> >>>>> * g++.target/powerpc/pr105485.C: New test. >>>>> >>>>> --- >>>>> gcc/config/rs6000/rs6000-builtin.cc | 13 +++++++++++++ >>>>> gcc/testsuite/g++.target/powerpc/pr105485.C | 9 +++++++++ >>>>> 2 files changed, 22 insertions(+) >>>>> create mode 100644 gcc/testsuite/g++.target/powerpc/pr105485.C >>>>> >>>>> diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc >>>>> index e925ba9fad9..e102305c90c 100644 >>>>> --- a/gcc/config/rs6000/rs6000-builtin.cc >>>>> +++ b/gcc/config/rs6000/rs6000-builtin.cc >>>>> @@ -1294,6 +1294,11 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) >>>>> enum tree_code bcode; >>>>> gimple *g; >>>>> >>>>> + /* For an unresolved overloaded builtin, return early here since there >>>>> + is no builtin info for it and we are unable to fold it. */ >>>>> + if (fn_code > RS6000_OVLD_NONE) >>>>> + return false; >>>>> + >>>>> size_t uns_fncode = (size_t) fn_code; >>>>> enum insn_code icode = rs6000_builtin_info[uns_fncode].icode; >>>>> const char *fn_name1 = rs6000_builtin_info[uns_fncode].bifname; >>>>> @@ -3295,6 +3300,14 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* subtarget */, >>>>> tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); >>>>> enum rs6000_gen_builtins fcode >>>>> = (enum rs6000_gen_builtins) DECL_MD_FUNCTION_CODE (fndecl); >>>>> + >>>>> + /* Emit error message if it's an unresolved overloaded builtin. */ >>>>> + if (fcode > RS6000_OVLD_NONE) >>>>> + { >>>>> + error ("unresolved overload for builtin %qF", fndecl); >>>>> + return const0_rtx; >>>>> + } >>>>> + >>>>> size_t uns_fcode = (size_t)fcode; >>>>> enum insn_code icode = rs6000_builtin_info[uns_fcode].icode; >>>>> >>>>> diff --git a/gcc/testsuite/g++.target/powerpc/pr105485.C b/gcc/testsuite/g++.target/powerpc/pr105485.C >>>>> new file mode 100644 >>>>> index 00000000000..a3b8290df8c >>>>> --- /dev/null >>>>> +++ b/gcc/testsuite/g++.target/powerpc/pr105485.C >>>>> @@ -0,0 +1,9 @@ >>>>> +/* It's to verify no ICE here, ignore error/warning messages since >>>>> + they are not test points here. */ >>>>> +/* { dg-excess-errors "pr105485" } */ >>>>> + >>>>> +template void __builtin_vec_vslv(); >>>>> +typedef __attribute__((altivec(vector__))) char T; >>>>> +T b (T c, T d) { >>>>> + return __builtin_vec_vslv(c, d); >>>>> +}