From patchwork Thu Sep 8 05:53:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1085 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp89875wrt; Wed, 7 Sep 2022 22:54:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR5brMaiOPo73akn+TGB57pPWcytT7ajFkTtpTyEMgbWAYUXPJKc+BZnTjkyLpmNHhTAkDuv X-Received: by 2002:a17:907:762b:b0:771:5755:82b7 with SMTP id jy11-20020a170907762b00b00771575582b7mr2810534ejc.684.1662616466897; Wed, 07 Sep 2022 22:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662616466; cv=none; d=google.com; s=arc-20160816; b=BEkpuFtV5jfnt4jWwhe3m3LZQkz0t3pjtiG5PuqJ6PSap1M1YSdjD1jA27bZs/I7Ni oTK3H1XClDVetUlVaMOyR8MEyieEc5/RV3SHEU++7bKbzkF2xiMrNIH9CDozryGQIxCz k7UUGzlP0rehWhDiNJdCvl/oqrfW1Dl1+1rxeYEiJd780o3i23qHqTLJTMWuuhkc61Km MsGgBF6/2wtC3qf+y4tiNAgoqcrQfaER7+smEv5larIuP6XUkh+FolsojGtajoIM/yHe Hst04a3afsQPNGlE4cpQpxIMcFoS8a25H4qBbbDwARBbjes0OkC4iZjM/lmzTxFkpHbI SuMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=IxdQg/uc3uWJ1eOFU69WQ8gxPJIAiK17IygsFm4bNZA=; b=emTXa/QG7SqH0igOL9lJslXXLhubdNrO9GdNU8sHp/LrPyBhYigFYM2OcBUKDRowxS UL78Ce/yx/32P8/FcFd40LvGtt1RZ9skGOmrTMknf7K+H5Iu7tTIEz+LN2Vuv4+2fHLB mLgs04PJw49zd89NIDsKbHNPTr4l8Kj4brJbtjDh5EO2By2Mqk9Gg7RMZdqQbzG5p8tb IJIq1LYYklnbgalfD+GJfRiUXxW/5lpeuGxe6teCC/46n5h1XuxEL3MzENeqrodYOqMa eUx/xpcN61WGcYkyQ51DQVeuAFR3ZLia64W2ONNrt0YZbDkAwAZAYOQQwzOaw0czO9PG oqhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QwEaPQFd; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hr6-20020a1709073f8600b00734b451c8c1si1483110ejc.931.2022.09.07.22.54.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 22:54:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QwEaPQFd; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 B317E3858428 for ; Thu, 8 Sep 2022 05:54:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B317E3858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662616465; bh=IxdQg/uc3uWJ1eOFU69WQ8gxPJIAiK17IygsFm4bNZA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QwEaPQFdhSCeGSijC8Mtep53hU1G1VHEWn9/bp+XLKbSlyIPxJsm/9l6sNXo4tZip ji43QcNJwCRPMpLwSht7pJFq4Cv23CwFwRmx4AkgcUxJ3MjPEMNcRdpAgWVHRBnSM1 5LcS0Pn+TucV8KwJI/UBcZZH22NbMvmhWq6HVuW4= 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 14D0F3858D1E for ; Thu, 8 Sep 2022 05:53:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14D0F3858D1E Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2885hEUo018589; Thu, 8 Sep 2022 05:53:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jfag609k4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Sep 2022 05:53:41 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2885mhQ3039233; Thu, 8 Sep 2022 05:53:40 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 3jfag609jc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Sep 2022 05:53:40 +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 2885oEQT014516; Thu, 8 Sep 2022 05:53:38 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04ams.nl.ibm.com with ESMTP id 3jbxj8x37w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Sep 2022 05:53:38 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2885o49639059940 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Sep 2022 05:50:04 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4F239A405B; Thu, 8 Sep 2022 05:53:36 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE066A4054; Thu, 8 Sep 2022 05:53:34 +0000 (GMT) Received: from [9.197.247.218] (unknown [9.197.247.218]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 8 Sep 2022 05:53:34 +0000 (GMT) Message-ID: Date: Thu, 8 Sep 2022 13:53:33 +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] Handle OPAQUE_TYPE specially in verify_type [PR106833] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: aT3j0fVYxuoAWJhoq3br93-1Mfue3WiB X-Proofpoint-GUID: pfkNk_acZvjOWTQ2z_b5oL2eV5uoZQCy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-08_03,2022-09-07_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 clxscore=1015 adultscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209080019 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 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 , Segher Boessenkool 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?1743379724432754258?= X-GMAIL-MSGID: =?utf-8?q?1743379724432754258?= Hi, As PR106833 shows, cv-qualified opaque type can cause ICE during LTO. It exposes that we missd to handle OPAQUE_TYPE well in type verification. As Richi pointed out, also assuming that target will always define TYPE_MAIN_VARIANT and TYPE_CANONICAL for opaque type, this patch is to check both are OPAQUE_TYPE_P. Besides, it also checks the only available size and alignment information as well as type mode for TYPE_MAIN_VARIANT. Bootstrapped and regtested on powerpc64-linux-gnu P7 and powerpc64le-linux-gnu P9 and P10. Is it ok for trunk? BR, Kewen ----- PR middle-end/106833 gcc/ChangeLog: * tree.cc (verify_opaque_type): New function. (verify_match): New macro. (verify_type): Call verify_opaque_type for OPAQUE_TYPE. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr106833.c: New test. --- gcc/testsuite/gcc.target/powerpc/pr106833.c | 14 +++++++ gcc/tree.cc | 45 ++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106833.c -- 2.27.0 diff --git a/gcc/testsuite/gcc.target/powerpc/pr106833.c b/gcc/testsuite/gcc.target/powerpc/pr106833.c new file mode 100644 index 00000000000..968d75184ff --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106833.c @@ -0,0 +1,14 @@ +/* { dg-do link } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto -mdejagnu-cpu=power10" } */ + +/* Verify there is no ICE in LTO mode. */ + +int main () +{ + float *b; + const __vector_quad c; + __builtin_mma_disassemble_acc (b, &c); + return 0; +} diff --git a/gcc/tree.cc b/gcc/tree.cc index fed1434d141..e67caa8f85d 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -13670,6 +13670,42 @@ gimple_canonical_types_compatible_p (const_tree t1, const_tree t2, } } +/* For OPAQUE_TYPE T, it has only size and alignment information, so verify + these properties of T match TV which is the main variant of T. Also + verify the type of TC, which is the canonical of T, is OPAQUE_TYPE. */ + +static void +verify_opaque_type (const_tree t, tree tv, tree tc) +{ + gcc_assert (OPAQUE_TYPE_P (t)); + gcc_assert (tv && tv == TYPE_MAIN_VARIANT (tv)); + gcc_assert (tc && tc == TYPE_CANONICAL (tc)); + +#define verify_match(flag, t, tv) \ + do \ + { \ + if (flag (t) != flag (tv)) \ + { \ + error ("opaque type differs by %s", #flag); \ + debug_tree (tv); \ + } \ + } \ + while (false) + + if (t != tv) + { + verify_match (TREE_CODE, t, tv); + verify_match (TYPE_MODE, t, tv); + verify_match (TYPE_SIZE, t, tv); + verify_match (TYPE_ALIGN, t, tv); + verify_match (TYPE_USER_ALIGN, t, tv); + } + + if (t != tc) + verify_match (TREE_CODE, t, tc); +#undef verify_match +} + /* Verify type T. */ void @@ -13677,6 +13713,14 @@ verify_type (const_tree t) { bool error_found = false; tree mv = TYPE_MAIN_VARIANT (t); + tree ct = TYPE_CANONICAL (t); + + if (OPAQUE_TYPE_P (t)) + { + verify_opaque_type (t, mv, ct); + return; + } + if (!mv) { error ("main variant is not defined"); @@ -13691,7 +13735,6 @@ verify_type (const_tree t) else if (t != mv && !verify_type_variant (t, mv)) error_found = true; - tree ct = TYPE_CANONICAL (t); if (!ct) ; else if (TYPE_CANONICAL (ct) != ct)