From patchwork Tue Feb 8 15:26:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 50920 Return-Path: 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 8E1E5385840B for ; Tue, 8 Feb 2022 15:27:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E1E5385840B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1644334040; bh=eJAWL5CU4ZrR1J2tX+ycXZUFzc3d0Mf2nQRjXvwDHCg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=J0/CjalOxDl/jocgb8o9lD3TDYx7H583bNbULFkfBLq5RYFw4wyMGtIlQ/4HzhM04 nXGSSRIOg7O74IMKXyei17d4wl+gs+JSfh5ntCjM1Ywli43J1z4B7XC1l1bhc5dnof HlyDGNYROFw7/oG7TX0bqGBLaOgwaZL62RbHPoVg= 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 CD6A23858D1E for ; Tue, 8 Feb 2022 15:26:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CD6A23858D1E 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 218DVE54020241; Tue, 8 Feb 2022 15:26:31 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e366wu38h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 15:26:31 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 218FFlY8142161; Tue, 8 Feb 2022 15:26:30 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by userp3030.oracle.com with ESMTP id 3e1ec0f9p8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 15:26:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aGsvp1LcCvtSUvWkyrlFK21BbZdlaFxOPj/BRquxL1Xy5mOU+my0iuECNbR31uJp+9ldvel1iag2M8/9jloOWnyFgQBEFjZYiHuaCaIxS90laMYXp2xNW8xQJGEUtTO3qDOMH1k+AZVLXNsLckB5YThQ5rfFbjtSHF6pgQYC3ZYTy5HXxYzMeTFd56Cu9oGXYxY4EVOgXOroJS1zk4SQQ4SZVjTFCx2akYxFSofnUJ7id9BDJT3exdNjTbiSSCnXxzIT9Soro4lPdrSEwor12v6M3uTh3vrDfYM5f5AHARez84272CeAhhZIwAoge4LepkohCnjwL6vGbkX8VQBUoQ== 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=eJAWL5CU4ZrR1J2tX+ycXZUFzc3d0Mf2nQRjXvwDHCg=; b=KBwlLN76NrRSXh90NrRRqwdsjEj6RVQNogCHkCWEQVLbMtyjO+xgNPdbqhWMqpmEiFC+SbV764OZz++Q3kfo2Ow7h8akB8b6d6JfwSIBJHZ7D3ncN5i2ZPtEPQzxkZ/wIc5tfBxpiP/6jvFPPkJLPt5ZEBD4oy+2K1EH4OHT8pN3/pN9gy7Mjr1oC/EmI+lIJwyy6l/a0GTEpGXfJ8a8nDHdDbKFi3DCJJVE59ytSB8DM21nRh3kJPDWi8JMTXqxEM8nRwXnOpQ6zxp4ry3vS73g5yHj1cz9IkEniEXwiyoI/ZUT9Hzk67XV+kI3iff1FK5nCvybYbUU8GZPTeWCXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) by CH0PR10MB5273.namprd10.prod.outlook.com (2603:10b6:610:db::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Tue, 8 Feb 2022 15:26:28 +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.4975.011; Tue, 8 Feb 2022 15:26:28 +0000 To: Richard Sandiford Subject: [Patch]middle-end: updating the reg use in exit block for -fzero-call-used-regs [PR100775] Thread-Topic: [Patch]middle-end: updating the reg use in exit block for -fzero-call-used-regs [PR100775] Thread-Index: AQHYHQA+blrubh893kyyuSq64JpHPQ== Date: Tue, 8 Feb 2022 15:26:28 +0000 Message-ID: <21559005-B0FF-4C80-83C2-F4EF7A875FF2@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: c9547b59-8acd-43f3-b047-08d9eb1760a3 x-ms-traffictypediagnostic: CH0PR10MB5273:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mrA+gwSs66buNN+3mgqwWw5mq/V5vz2YT4M3Y2ltLzGKQ0gqHFhNdv7HOCupctOpEzWnak4smQgjyO0uLcxq1rE7UDk6jQfJ5jjqossTUTx3Ki+1zLujEKWY/j7q9mpfwxgGg7uKnFegkmcgvoZEiTu8MkxEn7G5rHTCv3VA47BWitkLkD3Xovbkl8qIvWT7pKfn34yXu78gfCQFRdlr9sC2yenhleONQ6inRhKK32Fv+1QyyzxBREU/0OB2TUR0lFXXVCA4qM3j9Pcpq+cng+EErm8ZBmzkeL5pvPXB4oPLLiljE1SHARvhm04KHWjWMSMERPQJag9p7Z2KLxIZkre0YnFfxMMdtOfl/TpsLBaY95Gmdtz5Yw6S/pkj3IoJ32kHd5aEBmQpQviJKu+7qdjNxKlxNgO/54w++4iODQCfkguARtzEDfICNupw+HnNtTjnL3mtVegQaTAIItoIa6Ry/UIHKCd6+IhB0hhSdtKvq78dOSCbhJ5WocXf/m3AP2ZLnRgs8ThxYGRmGkT2YMMlMEbuv5f/2X6gtdjuxhEanZWPgxgmBaD/EU+g2OOqjImSGmTRJNhOTlmeuAKAggcAMnk4kFjErvwDYZkHyVvNoUGs7lneBDeTLBnH/9SJGmW7jReS3dzYuV+mc1I9x+MEZf7wzyDEK7o6VlmpnPU53HbzENq3Hzfr/zXPue1D9cYu9pRx6bfDpIPAPyYncx1gkvemRWIMnmnsA7yq3EE4w0HvJ9Znr3pO0JH0aM+qIzGX68+A2plDEjDPMs0JUpvCHy4EjzNCppyiA6JWN/7+/dvwJQ1U8G848bXAK5yRqVryq4fispe8OtZMIkDFkQ== 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)(33656002)(44832011)(186003)(5660300002)(2616005)(71200400001)(4326008)(8676002)(64756008)(66446008)(66476007)(66556008)(6506007)(8936002)(66946007)(84970400001)(6512007)(91956017)(38070700005)(53546011)(76116006)(2906002)(26005)(83380400001)(86362001)(508600001)(6916009)(122000001)(38100700002)(6486002)(316002)(36756003)(966005)(45980500001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?lCKfaNLAzS1Kpv+qWB/8FATzgu2Z?= =?utf-8?q?7yzDAJkHQA1Od1h4ZQZA0hwwAoloSAyJ39UGZ+u604Rr/V5XgDKykpN6KYEWqBB3N?= =?utf-8?q?xPo0L/flMKgcZT27wCto2b+vEDw0U03KHqXu9WXRDzvWv0dJezdQzUuKDXNz7vH5P?= =?utf-8?q?zLBpR3yuHaLHOy5mEiwB+97Ekz4DZb/kVRIOsZAVVhAswPRtz2O1P4cBwRnNtb8mZ?= =?utf-8?q?wEEsMPenvjI2zt8CJDjiINR4U85wGPhyEDKGoQaISkv/FGgaa8ZEKhYg/5L52vTgO?= =?utf-8?q?2I902VnehGWua55Qn42o29FHKwss+BFQHAHhsOovssEJ6UibXcvhIGtYAveW359MF?= =?utf-8?q?IAPuYUxsiuraZICeuYOA+7zr+bUwpyzRRNmVYxGDTS3jEgW2N6uRGIPn8mcOvuCIc?= =?utf-8?q?2Qy7DslbcARfrL3aVny/0FzicG13v1Nkx9yhfuWo0Ixy3KqsVCF9c4Et8OvWQS7TO?= =?utf-8?q?3UBBieqZN7GJ48gj0Cal+g8wJi9DbsRnmr0sh1eJaEe5MhuwqfWVaSfd/VAoFiOAT?= =?utf-8?q?6BG9yvs7LmMv6OFn74xBBIe6NGGIwItUMfKIaI0NHmtaDZt47slMzdeAaPwSCTGmD?= =?utf-8?q?OWNAvjAI5ojc2hQee5ghMputF9kWf/82NvstTuqck4bdt6g2O+wTfV83k7v/svdRc?= =?utf-8?q?VC3zp8GdyIEn9ORn1bRbpgVCYytCxtzED130rNhkfaYTl4VJRZxJNgyUkjbKVRxC9?= =?utf-8?q?OhFBLG67cHWMEaTU6QAl/g/UhhDkGhmDSlUZz7QDwZQ5yCtI46SC3VCMj9IWY0t77?= =?utf-8?q?zysRF+qZtIdPccc/S1d1PolkX8L2hsyZ25b+AE4A48KDF3KKv8zkrcU0KsCFILDfZ?= =?utf-8?q?BuG/OwdPntCMrn5XgrVyvbpLmWnOrbuhcpyHFFCodMZU1UtVFze28or9+SyrziRdt?= =?utf-8?q?zensNbp76ZC42CFUTcr2Gfg/i9QikShM8Fr1PYZvAObcyTVfkNjKhQ5JmdPNGz7AB?= =?utf-8?q?P7foTeOG3kb3vXPBwMCRY5ZcaJZOEx0qdomWwbKWMaIjweLJCjL38D0d0uimcgi/i?= =?utf-8?q?OxPnS8cT/Bmq00cCG23yPY4+4J+yz70A2LVclkRx2WeWmKiMMVfIitvXQ+6hrPnuG?= =?utf-8?q?c3DXwNSVS52dIY0uVW3CEuW4Kw74sas3g2f1iXeXh64F8vAXf4mvH8CTENCVqp75y?= =?utf-8?q?BuMjslbDvI8/kQranYr3oTQ+1lWnCrFYO3iZcNY2MwEPxboiEgQZAcZb2OsEafawU?= =?utf-8?q?H+sD8kdsNsfX9aeQSL3syaVSWt8l5/xowMA58xh/P09dYt3mxQjq7YgsNFh5b2FIt?= =?utf-8?q?KDdncpp7lTh8KdFbJpjIIaEp5p6eobUxc0ePNsbLizoctcEF0C1XUClDj9Wt7djqd?= =?utf-8?q?0KWq3XPzPoPk4ERWgIHvz6IOOgVLQDO60MmdpnN1Ljzgk9N6nHlkZbMsOJyCZuNy/?= =?utf-8?q?wyjvmVpzNqFufEQ/7QtVRGrp9jXrF3n2bs3uhZHl0/MU0Odtly3jwcsEhP4aspgA/?= =?utf-8?q?aZRjj4llZI1rbouA54hZ2T8uY9nbK90QohkWjNvhcr/tqxUCADfMADrecrcaTHmNU?= =?utf-8?q?6DToBIf1Dn1aVMl+HtHae2Nv0Eh8+GqXHFypkZ5+F4GUvbnoqoLO26o=3D?= Content-ID: 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: c9547b59-8acd-43f3-b047-08d9eb1760a3 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 15:26:28.7282 (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: 0has4b9YI3TYRAysmSgIsRwE3+RWg3G/Uur/fXv9AqeTTj3ItgwHPk+h9AG81eZ3bFgHQq7rFqpV/uKd/UUFjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5273 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10252 signatures=673431 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080095 X-Proofpoint-GUID: ybBVVjuD_DO15iHq2uz1zhVwgdwwh-Wx X-Proofpoint-ORIG-GUID: ybBVVjuD_DO15iHq2uz1zhVwgdwwh-Wx X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Qing Zhao via Gcc-patches From: Qing Zhao Reply-To: Qing Zhao Cc: "Paul A. Clarke via Gcc-patches" Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, Richard, Could you please review this patch? This is a fix to the previous -fzero-call-used-regs implementation. PR 100775 ( ICE: in df_exit_block_bitmap_verify, at df-scan.c:4164 with -mthumb -fzero-call-used-regs=used) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100775 Although the ICE only happens on arm, but this is a bug in the middle end. So, I think this bug has higher priority, Need to be included into gcc12, and also need to be back ported to gcc11. In the pass_zero_call_used_regs, when updating dataflow info after adding the register zeroing sequence in the epilogue of the function, we should call "df_update_exit_block_uses" to update the register use information in the exit block to include all the registers that have been zeroed. The change has been bootstrapped and reg-tested on both x86 and aarch64 (with -enable-checking=yes,rtl,df). Since I cannot find an arm machine, no bootstrap and reg-tested on arm yet. For the arm failure, I just tested it with the cross build and it has no issue withe the fix. (One question here: Previously, I though “df_set_bb_dirty (EXIT_BLOCK_PTR_FOR_FN (cfun))” and a later “df_analyze()” should rescan the changed exit block of the function, and update all the df info automatically, it apparently not the case, the register use info at exit block is not automatically updated, we have to add an explicitly call to “df_update_exit_block_uses”. I checked the pass_thread_prologue_and_epilogue, looks like it also explicitly calls “df_update_entry_exit_and_calls” to update the register use info. Shall the “df_set_bb_dirty” + “df_analyze” automatically update the reg use info of the dirty block?). Let me know whether there is any issue with the fix? Thanks Qing =================================== From e1cca5659c85e7c536f5016a2c75c615e65dba75 Mon Sep 17 00:00:00 2001 From: Qing Zhao Date: Fri, 28 Jan 2022 16:29:51 +0000 Subject: [PATCH] middle-end: updating the reg use in exit block for -fzero-call-used-regs [PR100775] In the pass_zero_call_used_regs, when updating dataflow info after adding the register zeroing sequence in the epilogue of the function, we should call "df_update_exit_block_uses" to update the register use information in the exit block to include all the registers that have been zeroed. 2022-01-27 Qing Zhao gcc/ChangeLog: * function.cc (gen_call_used_regs_seq): Call df_update_exit_block_uses when updating df. gcc/testsuite/ChangeLog: * gcc.target/arm/pr100775.c: New test. --- gcc/function.cc | 1 + gcc/testsuite/gcc.target/arm/pr100775.c | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arm/pr100775.c diff --git a/gcc/function.cc b/gcc/function.cc index e1d2565f8d92..c8a77c9a6246 100644 --- a/gcc/function.cc +++ b/gcc/function.cc @@ -5942,6 +5942,7 @@ gen_call_used_regs_seq (rtx_insn *ret, unsigned int zero_regs_type) /* Update the data flow information. */ crtl->must_be_zero_on_return |= zeroed_hardregs; df_set_bb_dirty (EXIT_BLOCK_PTR_FOR_FN (cfun)); + df_update_exit_block_uses (); } } diff --git a/gcc/testsuite/gcc.target/arm/pr100775.c b/gcc/testsuite/gcc.target/arm/pr100775.c new file mode 100644 index 000000000000..dd2255a95492 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr100775.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-mthumb -fzero-call-used-regs=used" } */ + +int +foo (int x) +{ + return x; +}