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 B76363858D1E; Tue, 14 May 2024 03:32:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B76363858D1E 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 B76363858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715657536; cv=none; b=FG2z/jBy1vI/yhcAT52d1zPYwVSZFLq3Z0I1MxvV/+FrcSD8Pr6BDZlONtwREg+i7H1XLReZXMepkuZarYrwD65/5RnzBdHtwjV7AH7XE0ELzrsveETWt9F411fA5D/LT4a0z1IKKRmhqFCEMZqffHmYoDw3NvW1pZ2/19ldeNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715657536; c=relaxed/simple; bh=WGvye9n6eI3/+k4pL86YycA3CcqexEnZVL5BM6rU8SA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=W2teW7ptu+R/h8T9+UVcr/K297EwDyP88O1xwAIxVcEPqxUbvgmucjgIha5SA1b31C3ijcQkHE4UXIkrHL7oJF/TSZM5mY3PEog71YWEUVVWxhrOsFKjplXJulVFNBZShrqRWI77HzCvvJ1v0Gu8mypftDa95QVAF8sbhO+bm0o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44E3FQFe026886; Tue, 14 May 2024 03:32:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : references : date : in-reply-to : message-id : mime-version : content-type; s=pp1; bh=dACksry8wmU+pqYUldbW5l52XGRlMqd8LF9InWB7clY=; b=SY9cZCBCvbasWfiXrTN5Jgsszhn1zz9KuZ4ySVERUpRqzFcQOqmeAhju4MOuh0hl6EYr 5g4LL+WaZFQKW0w15xEW+YS77/Tn7MBn3IDuebV7zawVXs7OMRW7xWG7LyvNAH42wyzd T3FMOZrRyRYvHaZvaGkkGA+cMnx4tunPBoJ4g+yLdNsssfYjeajoCM61LIrNuHh5GVru trS7cJal+oLTSwxJkY6TLfaxAwUWbpbwebVYaDj7P4PRX0r4Fr8Dj8ZupqKloTG2i4Ba zmMLwjNOsg9CaxVOdsOns7ooEgDDa6Iyg2wktt7D6YHLY/rCvXwxMd9nIr5LI3ZeoklG WQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3y3y1jr451-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 May 2024 03:32:11 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44E3WAWQ019752; Tue, 14 May 2024 03:32:10 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3y3y1jr44w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 May 2024 03:32:10 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 44E0jmEr005998; Tue, 14 May 2024 03:32:09 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3y2mgmb38b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 May 2024 03:32:09 +0000 Received: from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com [10.39.53.233]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 44E3W6hL51642842 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 May 2024 03:32:08 GMT Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B9AE58064; Tue, 14 May 2024 03:32:06 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D433A58056; Tue, 14 May 2024 03:32:05 +0000 (GMT) Received: from genoa (unknown [9.40.192.157]) by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTPS; Tue, 14 May 2024 03:32:05 +0000 (GMT) From: Jiufu Guo To: "Kewen.Lin" Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, bergner@linux.ibm.com, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] report message for operator %a on unaddressible exp References: <20240513025712.889169-1-guojiufu@linux.ibm.com> <80099fde-e6c0-5953-4f78-74fb7bbaf52f@linux.ibm.com> Date: Tue, 14 May 2024 11:32:02 +0800 In-Reply-To: <80099fde-e6c0-5953-4f78-74fb7bbaf52f@linux.ibm.com> (Kewen Lin's message of "Tue, 14 May 2024 11:15:49 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: quM9xzvAhAZNq3b4UyXqnp9AegvNYmXI X-Proofpoint-GUID: 3rSqfIhkPje3M7ngBYCk7FNf4XP37ND1 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 suspectscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 priorityscore=1501 clxscore=1015 mlxscore=0 spamscore=0 impostorscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405140023 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,KAM_STOCKGEN,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, "Kewen.Lin" writes: > 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? Yeap, exactly! "output_operand_lossage" could handle both user 'asm' error and internal_error. So it would be ok to call it directly just for "gcc_assert(TARGET_TOC)" for this "if condition". Like: ``` else if (TARGET_TOC) output_operand_lossage ("invalid expression as operand"); ``` I would refine the patch. Thanks again for your great comments. BR, Jeff(Jiufu) Guo > > 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)); >>>> +}