[V3,middle-end/104550] Suppress uninitialized warnings for new created uses from __builtin_clear_padding folding
Message ID | 2801D462-0547-4E07-BF31-CA60182CA160@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E9F3B3857C4E for <patchwork@sourceware.org>; Fri, 25 Feb 2022 01:23:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 5F04C3858402 for <gcc-patches@gcc.gnu.org>; Fri, 25 Feb 2022 01:23:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5F04C3858402 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21OM8jSS028596; Fri, 25 Feb 2022 01:23:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-type : content-id : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=CeXaVO4af/2c1AGmAutXeAjmKGT9SmJJiPVjYiFpVgo=; b=H9b8/x6uw6Xogm85+996wWl3eSGOc3B1qgih6u+gAm7Mkj/VcfZ98FTJXLwdFFjbGJn5 +Gq0V93tiZLvI2xzCqt5oC/ypHYY4r3rwL9d5yMkXSGwAezYxtWMm+wW9oDzZDfnE582 J6dJf7bFzz9kSI5xNycXsAFThaELHuiDE0HKKEcnZzuchuvuxMJA8l4QRnfpROU0Ftvo l0Osm81YFQohUaOMxkg5p1s6bblVkawlHo7G0jHpWCGG8ELNiGdSWWnmy6UDFE/7vGtT YPLXqU1P+Kov4c2kc9tVBvcW+tREljezmSOQs6dFS9B4h5EMmcxri2iAFc2i2FM0uZuC mw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ecvar8j4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Feb 2022 01:23:20 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21P1AwND021479; Fri, 25 Feb 2022 01:23:19 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by userp3020.oracle.com with ESMTP id 3eat0rg8tm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Feb 2022 01:23:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ejxVkQ+oJNJ4Ht6EP77OHEqgFrLCDRHPpy2gkmm55IhbWkMxYbsadI7cw667bxOuDiBf5aOjtcO3qUwL35Gchl9+eKmgXHmHvqAYo6of3Y9XYPVKHoJLVDIutk8tURctT+e8Py29zTLClxOIzGmbfyMHVZcn1ToDqWkpEXS2WbyvA86gUQEMD7zOOQ5hdN43lf/Bpn3EwD3XR5g0orbVo2D8PTNB8X1FJI3u5PR7ME2w9upFW7OxKhq7K+rmYdywjf+5c3iAageAQDX8KZBo1xVCgniJHh7qSk1MzZev+WEtkOx1Tq8tbcXbEneRYuMBV4rB7dNslUi3ir5PJ7vO/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CeXaVO4af/2c1AGmAutXeAjmKGT9SmJJiPVjYiFpVgo=; b=iYdcJM8rASl0eyvzXlK6XbAxIhRHP77AAk9xj5FHThWpAzG+frOyKvnq47nqePCZv4aDrcWmrR9zF/E9XVyKZSIUi71l9Lb2GwT8IT5E5YYppU2HeK1bF69ebXgJ1cTfeJDJQBn9D1tKt0WCyvolvn2tlDV0qTQmW44sFVtUGs/Kn/0EzKyy+DVibCD8MHS3U4W3YC+FhcGKZ2XgJG0Slo+jHyk9IWRjlI9BZsvdH8jR6vvkb1UTx94Vy1mc4pdHa8zAg/mJU92Fg1bjRxVFxt1Ho9lPuLK97SF0BVBUsdHJ8zvJTNLlwGUlcV9zdXqwWenQ4TtZMNdX4atDmRnf7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CeXaVO4af/2c1AGmAutXeAjmKGT9SmJJiPVjYiFpVgo=; b=jeNpOiCDICiySot+NR09JKnoAU/3ukQVW2GQk9yVQzQ+9kSyaQXcELVD93MyulyzP5FkAIt2I1pJO81LbQOIhsg9J4XaVhrIkvzP6Oy58FfxLq37thqsG9H7dWsYpMMmW5Acj/tBSgrw7hbPGaG7xcELGQMHlwq9tdRpUIo2lNo= Received: from CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) by DM5PR1001MB2316.namprd10.prod.outlook.com (2603:10b6:4:2d::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.26; Fri, 25 Feb 2022 01:23:16 +0000 Received: from CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::50e0:10b6:4c07:3728]) by CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::50e0:10b6:4c07:3728%8]) with mapi id 15.20.5017.025; Fri, 25 Feb 2022 01:23:16 +0000 From: Qing Zhao <qing.zhao@oracle.com> To: jakub Jelinek <jakub@redhat.com>, richard Biener <rguenther@suse.de> Subject: [PATCH][V3][middle-end/104550]Suppress uninitialized warnings for new created uses from __builtin_clear_padding folding Thread-Topic: [PATCH][V3][middle-end/104550]Suppress uninitialized warnings for new created uses from __builtin_clear_padding folding Thread-Index: AQHYKeZEstDe2GgGhUm9cciKvMjK5A== Date: Fri, 25 Feb 2022 01:23:16 +0000 Message-ID: <2801D462-0547-4E07-BF31-CA60182CA160@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3608.120.23.2.7) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 98508fdd-105f-429d-3fb0-08d9f7fd6688 x-ms-traffictypediagnostic: DM5PR1001MB2316:EE_ x-microsoft-antispam-prvs: <DM5PR1001MB2316148F7D6EF70BC9EA4F96803E9@DM5PR1001MB2316.namprd10.prod.outlook.com> x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pqGh4CCEJNM0PJ/Cr2bI0ZZRD4J/6lK+udGCLFDAwC8HdVRQ/t06vKsHKLeMrOWPH8u9o8NLjNjCeMEo/CrvRrPRYIclqhpibjhAm+1l96fcmLZ5D7dUuHvEoEXhW9f75Cmz81Ky66hYBTUDPX5ulFxAI4gqAU9SbECDr2nj3lXvstniU7VCKhGu6ZhPqbenPW5RjS0O7xFCauSp+WLw2jmKGKEtAGXc+mPgklGk+3PiOEmxcKpSxtuXnSo5+D2Or1OPc90m2sYe9XNKuPcx+FBkEI6qCdZkQjIuFxalgCU+6+SQqtedv5oEbdgUjEjYyFlQu1WMWj/GUfrydcOPqHAJc25g2k4/dZxjAwqSCQFfLx5dYq6FBBWf4B0w+8WZcJIR5CiCIJF462bQ7UR9RRdBc3KWr/C7lwRVfjkkTbWl8mWd7dbLqKCvTiaGig+CqqfJWesayNEgPTXNoiNYM1y3pMPrvVUTJ5/kecYugnhtDMOngLXpeLzekf3NbAz66qYxQx+6WGZV/jxw10kcaKwwTemLepz/7eiAJYQX8mltM5ES+SZaDkTM3wQV35XcsdkvrK5QN1hmw35dKPqSGuvBvQj+pLW4Mqb1m9PAZlKaz+Adkq7rz39LVv0Jwu55e08K/oluhGIzCq8yBFmVulEaKRVuC6/pCOUqgdCEnsAcVtc/BWQfXRcw6rRfEg22hdOSX8ZMiicjKa2R4qL5E2riR4Vzb6qwa5ytSp0pHPwxaPMG9HJdF1WrkVAw2D7m5ImhuJeKkoE1PNzpb5XrtF7xwYr3xnfztrFbgQpUeZrc2Qd2pZKWWyBDp72lGNRSzEoL4kqQRIqM7c0pgzSQvpa0023ybfUfcczdGPNkmT6zbOxaygMpiUKmA9yrNRp5 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR10MB4344.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6506007)(53546011)(33656002)(6486002)(508600001)(110136005)(316002)(38070700005)(122000001)(71200400001)(6512007)(44832011)(86362001)(2906002)(8936002)(186003)(84970400001)(83380400001)(66946007)(91956017)(66556008)(66446008)(66476007)(76116006)(36756003)(38100700002)(4326008)(5660300002)(2616005)(4743002)(8676002)(64756008)(45980500001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?/xSJ+G43i6dbb3/jNJUgiCiAzsUl?= =?utf-8?q?IZNzUxWK/uaAja6lAE2K5orjLV3lCYX/f5eWnu1b3bbEZw1VkWFmgUaNFvBcrcdI/?= =?utf-8?q?ywMHEtlupS4zcXBKkgOWL3hsluOWLrSRubqbPYH3F303aiNaNUuSn+7OomFj71Wvy?= =?utf-8?q?tWtqCSMZtVjW+fG8c+pC+dB8cM940dmAQvWrIvfz86ayzI/1Oe3fnJeSBiTpVomt8?= =?utf-8?q?mANH6inXqqSJh1GOLiBOygwXXGGPpSP4xawWconxTO0oLlltdu7w27AVuktMzc/6B?= =?utf-8?q?rEsbwWUuhTv1bTHIONQx++Z0UL4FDVgxAp7oxo8MSA1IQYrUAKJMPr+Ln3TCEyfRB?= =?utf-8?q?VWuSVmj5sH4xlOJnOzvFWJVN+FdZQjevQ0yDrz7l2HtHVq5pj4mmiOO6Sq2cA77/W?= =?utf-8?q?OLDvNmlyXXwHCbwHWCDsWooJQtIW7rs9qmHbTfMjXq4xDyfe5QWHJPHQx7xVYx12c?= =?utf-8?q?M7ebiXuO4xbJUsFyOzQHk2iY4QDwnMdz7i3ybooLxnz1JJuy8ld7gqUsqr1ytVtZF?= =?utf-8?q?JeJI7vuOrm90rLAjrEB663CWSwq725eE8dN/j6NCPLGyyz2/rNm/hzdt1uvh6I0LV?= =?utf-8?q?KsELwWvY9PtKvhfjvEgVpVsZSX2P+hTyWdOtpUAwmWkGVH3iYTFe8pNixKIOvBsbY?= =?utf-8?q?EMRCVVtJRwiusMxBkFeq59Tw/0xVLTAVFIsqfD7WOhJQ6qqsR1hK4c4jEdFK/6p43?= =?utf-8?q?xpQB7mB+lgmbtDtOKaKDWAGUJq3eQeL4GYIwFZa0plYzpoBzzpbGwkyj2QKpldzh3?= =?utf-8?q?tAWqTdih+ZZje309TOVM23v2eOBI4FHUdBIdUo0XaC3eia4jwm26xAwY+e8TfAAki?= =?utf-8?q?A+nIi6IK2GlA8E3YloUCDb7F5+tbm1asohyuP3zJ6pElDfZky4f+EiRVA9SPjkma1?= =?utf-8?q?8vN/+ioMzXDMsst1YsC3IwqA1sdth2ZNJp8f2ch4XKNQ10E+zmKd6PKVodcXkPRmN?= =?utf-8?q?T5iHpDiymR8bZeAwCi3xxYz7bI0/HWGiBgrgWVVU9AYSAf/8FiYluULg/oSrpiqpG?= =?utf-8?q?QZlWd/nme2zNXyzRXXC5OAjkmrYjrc75Y81XxnKjYSZ7ryX2jm6qPeggT5h1tJEJb?= =?utf-8?q?9ZFtzO3C3+OkD9nzGhXZJ6JfGtPqMjAXQRdqxf3Bb+pt/yItRJuUrfVpqj6gBcZNG?= =?utf-8?q?FKuYNcNc2rbuGmGR1S7DyTt22GgD7fkEu0VrkUAuguZjchiPPmaUmtjNs6FCZvkRz?= =?utf-8?q?vGBsmcYhxg/qo68ZEf+xTb/sJOshd/MwGqO35D/yix1CsYTGz7YI57ShmryQqErcF?= =?utf-8?q?16THYRMR85LkIx1gyfIeLUBK+iwimde7cvFmxha0WF5T13V92aPEQ1KnYbFm8ARcV?= =?utf-8?q?GWegvTJzvcQrZv06/BBb/mc8KBMyTwCpjdGm83D4DDnZ8964AxUqwQ7A0avbrLfle?= =?utf-8?q?eZFAx2XYlnUw0nbM6Oy7WywkBeuq/zCUVkQCkjTxcG8BM6eBnZdgz0OxRLHrNoF0Z?= =?utf-8?q?Kql14QL7zgWqcC/kV37lNlpNFmbbxo+6cUdeeENdiOqksuwpWzzPD3/GfIeu7nEmr?= =?utf-8?q?NNH0AatsDHGo9dpNGz9nvKYgSmBAOr5ld3Qx4PUfHmntwDkXc8HfJBd9rRA178DBm?= =?utf-8?q?VOQoS7de04OKRPGP8NpqmLQ0bo8du4+gw=3D=3D?= Content-Type: text/plain; charset="utf-8" Content-ID: <1C1BE36A51F5B746AC3FBF5D56D00104@namprd10.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4344.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98508fdd-105f-429d-3fb0-08d9f7fd6688 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Feb 2022 01:23:16.7690 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: AN8X3lL2dWz6TfNjGyCvODX0LeYwQuIY6KyTdJTEa0BfeR6RnSiBrMOgqjZNlV53LeReGbQtR3KQe+JM33s2eA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1001MB2316 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10268 signatures=684655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202250004 X-Proofpoint-GUID: KE1h8uY0Nu4hsNZPPhvXfH4mNL_nFGgd X-Proofpoint-ORIG-GUID: KE1h8uY0Nu4hsNZPPhvXfH4mNL_nFGgd X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Cc: gcc-patches Paul A Clarke via <gcc-patches@gcc.gnu.org> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
[V3,middle-end/104550] Suppress uninitialized warnings for new created uses from __builtin_clear_padding folding
|
|
Commit Message
Qing Zhao
Feb. 25, 2022, 1:23 a.m. UTC
Hi, Jakub and Richard:
This is the 3rd version of the patch, the major change compared to the previous version are:
1. Add warning_enabled_at guard before “suppress_warning”
2. Add location to the call to __builtin_clear_padding for auto init.
The patch has been bootstrapped and regress tested on both x86 and aarch64.
Okay for trunk?
Thanks.
Qing
==================================
From 8314ded4ca0f59c5a3ec431c9c3768fcaf2a0949 Mon Sep 17 00:00:00 2001
From: Qing Zhao <qing.zhao@oracle.com>
Date: Thu, 24 Feb 2022 22:38:38 +0000
Subject: [PATCH] Suppress uninitialized warnings for new created uses from
__builtin_clear_padding folding [PR104550]
__builtin_clear_padding(&object) will clear all the padding bits of the object.
actually, it doesn't involve any use of an user variable. Therefore, users do
not expect any uninitialized warning from it. It's reasonable to suppress
uninitialized warnings for all new created uses from __builtin_clear_padding
folding.
PR middle-end/104550
gcc/ChangeLog:
* gimple-fold.cc (clear_padding_flush): Suppress warnings for new
created uses.
* gimplify.cc (gimple_add_padding_init_for_auto_var): Set
location for new created call to __builtin_clear_padding.
gcc/testsuite/ChangeLog:
* gcc.dg/auto-init-pr104550-1.c: New test.
* gcc.dg/auto-init-pr104550-2.c: New test.
* gcc.dg/auto-init-pr104550-3.c: New test.
---
gcc/gimple-fold.cc | 11 ++++++++++-
gcc/gimplify.cc | 1 +
gcc/testsuite/gcc.dg/auto-init-pr104550-1.c | 10 ++++++++++
gcc/testsuite/gcc.dg/auto-init-pr104550-2.c | 11 +++++++++++
gcc/testsuite/gcc.dg/auto-init-pr104550-3.c | 11 +++++++++++
5 files changed, 43 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-1.c
create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-2.c
create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-3.c
Comments
On Fri, 25 Feb 2022, Qing Zhao wrote: > Hi, Jakub and Richard: > > This is the 3rd version of the patch, the major change compared to the previous version are: > > 1. Add warning_enabled_at guard before “suppress_warning” > 2. Add location to the call to __builtin_clear_padding for auto init. > > The patch has been bootstrapped and regress tested on both x86 and aarch64. > Okay for trunk? > > Thanks. > > Qing > > ================================== > From 8314ded4ca0f59c5a3ec431c9c3768fcaf2a0949 Mon Sep 17 00:00:00 2001 > From: Qing Zhao <qing.zhao@oracle.com> > Date: Thu, 24 Feb 2022 22:38:38 +0000 > Subject: [PATCH] Suppress uninitialized warnings for new created uses from > __builtin_clear_padding folding [PR104550] > > __builtin_clear_padding(&object) will clear all the padding bits of the object. > actually, it doesn't involve any use of an user variable. Therefore, users do > not expect any uninitialized warning from it. It's reasonable to suppress > uninitialized warnings for all new created uses from __builtin_clear_padding > folding. > > PR middle-end/104550 > > gcc/ChangeLog: > > * gimple-fold.cc (clear_padding_flush): Suppress warnings for new > created uses. > * gimplify.cc (gimple_add_padding_init_for_auto_var): Set > location for new created call to __builtin_clear_padding. > > gcc/testsuite/ChangeLog: > > * gcc.dg/auto-init-pr104550-1.c: New test. > * gcc.dg/auto-init-pr104550-2.c: New test. > * gcc.dg/auto-init-pr104550-3.c: New test. > --- > gcc/gimple-fold.cc | 11 ++++++++++- > gcc/gimplify.cc | 1 + > gcc/testsuite/gcc.dg/auto-init-pr104550-1.c | 10 ++++++++++ > gcc/testsuite/gcc.dg/auto-init-pr104550-2.c | 11 +++++++++++ > gcc/testsuite/gcc.dg/auto-init-pr104550-3.c | 11 +++++++++++ > 5 files changed, 43 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-1.c > create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-2.c > create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-3.c > > diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc > index 16f02c2d098d..67b4963ffd96 100644 > --- a/gcc/gimple-fold.cc > +++ b/gcc/gimple-fold.cc > @@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see > #include "attribs.h" > #include "asan.h" > #include "diagnostic-core.h" > +#include "diagnostic.h" > #include "intl.h" > #include "calls.h" > #include "tree-vector-builder.h" > @@ -4379,7 +4380,15 @@ clear_padding_flush (clear_padding_struct *buf, bool full) > else > { > src = make_ssa_name (type); > - g = gimple_build_assign (src, unshare_expr (dst)); > + tree tmp_dst = unshare_expr (dst); > + /* The folding introduces a read from the tmp_dst, we should > + prevent uninitialized warning analysis from issuing warning > + for such fake read. */ > + if (warning_enabled_at (buf->loc, OPT_Wuninitialized) > + || warning_enabled_at (buf->loc, > + OPT_Wmaybe_uninitialized)) > + suppress_warning (tmp_dst, OPT_Wuninitialized); > + g = gimple_build_assign (src, tmp_dst); So what about just gimple_set_no_warning (g, true); ? (sorry for the ping-pong between us three...) > gimple_set_location (g, buf->loc); > gsi_insert_before (buf->gsi, g, GSI_SAME_STMT); > tree mask = native_interpret_expr (type, > diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc > index f570daa015a5..977cf458f858 100644 > --- a/gcc/gimplify.cc > +++ b/gcc/gimplify.cc > @@ -1823,6 +1823,7 @@ gimple_add_padding_init_for_auto_var (tree decl, bool is_vla, > > gimple *call = gimple_build_call (fn, 2, addr_of_decl, > build_one_cst (TREE_TYPE (addr_of_decl))); > + gimple_set_location (call, EXPR_LOCATION (decl)); I believe EXPR_LOCATION (decl) is bogus, 'decl's have DECL_LOCATION, EXPR_LOCATION here will just return UNKNOWN_LOCATION. > gimplify_seq_add_stmt (seq_p, call); > } > > diff --git a/gcc/testsuite/gcc.dg/auto-init-pr104550-1.c b/gcc/testsuite/gcc.dg/auto-init-pr104550-1.c > new file mode 100644 > index 000000000000..a08110c3a170 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/auto-init-pr104550-1.c > @@ -0,0 +1,10 @@ > +/* PR 104550*/ > +/* { dg-do compile } */ > +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=pattern" } */ > +struct vx_audio_level { > + int has_monitor_level : 1; > +}; > + > +void vx_set_monitor_level() { > + struct vx_audio_level info; /* { dg-bogus "info" "is used uninitialized" } */ > +} > diff --git a/gcc/testsuite/gcc.dg/auto-init-pr104550-2.c b/gcc/testsuite/gcc.dg/auto-init-pr104550-2.c > new file mode 100644 > index 000000000000..2c395b32d322 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/auto-init-pr104550-2.c > @@ -0,0 +1,11 @@ > +/* PR 104550 */ > +/* { dg-do compile } */ > +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ > +struct vx_audio_level { > + int has_monitor_level : 1; > +}; > + > +void vx_set_monitor_level() { > + struct vx_audio_level info; > + __builtin_clear_padding (&info); /* { dg-bogus "info" "is used uninitialized" } */ > +} > diff --git a/gcc/testsuite/gcc.dg/auto-init-pr104550-3.c b/gcc/testsuite/gcc.dg/auto-init-pr104550-3.c > new file mode 100644 > index 000000000000..9893e37f12d8 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/auto-init-pr104550-3.c > @@ -0,0 +1,11 @@ > +/* PR 104550 */ > +/* { dg-do compile } */ > +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=pattern" } */ > +struct vx_audio_level { > + int has_monitor_level : 1; > +}; > + > +void vx_set_monitor_level() { > + struct vx_audio_level info; /* { dg-bogus "info" "is used uninitialized" } */ > + __builtin_clear_padding (&info); /* { dg-bogus "info" "is used uninitialized" } */ > +} >
> On Feb 25, 2022, at 2:38 AM, Richard Biener <rguenther@suse.de> wrote: > > On Fri, 25 Feb 2022, Qing Zhao wrote: > >> Hi, Jakub and Richard: >> >> This is the 3rd version of the patch, the major change compared to the previous version are: >> >> 1. Add warning_enabled_at guard before “suppress_warning” >> 2. Add location to the call to __builtin_clear_padding for auto init. >> >> The patch has been bootstrapped and regress tested on both x86 and aarch64. >> Okay for trunk? >> >> Thanks. >> >> Qing >> >> ================================== >> From 8314ded4ca0f59c5a3ec431c9c3768fcaf2a0949 Mon Sep 17 00:00:00 2001 >> From: Qing Zhao <qing.zhao@oracle.com> >> Date: Thu, 24 Feb 2022 22:38:38 +0000 >> Subject: [PATCH] Suppress uninitialized warnings for new created uses from >> __builtin_clear_padding folding [PR104550] >> >> __builtin_clear_padding(&object) will clear all the padding bits of the object. >> actually, it doesn't involve any use of an user variable. Therefore, users do >> not expect any uninitialized warning from it. It's reasonable to suppress >> uninitialized warnings for all new created uses from __builtin_clear_padding >> folding. >> >> PR middle-end/104550 >> >> gcc/ChangeLog: >> >> * gimple-fold.cc (clear_padding_flush): Suppress warnings for new >> created uses. >> * gimplify.cc (gimple_add_padding_init_for_auto_var): Set >> location for new created call to __builtin_clear_padding. >> >> gcc/testsuite/ChangeLog: >> >> * gcc.dg/auto-init-pr104550-1.c: New test. >> * gcc.dg/auto-init-pr104550-2.c: New test. >> * gcc.dg/auto-init-pr104550-3.c: New test. >> --- >> gcc/gimple-fold.cc | 11 ++++++++++- >> gcc/gimplify.cc | 1 + >> gcc/testsuite/gcc.dg/auto-init-pr104550-1.c | 10 ++++++++++ >> gcc/testsuite/gcc.dg/auto-init-pr104550-2.c | 11 +++++++++++ >> gcc/testsuite/gcc.dg/auto-init-pr104550-3.c | 11 +++++++++++ >> 5 files changed, 43 insertions(+), 1 deletion(-) >> create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-1.c >> create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-2.c >> create mode 100644 gcc/testsuite/gcc.dg/auto-init-pr104550-3.c >> >> diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc >> index 16f02c2d098d..67b4963ffd96 100644 >> --- a/gcc/gimple-fold.cc >> +++ b/gcc/gimple-fold.cc >> @@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see >> #include "attribs.h" >> #include "asan.h" >> #include "diagnostic-core.h" >> +#include "diagnostic.h" >> #include "intl.h" >> #include "calls.h" >> #include "tree-vector-builder.h" >> @@ -4379,7 +4380,15 @@ clear_padding_flush (clear_padding_struct *buf, bool full) >> else >> { >> src = make_ssa_name (type); >> - g = gimple_build_assign (src, unshare_expr (dst)); >> + tree tmp_dst = unshare_expr (dst); >> + /* The folding introduces a read from the tmp_dst, we should >> + prevent uninitialized warning analysis from issuing warning >> + for such fake read. */ >> + if (warning_enabled_at (buf->loc, OPT_Wuninitialized) >> + || warning_enabled_at (buf->loc, >> + OPT_Wmaybe_uninitialized)) >> + suppress_warning (tmp_dst, OPT_Wuninitialized); >> + g = gimple_build_assign (src, tmp_dst); > > So what about just gimple_set_no_warning (g, true); ? (sorry for > the ping-pong between us three...) This didn’t work. The small testing case still failed. This is due to in tree-ssa-uninit.cc, it checks get_no_uninit_warning (RHS), not for the whole stmt. We can update tree-sea-uninit.cc to check the whole stmt, but I am not sure whether doing this might introduce other issue. Qing > >> gimple_set_location (g, buf->loc); >> gsi_insert_before (buf->gsi, g, GSI_SAME_STMT); >> tree mask = native_interpret_expr (type, >> diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc >> index f570daa015a5..977cf458f858 100644 >> --- a/gcc/gimplify.cc >> +++ b/gcc/gimplify.cc >> @@ -1823,6 +1823,7 @@ gimple_add_padding_init_for_auto_var (tree decl, bool is_vla, >> >> gimple *call = gimple_build_call (fn, 2, addr_of_decl, >> build_one_cst (TREE_TYPE (addr_of_decl))); >> + gimple_set_location (call, EXPR_LOCATION (decl)); > > I believe EXPR_LOCATION (decl) is bogus, 'decl's have DECL_LOCATION, > EXPR_LOCATION here will just return UNKNOWN_LOCATION. > >> gimplify_seq_add_stmt (seq_p, call); >> } >> >> diff --git a/gcc/testsuite/gcc.dg/auto-init-pr104550-1.c b/gcc/testsuite/gcc.dg/auto-init-pr104550-1.c >> new file mode 100644 >> index 000000000000..a08110c3a170 >> --- /dev/null >> +++ b/gcc/testsuite/gcc.dg/auto-init-pr104550-1.c >> @@ -0,0 +1,10 @@ >> +/* PR 104550*/ >> +/* { dg-do compile } */ >> +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=pattern" } */ >> +struct vx_audio_level { >> + int has_monitor_level : 1; >> +}; >> + >> +void vx_set_monitor_level() { >> + struct vx_audio_level info; /* { dg-bogus "info" "is used uninitialized" } */ >> +} >> diff --git a/gcc/testsuite/gcc.dg/auto-init-pr104550-2.c b/gcc/testsuite/gcc.dg/auto-init-pr104550-2.c >> new file mode 100644 >> index 000000000000..2c395b32d322 >> --- /dev/null >> +++ b/gcc/testsuite/gcc.dg/auto-init-pr104550-2.c >> @@ -0,0 +1,11 @@ >> +/* PR 104550 */ >> +/* { dg-do compile } */ >> +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ >> +struct vx_audio_level { >> + int has_monitor_level : 1; >> +}; >> + >> +void vx_set_monitor_level() { >> + struct vx_audio_level info; >> + __builtin_clear_padding (&info); /* { dg-bogus "info" "is used uninitialized" } */ >> +} >> diff --git a/gcc/testsuite/gcc.dg/auto-init-pr104550-3.c b/gcc/testsuite/gcc.dg/auto-init-pr104550-3.c >> new file mode 100644 >> index 000000000000..9893e37f12d8 >> --- /dev/null >> +++ b/gcc/testsuite/gcc.dg/auto-init-pr104550-3.c >> @@ -0,0 +1,11 @@ >> +/* PR 104550 */ >> +/* { dg-do compile } */ >> +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=pattern" } */ >> +struct vx_audio_level { >> + int has_monitor_level : 1; >> +}; >> + >> +void vx_set_monitor_level() { >> + struct vx_audio_level info; /* { dg-bogus "info" "is used uninitialized" } */ >> + __builtin_clear_padding (&info); /* { dg-bogus "info" "is used uninitialized" } */ >> +} >> > > -- > Richard Biener <rguenther@suse.de> > SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, > Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg)
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index 16f02c2d098d..67b4963ffd96 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see #include "attribs.h" #include "asan.h" #include "diagnostic-core.h" +#include "diagnostic.h" #include "intl.h" #include "calls.h" #include "tree-vector-builder.h" @@ -4379,7 +4380,15 @@ clear_padding_flush (clear_padding_struct *buf, bool full) else { src = make_ssa_name (type); - g = gimple_build_assign (src, unshare_expr (dst)); + tree tmp_dst = unshare_expr (dst); + /* The folding introduces a read from the tmp_dst, we should + prevent uninitialized warning analysis from issuing warning + for such fake read. */ + if (warning_enabled_at (buf->loc, OPT_Wuninitialized) + || warning_enabled_at (buf->loc, + OPT_Wmaybe_uninitialized)) + suppress_warning (tmp_dst, OPT_Wuninitialized); + g = gimple_build_assign (src, tmp_dst); gimple_set_location (g, buf->loc); gsi_insert_before (buf->gsi, g, GSI_SAME_STMT); tree mask = native_interpret_expr (type, diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index f570daa015a5..977cf458f858 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -1823,6 +1823,7 @@ gimple_add_padding_init_for_auto_var (tree decl, bool is_vla, gimple *call = gimple_build_call (fn, 2, addr_of_decl, build_one_cst (TREE_TYPE (addr_of_decl))); + gimple_set_location (call, EXPR_LOCATION (decl)); gimplify_seq_add_stmt (seq_p, call); } diff --git a/gcc/testsuite/gcc.dg/auto-init-pr104550-1.c b/gcc/testsuite/gcc.dg/auto-init-pr104550-1.c new file mode 100644 index 000000000000..a08110c3a170 --- /dev/null +++ b/gcc/testsuite/gcc.dg/auto-init-pr104550-1.c @@ -0,0 +1,10 @@ +/* PR 104550*/ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=pattern" } */ +struct vx_audio_level { + int has_monitor_level : 1; +}; + +void vx_set_monitor_level() { + struct vx_audio_level info; /* { dg-bogus "info" "is used uninitialized" } */ +} diff --git a/gcc/testsuite/gcc.dg/auto-init-pr104550-2.c b/gcc/testsuite/gcc.dg/auto-init-pr104550-2.c new file mode 100644 index 000000000000..2c395b32d322 --- /dev/null +++ b/gcc/testsuite/gcc.dg/auto-init-pr104550-2.c @@ -0,0 +1,11 @@ +/* PR 104550 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +struct vx_audio_level { + int has_monitor_level : 1; +}; + +void vx_set_monitor_level() { + struct vx_audio_level info; + __builtin_clear_padding (&info); /* { dg-bogus "info" "is used uninitialized" } */ +} diff --git a/gcc/testsuite/gcc.dg/auto-init-pr104550-3.c b/gcc/testsuite/gcc.dg/auto-init-pr104550-3.c new file mode 100644 index 000000000000..9893e37f12d8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/auto-init-pr104550-3.c @@ -0,0 +1,11 @@ +/* PR 104550 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=pattern" } */ +struct vx_audio_level { + int has_monitor_level : 1; +}; + +void vx_set_monitor_level() { + struct vx_audio_level info; /* { dg-bogus "info" "is used uninitialized" } */ + __builtin_clear_padding (&info); /* { dg-bogus "info" "is used uninitialized" } */ +}