From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 022BF3858D1E; Tue, 14 May 2024 03:15:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 022BF3858D1E 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 022BF3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715656561; cv=none; b=MNRhpYoxQvCKuwChCa137pJ4Xb/eIuOS7fcsfsM66Fit1xB7lxEnWKg1nGRP0f9WMizDe/UOLc7JpvQJ+pxuEZ4nAAf+nsQ7pdgkc16ocjidWQ0xBfvgTXc/GVpEUtT4SLbX6HXy52vDipKj9m+TEOl1RWAYhPc2aMgkUZlKgHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715656561; c=relaxed/simple; bh=dXvM2j6PxBzrjqtYmyK4+XT2eQTkow2bCZ5EuLCQRYs=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=kbgH2LueJt70/GZpViRcBWMaHrH8IAIO8G9DXaSscwe+Js+j1tpT75O2VeHaU4geEjvmNGhmDHVJrzldkbRWiPvZCRJzAkP3ShGuy8ySxVAXFm+WRaAFHXU9Y9TnpysIjc0LKKLGYUEtTMgEI+cTPpyQSW4spNRSFHqsx0uA0b8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44E2plen023253; Tue, 14 May 2024 03:15:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=0EQXN8zCUIZjefRSC02J8IvuDWRrf0vKtNzRxMYuvzg=; b=hILy/x/r4PMFSPszvmxfCpwZyRMOsaVJCs5S3mRIlorp5FWQpr0Ho/UxRRCx4XYkIKrF DusES3gCk+zUbe7b0TiYMJHKpznryqk5pOOcTEl3p79YtD98ZpFP95tgUiMETaTLqr1m lyaOL2SpkT1qWPzlGI1g+yWDjawwZP6pr5aCoH1adVJPvdad7U08dwW+tI15fJCk1B6E MvsXkwq7jGGoDZmR2x2HRcwUq3qR0Y380infbjtxra+ZWqD26U/vWfHFPrQYpNPi1xOg fcS0pqD3xVgMBbyzEcf8JeJn97yk0xCzUXWbbnBOAVNXBk0jrFDYW2Rb9kpUo7uElhcr /w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3y3y8sg2fp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 May 2024 03:15:59 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44E3FwQE026958; Tue, 14 May 2024 03:15:58 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3y3y8sg2fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 May 2024 03:15:58 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 44E06SG1020403; Tue, 14 May 2024 03:15:58 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3y2kcyu9uv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 May 2024 03:15:57 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 44E3Fqpl12452344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 May 2024 03:15:54 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 396512004D; Tue, 14 May 2024 03:15:52 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6894E2004B; Tue, 14 May 2024 03:15:50 +0000 (GMT) Received: from [9.200.158.244] (unknown [9.200.158.244]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 14 May 2024 03:15:50 +0000 (GMT) Message-ID: <80099fde-e6c0-5953-4f78-74fb7bbaf52f@linux.ibm.com> Date: Tue, 14 May 2024 11:15:49 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] report message for operator %a on unaddressible exp Content-Language: en-US To: Jiufu Guo Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, bergner@linux.ibm.com, gcc-patches@gcc.gnu.org References: <20240513025712.889169-1-guojiufu@linux.ibm.com> From: "Kewen.Lin" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 58X1zTsUKNsxtFoWz6mMCKxWwfcq1KJQ X-Proofpoint-ORIG-GUID: EAlL7AQp7UW60oDF1R5z_sY9gouRMsDa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-13_17,2024-05-10_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 spamscore=0 impostorscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405140022 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,KAM_STOCKGEN,NICE_REPLY_A,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP 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, on 2024/5/14 11:00, Jiufu Guo wrote: > Hi, > > Thanks a lot for your helpful review! > > "Kewen.Lin" writes: > >> Hi, >> >> on 2024/5/13 10:57, Jiufu Guo wrote: >>> Hi, >>> >>> For PR96866, when gcc print asm code for modifier "%a" which requires >>> an address operand, while the operand is with the constraint "X" which >>> allow non-address form. An error message would be reported to indicate >>> the invalid asm operands. >>> >>> Bootstrap®test pass on ppc64{,le}. >>> Is this ok for trunk? >>> >>> BR, >>> Jeff(Jiufu Guo) >>> >>> PR target/96866 >>> >>> gcc/ChangeLog: >>> >>> * config/rs6000/rs6000.cc (print_operand_address): >>> >>> gcc/testsuite/ChangeLog: >>> >>> * gcc.target/powerpc/pr96866-1.c: New test. >>> * gcc.target/powerpc/pr96866-2.c: New test. >>> >>> --- >>> gcc/config/rs6000/rs6000.cc | 6 ++++++ >>> gcc/testsuite/gcc.target/powerpc/pr96866-1.c | 15 +++++++++++++++ >>> gcc/testsuite/gcc.target/powerpc/pr96866-2.c | 10 ++++++++++ >>> 3 files changed, 31 insertions(+) >>> create mode 100644 gcc/testsuite/gcc.target/powerpc/pr96866-1.c >>> create mode 100644 gcc/testsuite/gcc.target/powerpc/pr96866-2.c >>> >>> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc >>> index 117999613d8..50943d76f79 100644 >>> --- a/gcc/config/rs6000/rs6000.cc >>> +++ b/gcc/config/rs6000/rs6000.cc >>> @@ -14659,6 +14659,12 @@ print_operand_address (FILE *file, rtx x) >>> else if (SYMBOL_REF_P (x) || GET_CODE (x) == CONST >>> || GET_CODE (x) == LABEL_REF) >>> { >>> + if (this_is_asm_operands && !address_operand (x, VOIDmode)) >> >> Do we really need this_is_asm_operands here? > I understand your point: > since in function 'print_operand_address' which supports not only user > asm code. So, it maybe incorrect if 'x' is not an 'address_operand', > no matter this_is_asm_operands. > > Here, 'this_is_asm_operands' is needed because it would be treated as an > user fault in asm-code (otherwise, internal_error in the compiler). The called function "output_operand_lossage" already takes different actions for this_is_asm_operands and !this_is_asm_operands cases, so for this_is_asm_operands, it goes with error_for_asm and no ICE, no? And without this_is_asm_operands, if we adopt constraint X internally and hit this (it means it's already unexpected), isn't better to see the ICE instead of going further? BR, Kewen > > I notice one thing: > As what we need is emitting error for printing address if the address > can not be access directly. > So it would be better to emit message through 'output_operand_lossage' > just befor gcc_assert(TARGET_TOC). > > Thanks a lot for your insight comment! > >> >>> + { >>> + output_operand_lossage ("invalid expression as operand"); >>> + return; >>> + } >>> + >>> output_addr_const (file, x); >>> if (small_data_operand (x, GET_MODE (x))) >>> fprintf (file, "@%s(%s)", SMALL_DATA_RELOC, >>> diff --git a/gcc/testsuite/gcc.target/powerpc/pr96866-1.c b/gcc/testsuite/gcc.target/powerpc/pr96866-1.c >>> new file mode 100644 >>> index 00000000000..6554a472a11 >>> --- /dev/null >>> +++ b/gcc/testsuite/gcc.target/powerpc/pr96866-1.c >>> @@ -0,0 +1,15 @@ >>> +/* It's to verify no ICE here, ignore error messages about invalid 'asm'. */ >>> +/* { dg-excess-errors "pr96866-2.c" } */ >>> +/* { dg-options "-fPIC -O2" } */ >> >> Nit: If these two options are required, it would be good to have a comment explaining it a bit >> when it's not obvious. > > Good suggestion, thanks! >> >>> + >>> +int x[2]; >>> + >>> +int __attribute__ ((noipa)) >>> +f1 (void) >>> +{ >>> + int n; >>> + int *p = x; >>> + *p++; >>> + __asm__ volatile("ld %0, %a1" : "=r"(n) : "X"(p)); >>> + return n; >>> +} >>> diff --git a/gcc/testsuite/gcc.target/powerpc/pr96866-2.c b/gcc/testsuite/gcc.target/powerpc/pr96866-2.c >>> new file mode 100644 >>> index 00000000000..a5ec96f29dd >>> --- /dev/null >>> +++ b/gcc/testsuite/gcc.target/powerpc/pr96866-2.c >>> @@ -0,0 +1,10 @@ >>> +/* It's to verify no ICE here, ignore error messages about invalid 'asm'. */ >>> +/* { dg-excess-errors "pr96866-2.c" } */ >>> +/* { dg-options "-fPIC -O2" } */ >> >> Ditto. > Thanks! > > BR, > Jeff(Jiufu) Guo >> >> BR, >> Kewen >> >>> + >>> +void >>> +f (void) >>> +{ >>> + extern int x; >>> + __asm__ volatile("#%a0" ::"X"(&x)); >>> +}