From patchwork Mon Jan 16 08:33:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 44024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1081389wrn; Mon, 16 Jan 2023 00:34:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXtrvdylJvCP36a17OZlTKEd5SDXXeoy59OyeupJ8+jGwX4W08DiWScPNpLyzi6yWbllTeae X-Received: by 2002:a05:6402:528f:b0:47e:eaae:9a69 with SMTP id en15-20020a056402528f00b0047eeaae9a69mr81077522edb.41.1673858072265; Mon, 16 Jan 2023 00:34:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673858072; cv=none; d=google.com; s=arc-20160816; b=yo9HRjpvVx8E/wsMhdYa7f8OVUUDcL3Kwf/NHA3hOaWrNgTRRtahtAO/C/OV+0BH1t 4OK8JPDYkwbYovMzhnyO5L7jHhvh//uoxS1/KQME1706sr+m/2G9RjFNI0FXw+nHrpqa +p8nTfGZog9/Uw4PFugA7aW1ugRRN2/2Kov8oL+QN1ObkYBWw8hL5vYShf2qlISuSju+ FDpyPfTxnIzu92eiBOZf6lQxbwLxDICksIcnh+wnBG1GJPCsWo3w+N2PY/44sBDeM4GG ZbDelB8LMh+CdjmG7D03dD3Yl01/4vv/7HlYazN+lHpeBXlROMDBZKVXv+dzVJGs3C0v 63SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:cc:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=Oox6qXzC6H/Lrq8+e9npGboXSTa8DeF8r2VgM9+IonI=; b=A9tABfM9xwyCNyLIOKI/Zk7252wZWk9Wq7LbPC1t3jVOJMl5/WZGP0HUla1/XimpO8 R0mPzqCQ5wUnWsmHNkaC7g04BrUW572noHmF8jTrhrZOGAHOdqLRBoMA2giDsknlprev eT82rUBUeUM3kUVJcE2Ej+5gLhSwHUvZrjOalYSpHrbUXJTpcw2GOp63hvmCfYkIX6Ve ZdFATbwZeE8RHPqsIhUout8/7fzN/84X6WI5SJSmql3SoEG9eoyVj6heW+yfHB3mAhOk 8ADtxp5KjXmSIr3S7Oc5UIN806+eL5j/Txfxgz5TiJKlY4d4sLPLODCZc2aNHZ78o5jA GN3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=LSsUoIA1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id by8-20020a0564021b0800b0049d0890542fsi8294595edb.364.2023.01.16.00.34.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 00:34:32 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=LSsUoIA1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D1B33858C60 for ; Mon, 16 Jan 2023 08:34:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D1B33858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673858071; bh=Oox6qXzC6H/Lrq8+e9npGboXSTa8DeF8r2VgM9+IonI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=LSsUoIA1odybVrxdR6eiG6UrsM4N3Z4t3uBUz3YHWeqezo6tp/mSPo6rAZV0hghMO 1JQm13xQEqy518gXw8ZQfV3+BxOM2vcYn8pCBfy4DxLD0OrpxOTUybj998oQ/bpto3 nvgpmmBXFfsxkVa7Mab/hpT8Plwkb7GnALKWQ+mY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 0117B3858D33 for ; Mon, 16 Jan 2023 08:33:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0117B3858D33 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30G5pg1j022695; Mon, 16 Jan 2023 08:33:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n4g07t1xq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Jan 2023 08:33:44 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30G8UHZw028218; Mon, 16 Jan 2023 08:33:43 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n4g07t1x8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Jan 2023 08:33:43 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30G1AVXr006229; Mon, 16 Jan 2023 08:33:42 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3n3knfj4xs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Jan 2023 08:33:41 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30G8XdWi46727574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Jan 2023 08:33:39 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 62FDC20040; Mon, 16 Jan 2023 08:33:39 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B396B20043; Mon, 16 Jan 2023 08:33:37 +0000 (GMT) Received: from [9.200.38.48] (unknown [9.200.38.48]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 16 Jan 2023 08:33:37 +0000 (GMT) Message-ID: <1ea87e1b-7caf-59dd-ff1a-8f282a2dae14@linux.ibm.com> Date: Mon, 16 Jan 2023 16:33:36 +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 Cc: Segher Boessenkool , David Edelsohn , Peter Bergner Subject: [PATCH] rs6000: Teach rs6000_opaque_type_invalid_use_p about gcall [PR108348] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _3M30h5rjOsof93SPIoD-tYkepFGAPaK X-Proofpoint-GUID: NUXWafT6MXog2pvoepDXTMqhbkuWIeSw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-16_06,2023-01-13_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301160062 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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" Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755167401873289289?= X-GMAIL-MSGID: =?utf-8?q?1755167401873289289?= Hi, PR108348 shows one special case that MMA opaque types are used in function arguments and treated as pass by reference, it results in one copying from argument to a temp variable, since this copying happens before rs6000_function_arg check, it can cause ICE without MMA support then. This patch is to teach function rs6000_opaque_type_invalid_use_p to check if any function argument in a gcall stmt has the invalid use of MMA opaque types. btw, I checked the handling on return value, it doesn't have this kind of issue as its checking and error emission is quite early, so this doesn't handle function return value. Bootstrapped and regtested on powerpc64-linux-gnu P8 and powerpc64le-linux-gnu P9 and P10. I'm going to push this soon if no objections. BR, Kewen ----- PR target/108348 gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_opaque_type_invalid_use_p): Add the support for invalid uses of MMA opaque type in function arguments. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr108348-1.c: New test. * gcc.target/powerpc/pr108348-2.c: New test. --- gcc/config/rs6000/rs6000.cc | 19 +++++++++++---- gcc/testsuite/gcc.target/powerpc/pr108348-1.c | 23 +++++++++++++++++++ gcc/testsuite/gcc.target/powerpc/pr108348-2.c | 23 +++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr108348-1.c create mode 100644 gcc/testsuite/gcc.target/powerpc/pr108348-2.c -- 2.27.0 diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 86b879038f7..b69a676fb6c 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -28922,9 +28922,9 @@ constant_generates_xxspltidp (vec_const_128bit_type *vsx_const) __vector_pair built-in types. They are target specific and only available when MMA is supported. With MMA supported, it simply returns true, otherwise it checks if the given gimple - STMT is an assignment or asm stmt and uses either of these two - opaque types unexpectedly, if yes, it would raise an error - message and returns true, otherwise it returns false. */ + STMT is an assignment, asm or call stmt and uses either of + these two opaque types unexpectedly, if yes, it would raise + an error message and returns true, otherwise it returns false. */ bool rs6000_opaque_type_invalid_use_p (gimple *stmt) @@ -28953,7 +28953,7 @@ rs6000_opaque_type_invalid_use_p (gimple *stmt) if (stmt) { /* The usage of MMA opaque types is very limited for now, - to check with gassign and gasm is enough so far. */ + to check with gassign, gasm and gcall is enough so far. */ if (gassign *ga = dyn_cast (stmt)) { tree lhs = gimple_assign_lhs (ga); @@ -28982,6 +28982,17 @@ rs6000_opaque_type_invalid_use_p (gimple *stmt) return true; } } + else if (gcall *gc = dyn_cast (stmt)) + { + unsigned nargs = gimple_call_num_args (gc); + for (unsigned i = 0; i < nargs; i++) + { + tree arg = gimple_call_arg (gc, i); + tree type = TREE_TYPE (arg); + if (check_and_error_invalid_use (type)) + return true; + } + } } return false; diff --git a/gcc/testsuite/gcc.target/powerpc/pr108348-1.c b/gcc/testsuite/gcc.target/powerpc/pr108348-1.c new file mode 100644 index 00000000000..25588a280a6 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr108348-1.c @@ -0,0 +1,23 @@ +/* { dg-require-effective-target powerpc_p9modulo_ok } */ +/* If the default cpu type is power10 or later, type __vector_quad is + supported. To keep the test point available all the time, this case + specifies -mdejagnu-cpu=power9 here. This needs -mabi=no-altivec + to do the copying for pass-by-reference function argument on 32 bit + environment. */ +/* { dg-options "-mdejagnu-cpu=power9 -mabi=no-altivec" } */ + +/* Verify there is no ICE on 32 bit and don't check the error messages + on unsupported type since they could be fragile and are not test + points of this case. */ + +/* { dg-excess-errors "pr108348-1" } */ + +extern void bar (__vector_quad v); + +void +foo (void) +{ + __vector_quad v; + bar (v); +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pr108348-2.c b/gcc/testsuite/gcc.target/powerpc/pr108348-2.c new file mode 100644 index 00000000000..2f6c736382c --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr108348-2.c @@ -0,0 +1,23 @@ +/* { dg-require-effective-target powerpc_p9modulo_ok } */ +/* If the default cpu type is power10 or later, type __vector_pair is + supported. To keep the test point available all the time, this case + specifies -mdejagnu-cpu=power9 here. This needs -mabi=no-altivec + to do the copying for pass-by-reference function argument on 32 bit + environment. */ +/* { dg-options "-mdejagnu-cpu=power9 -mabi=no-altivec" } */ + +/* Verify there is no ICE on 32 bit and don't check the error messages + on unsupported type since they could be fragile and are not test + points of this case. */ + +/* { dg-excess-errors "pr108348-2" } */ + +extern void bar (__vector_pair v); + +void +foo (void) +{ + __vector_pair v; + bar (v); +} +