From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5818 invoked by alias); 12 Nov 2019 09:12:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 5717 invoked by uid 89); 12 Nov 2019 09:12:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LOTSOFHASH,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: EUR04-DB3-obe.outbound.protection.outlook.com Received: from mail-eopbgr60045.outbound.protection.outlook.com (HELO EUR04-DB3-obe.outbound.protection.outlook.com) (40.107.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Nov 2019 09:11:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=proyDYpLclGSmeKtBsDEuecp3LwcYij8AWPRRGJusM4=; b=CEoU/CVYeeDSp8HtTN2lm9CKvXcuuYO40OZ+ZP6dH3Q5atql2TA7AShzWw+GjEeFbcxM9eGNf1m3d2eQOlfPiKW3fcfm3zjVKnq8gknPML8ZBlHcTmeOibTVtS0VLGGAjmVNxefrF8atREVK0T0IcTOKLlLwwXhMcEtf3ym0J04= Received: from HE1PR0802CA0013.eurprd08.prod.outlook.com (2603:10a6:3:bd::23) by AM0PR08MB4434.eurprd08.prod.outlook.com (2603:10a6:208:143::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.22; Tue, 12 Nov 2019 09:11:53 +0000 Received: from AM5EUR03FT038.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::209) by HE1PR0802CA0013.outlook.office365.com (2603:10a6:3:bd::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.20 via Frontend Transport; Tue, 12 Nov 2019 09:11:53 +0000 Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=none action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT038.mail.protection.outlook.com (10.152.17.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.21 via Frontend Transport; Tue, 12 Nov 2019 09:11:52 +0000 Received: ("Tessian outbound 081de437afc7:v33"); Tue, 12 Nov 2019 09:11:52 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f5b32fca9f8c4c64 X-CR-MTA-TID: 64aa7808 Received: from e95a4848fa4b.1 (cr-mta-lb-1.cr-mta-net [104.47.5.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 820598F9-D5BD-4A57-9376-735A60DDEF50.1; Tue, 12 Nov 2019 09:11:46 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02lp2058.outbound.protection.outlook.com [104.47.5.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e95a4848fa4b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Nov 2019 09:11:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f4qaGzkw2U/SPJUoyXZVG2oOKcctZxahwNSj+0r+QMz8+9L4d3c5pdLVB+4CcE5MjtN+IHX9EaEykpNEXezJAcHa9cMYuGyVASseu7Z7y24XOaC5D06J7P+BJjN0Gt7/Kkxw7X6MO4HHn9E4QNAKAExsUQoY3STaT5SP6fbBv+dns9xAfB7rdqgOesQ2oFt3eDsoEwDbMuiuD/6TwFA+2hVjsJvkETZG24CekaDGwumIBldiIafLTi+90URrKgV7pdOypxpBfDrIw0uOJwU9vgjkmnbrU5Xdee/ZMawed80DSPo/ow9PbcLTK8qbLWKRejYW3zCTjZv25XHImzkFSA== 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-SenderADCheck; bh=proyDYpLclGSmeKtBsDEuecp3LwcYij8AWPRRGJusM4=; b=BkQYoS9GOW+z5vSA8eGNLhaAukEm+3NVMr+ZALjrAbCjmUPP/t+klvt6OeIZpB+FIl0KZLEsEdYCVxoSsQ+//CISvvNydL9S81axbyMUFedsA3TbLFQSgytEbdUR231SjHC5cPXLtAT86CerW93neeVp3KcCEOjfaaCbihSq/fMDXnyNc+LjuXIlv8z569QBkek9x6/wYuWqKJpA/yy0U+vk1toRCoalExaUrkiS3SPsrqOPRH8/nxQikJn2zc9hhUHo/uSNxoTMPPkMiiH0QYoNyGwg2Uhe7M9Spk+NkIcJ3YSwFRbziXgkmL82oL5hsRRlA+OhMlKfG5GxlC5ZZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=proyDYpLclGSmeKtBsDEuecp3LwcYij8AWPRRGJusM4=; b=CEoU/CVYeeDSp8HtTN2lm9CKvXcuuYO40OZ+ZP6dH3Q5atql2TA7AShzWw+GjEeFbcxM9eGNf1m3d2eQOlfPiKW3fcfm3zjVKnq8gknPML8ZBlHcTmeOibTVtS0VLGGAjmVNxefrF8atREVK0T0IcTOKLlLwwXhMcEtf3ym0J04= Received: from HE1PR0802MB2251.eurprd08.prod.outlook.com (10.172.131.21) by HE1PR0802MB2201.eurprd08.prod.outlook.com (10.172.131.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.25; Tue, 12 Nov 2019 09:11:44 +0000 Received: from HE1PR0802MB2251.eurprd08.prod.outlook.com ([fe80::e120:9a38:bcf4:6075]) by HE1PR0802MB2251.eurprd08.prod.outlook.com ([fe80::e120:9a38:bcf4:6075%5]) with mapi id 15.20.2430.027; Tue, 12 Nov 2019 09:11:44 +0000 From: Matthew Malcomson To: "gcc-patches@gcc.gnu.org" CC: "rguenther@suse.de" , nd , "law@redhat.com" , "ian@airs.com" , Martin Liska Subject: [mid-end] Add notes to dataflow insn info when re-emitting (PR92410) Date: Tue, 12 Nov 2019 09:16:00 -0000 Message-ID: Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Matthew.Malcomson@arm.com; X-MS-Exchange-PUrlCount: 1 x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:9508;OLM:9508; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(4636009)(136003)(366004)(346002)(396003)(39860400002)(376002)(54534003)(199004)(189003)(6916009)(186003)(8676002)(81156014)(81166006)(6116002)(3846002)(2906002)(966005)(7736002)(8936002)(54906003)(478600001)(4001150100001)(2501003)(33656002)(66616009)(2351001)(52536014)(316002)(4326008)(71200400001)(71190400001)(86362001)(486006)(74316002)(14454004)(25786009)(305945005)(66946007)(5660300002)(26005)(7696005)(52116002)(5640700003)(6436002)(476003)(386003)(44832011)(66066001)(102836004)(6506007)(66556008)(6306002)(99286004)(256004)(9686003)(66476007)(55016002)(64756008)(5024004)(66446008)(14444005);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR0802MB2201;H:HE1PR0802MB2251.eurprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: mQFaozN1hhDclZQzsIDVWOV7nVnUGB0KRtNFmgYT2jJe92JKblRTCx31v5nIHch5EC+4FClrvq1oW1U1iSs7Q4wwx6/3LbtNCNvuE05ttianMc+HDnbazlSxWHOP1/rm0OUsOZ0KsK+4eVjKuuePiCSVnosNe0HIWxGjCriH+yNQnVFgwLIsx+Fz7IsccsOSVKNS02zRPyI/rzoKz8Xbsn0CFd7a+a7Hcr41C32nvDCMhlQYt8Nj73FlNhJitHb0/uHvaxGIqRYCddNdXMMPEd+kmzezHDKK+OV3ZYBox/ey29xEO38OPj43OlvsPxhCK9vxXTU7rY6nYFTbitLIjPTAzKQFQMnDZHBtoUKy3UbwqOv12xLZF++liSknB56DMw2pmnyzwn0SvdzdM9I23fn/jiL/J6j47kHBgS4DMEJuhgLmksPr5pY6LfqTU8JhWjhMkE/aKQZR3AdekZZ/pkY7vxFFF7/XPsCG5omDHwo= x-ms-exchange-transport-forked: True Content-Type: multipart/mixed; boundary="_002_HE1PR0802MB2251E765C9C92B9ADE1412EDE0770HE1PR0802MB2251_" MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Matthew.Malcomson@arm.com; Return-Path: Matthew.Malcomson@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a307d8e3-4341-4f63-9f35-08d767505657 X-IsSubscribed: yes X-SW-Source: 2019-11/txt/msg00846.txt.bz2 --_002_HE1PR0802MB2251E765C9C92B9ADE1412EDE0770HE1PR0802MB2251_ Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable Content-length: 4110 In scheduling passes, notes are removed with `remove_notes` before the scheduling is done, and added back in with `reemit_notes` once the scheduling has been decided. This process leaves the notes in the RTL chain with different insn uid's than were there before. Having different UID's (larger than the previous ones) means that DF_INSN_INFO_GET(insn) will access outside of the allocated array. This has been seen in the `regstat_bb_compute_calls_crossed` function. This patch adds an assert to the `regstat_bb_compute_calls_crossed` function so that bad accesses here are caught instead of going unnoticed, and then avoids the problem. We avoid the problem by ensuring that new notes added by `reemit_notes` hav= e an insn record given to them. This is done by adding a call to `df_insn_create_insn_record` on each note added in `reemit_notes`. `df_insn_create_insn_record` leaves this new record zeroed out, which appea= rs to be fine for notes (e.g. `df_bb_refs_record` already does not set anything except the luid for notes, and notes have no dataflow information = to record). We add the testcase that Martin found here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D92410#c2 . This testcase fails with the "regstat.c" change, and then succeeds with the "haifa-sched.c" change. There is a similar problem with labels, that the `gcc_assert` catches when running regression tests in gcc.dg/fold-eqandshift-1.c and gcc.c-torture/compile/pr32482.c. This is due to the `cfg_layout_finalize` call in `bb-reorder.c` emitting new labels for the start of the newly created basic blocks. These labels are not given a dataflow df_insn_info member. We solve this by manually calling `df_recompute_luids` on each basic block once this pass has finished. Testing done: Bootstrapped and regression test on aarch64-none-linux-gnu native. gcc/ChangeLog: 2019-11-12 Matthew Malcomson PR middle-end/92410 * bb-reorder.c (pass_reorder_blocks::execute): Recompute dataflow luids once basic blocks have been reordered. * haifa-sched.c (reemit_notes): Create df insn record for each new note. * regstat.c (regstat_bb_compute_calls_crossed): Assert every insn has an insn record before trying to use it. gcc/testsuite/ChangeLog: 2019-11-12 Matthew Malcomson PR middle-end/92410 * gcc.dg/torture/pr92410.c: New test. ############### Attachment also inlined for ease of reply ##########= ##### diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c index 0ac39140c6ce3db8499f99cd8f483218888de61b..4943f97a2cfccc7ab7c4834fff2= c81f62fc5b738 100644 --- a/gcc/bb-reorder.c +++ b/gcc/bb-reorder.c @@ -2662,6 +2662,8 @@ pass_reorder_blocks::execute (function *fun) bb->aux =3D bb->next_bb; cfg_layout_finalize (); =20 + FOR_EACH_BB_FN (bb, fun) + df_recompute_luids (bb); return 0; } =20 diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c index 41cf1f362e8c34d009b0a310ff5b9a9ffb613631..2e1a84f1325d54ece1cf3c6f0ba= b607099c71d27 100644 --- a/gcc/haifa-sched.c +++ b/gcc/haifa-sched.c @@ -5433,6 +5433,7 @@ reemit_notes (rtx_insn *insn) =20 last =3D emit_note_before (note_type, last); remove_note (insn, note); + df_insn_create_insn_record (last); } } } diff --git a/gcc/regstat.c b/gcc/regstat.c index 4da9b7cc523cde113df931226ea56310b659e619..c6cefb117d7330cc1b9787c3708= 3e05e2acda2d2 100644 --- a/gcc/regstat.c +++ b/gcc/regstat.c @@ -324,6 +324,7 @@ regstat_bb_compute_calls_crossed (unsigned int bb_index= , bitmap live) =20 FOR_BB_INSNS_REVERSE (bb, insn) { + gcc_assert (INSN_UID (insn) < DF_INSN_SIZE ()); struct df_insn_info *insn_info =3D DF_INSN_INFO_GET (insn); unsigned int regno; =20 diff --git a/gcc/testsuite/gcc.dg/torture/pr92410.c b/gcc/testsuite/gcc.dg/= torture/pr92410.c new file mode 100644 index 0000000000000000000000000000000000000000..628e329782260ef36f26506bfbc= 0d36a93b33f41 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr92410.c @@ -0,0 +1,8 @@ +/* PR middle-end/92410 */ +/* { dg-do compile } */ +int v; + +int a() { + ; + return v; +} --_002_HE1PR0802MB2251E765C9C92B9ADE1412EDE0770HE1PR0802MB2251_ Content-Type: text/plain; name="pr92410.patch" Content-Description: pr92410.patch Content-Disposition: attachment; filename="pr92410.patch"; size=1608; creation-date="Tue, 12 Nov 2019 09:11:44 GMT"; modification-date="Tue, 12 Nov 2019 09:11:44 GMT" Content-ID: Content-Transfer-Encoding: base64 Content-length: 2180 ZGlmZiAtLWdpdCBhL2djYy9iYi1yZW9yZGVyLmMgYi9nY2MvYmItcmVvcmRl ci5jCmluZGV4IDBhYzM5MTQwYzZjZTNkYjg0OTlmOTljZDhmNDgzMjE4ODg4 ZGU2MWIuLjQ5NDNmOTdhMmNmY2NjN2FiN2M0ODM0ZmZmMmM4MWY2MmZjNWI3 MzggMTAwNjQ0Ci0tLSBhL2djYy9iYi1yZW9yZGVyLmMKKysrIGIvZ2NjL2Ji LXJlb3JkZXIuYwpAQCAtMjY2Miw2ICsyNjYyLDggQEAgcGFzc19yZW9yZGVy X2Jsb2Nrczo6ZXhlY3V0ZSAoZnVuY3Rpb24gKmZ1bikKICAgICAgIGJiLT5h dXggPSBiYi0+bmV4dF9iYjsKICAgY2ZnX2xheW91dF9maW5hbGl6ZSAoKTsK IAorICBGT1JfRUFDSF9CQl9GTiAoYmIsIGZ1bikKKyAgICBkZl9yZWNvbXB1 dGVfbHVpZHMgKGJiKTsKICAgcmV0dXJuIDA7CiB9CiAKZGlmZiAtLWdpdCBh L2djYy9oYWlmYS1zY2hlZC5jIGIvZ2NjL2hhaWZhLXNjaGVkLmMKaW5kZXgg NDFjZjFmMzYyZThjMzRkMDA5YjBhMzEwZmY1YjlhOWZmYjYxMzYzMS4uMmUx YTg0ZjEzMjVkNTRlY2UxY2YzYzZmMGJhYjYwNzA5OWM3MWQyNyAxMDA2NDQK LS0tIGEvZ2NjL2hhaWZhLXNjaGVkLmMKKysrIGIvZ2NjL2hhaWZhLXNjaGVk LmMKQEAgLTU0MzMsNiArNTQzMyw3IEBAIHJlZW1pdF9ub3RlcyAocnR4X2lu c24gKmluc24pCiAKIAkgIGxhc3QgPSBlbWl0X25vdGVfYmVmb3JlIChub3Rl X3R5cGU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