Message ID | 20250131171232.1018281-30-aleksandar.rakic@htecgroup.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 251493857823 for <patchwork@sourceware.org>; Fri, 31 Jan 2025 18:06:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 251493857823 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=htecgroup.com header.i=@htecgroup.com header.a=rsa-sha256 header.s=selector1 header.b=fFqHOXUX X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20712.outbound.protection.outlook.com [IPv6:2a01:111:f403:2614::712]) by sourceware.org (Postfix) with ESMTPS id AF7A73857820 for <gcc-patches@gcc.gnu.org>; Fri, 31 Jan 2025 17:14:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF7A73857820 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=htecgroup.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=htecgroup.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AF7A73857820 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2614::712 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1738343675; cv=pass; b=So81AF3LEKAvms0t/6A++z86htwV+NlIj5lL6r+bw7l5ljP0twNfbhodEEAJNZEgqymtHW0StyyHWJi4nbAEg9PTosXB7jSiQ2S1Lu0fieng0hfrpKJcp804nhWSM1W3t41f1R9YZaEImwp/YoWfCiR7alYOpw7Zvxqox0xt67U= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1738343675; c=relaxed/simple; bh=xzZ0KwKPERwj5ertfmcvRcEp4/UAmo/ZnsVUIjdzKtI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RlfTs4RbiC4YArPUQR2Jo5kmTETzMbP6KQbUj+oFOB9LW6en1FDlEAVLRlUH8VvuR6ouY2cTDJmj+qJil69/c2OfRbxS5Y85BoGDy99r68vC0ghiu2h/V0NhypgOi8VFqh5HxO675YOu1USHzYZJv+BHWlzWby3jM+yg0l/8biU= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF7A73857820 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sh9/l4GEb+Phz7V0JdMvUY2v3xmtfjPAeZZyLrWyHQ4hMrTraxYSWQTirb4MluiVmgjLX9K5Qmz6qTEhwPZFLh470+pNkXrmOQndEGrmDleqZEJ6eHsleNr6tJANvL2UfjjUDq9PazVSQD22hJ0N5/N6Aiup3J4wSU5aB7twexMX6EKolFmInwOIGviFUK8Bn/eyKOJKuM5XQPoDuiuBkl5CSQuSwNn6SuYmslXRoAznvwsyyYgXBeEHyts8msMEeu5hfYzyrNa6KWUaLiPo4RoRCeLgC3lfkkq33djq8s7+XeVNU80FEFpLl+/f2zgUP3Krzdxt/wdSSl1ssPqLsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=gamVfuU9EOW4fP26fOKK72wzGu41Rlfbm6TwOWGMUrY=; b=xaMjOY8e/0u8bVgglaYQC6rCaRePydv+nSsGt8gAzZIxVqAK0SfVVt5/oD9hb9Wp7YJNDNtzet/10gBuEDBV4NxZ433HuTR7AODAe4ikuNYhln3wfR2VnGls6q2KBxCh152PDdiOO6ZYF/hdctk6xo8Wsp9y7yLh3pp2uO8ekMCPJzatPiJ7JrHtQ8XAHZrLdkcg1IREENXnYbgnhw9SaooExCpBE2rZGP3fpw+90bVGfAjRl120oid1wLUEBKzuLaTbYLDlcc1bFFkDNoYE5GLyMPgi1dQckkLaku53e0hxfBecOAjO9vZVYfzZXGgFX8Mi+2lA845/haCoeV9+LA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=htecgroup.com; dmarc=pass action=none header.from=htecgroup.com; dkim=pass header.d=htecgroup.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=htecgroup.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gamVfuU9EOW4fP26fOKK72wzGu41Rlfbm6TwOWGMUrY=; b=fFqHOXUXRrQ7eMJKAoGAzYGx+YK8GX59b6u4gtRyGPp+lixrYIOskBBLLwBNfh+sJf/9h85SOu1G9sSuC+XNs3m26oIeXEBMGx1lI7ynSuKipsMntwPx1lps+T7JmAhOHi2QMVLrNegvHCpOVWnmzFYt8bblPThRQO1p3VVy7ucOgYOIxXVSBcCOtJP4D5k2tU16Eowa8rkauTnhmGk8qvUwYGIycaHeqj9jUZFJETh4IoeI9keab1/7IqrUUQzSFjMU6PQetRHK5VQe7mbB0BKNseo9xjBAdPM0HL8JV4Q9fA3ZAx0nE7XvkpyFEANGHoQgh0li0vBKywS7sXJSYA== Received: from PA4PR09MB4864.eurprd09.prod.outlook.com (2603:10a6:102:ed::17) by GVXPR09MB7727.eurprd09.prod.outlook.com (2603:10a6:150:1e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.21; Fri, 31 Jan 2025 17:13:33 +0000 Received: from PA4PR09MB4864.eurprd09.prod.outlook.com ([fe80::a02b:9d5c:eca5:e024]) by PA4PR09MB4864.eurprd09.prod.outlook.com ([fe80::a02b:9d5c:eca5:e024%6]) with mapi id 15.20.8398.020; Fri, 31 Jan 2025 17:13:33 +0000 From: Aleksandar Rakic <aleksandar.rakic@htecgroup.com> To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org> CC: Djordje Todorovic <Djordje.Todorovic@htecgroup.com>, "cfu@mips.com" <cfu@mips.com>, Robert Suchanek <robert.suchanek@imgtec.com>, Robert Suchanek <robert.suchanek@mips.com>, Faraz Shahbazker <fshahbazker@wavecomp.com>, Aleksandar Rakic <aleksandar.rakic@htecgroup.com> Subject: [PATCH 28/61] Fix wrong instruction in the delay slot Thread-Topic: [PATCH 28/61] Fix wrong instruction in the delay slot Thread-Index: AQHbdAN1RqBBYa00RE67HbYahYK4UA== Date: Fri, 31 Jan 2025 17:13:33 +0000 Message-ID: <20250131171232.1018281-30-aleksandar.rakic@htecgroup.com> References: <20250131171232.1018281-1-aleksandar.rakic@htecgroup.com> In-Reply-To: <20250131171232.1018281-1-aleksandar.rakic@htecgroup.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=htecgroup.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR09MB4864:EE_|GVXPR09MB7727:EE_ x-ms-office365-filtering-correlation-id: 91bcf7e8-1b0a-4a6b-b9c0-08dd421a9790 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?k8pieYNwjKxoPGzwwJT799ASUd?= =?iso-8859-1?q?MrWFzY2bxH0lEsvNLuSPKfgK6b9/EGFoHkPsryu8E4aosxHeKvNLu39glgR9?= =?iso-8859-1?q?23jXANHAvb5/ZFgfsycLb8wxEWWJgxSlhjmo2ZS22tb/Pu10EFonjjtmGXoB?= =?iso-8859-1?q?oeOOmVF7F8GTLh7HcwzVw/9lrQ01TVdJdWXEtfB+OuRd6Qc7u9WhPiAA2hRP?= =?iso-8859-1?q?HivUL532XuKleRJSncBgznGLoSwpwHbM5Pcou9QJGU2Fv8Uh05izj3+Z3U+D?= =?iso-8859-1?q?gSzGzgA0cjBU8bOJ4a5XNz1KtDurfQe0SyewwDBbeokw1C/Hk3fXM54izYoc?= =?iso-8859-1?q?S9pJxR05sAY0NuClyia7QO0HE9rlKrXbtXoQWmknRX5/P5Id8D79L1eK7rsC?= =?iso-8859-1?q?rKE0ivwExmS3Poz/aeOeFUpWjDjDldsxxiARc9hLP7awv+LDNAKFE/VOqO/v?= =?iso-8859-1?q?fLFMuMDRhBiDxMS2vplM4qQP5dLeaIVePNlZLs3pMaJTUQezW1P6UPQlZYXN?= =?iso-8859-1?q?7ii2vgJExAkFSzzvrMLk/DVB1sGMdEiAQuQ7tqwHC7vT4OzS1s3Ne+SJ+oWX?= =?iso-8859-1?q?NEHWqYdhL0lUKdIdFCchO8xv4erSVzD3k1rBAEYMFN0H9eTV0hqxlyNDO0HO?= =?iso-8859-1?q?YzfH2Q02sEMdt5I/VebDXL+rg+jX6PD2A7Hjlx6W6OKYnPIt0LKLmsGbzq5b?= =?iso-8859-1?q?PrrCSu39JtwMwi+cX0HijoYkvyQei+HUm/xmqCZuQWakpeNBrUn6u9xZddla?= =?iso-8859-1?q?llbCd6PMIdmhr1LwyISa2S5Xx0tEL2sitNJryYk3jjnyGmW2q0ENRJTS5Ahn?= =?iso-8859-1?q?5XfMH+FvFSyn5b0Eg30X9EwARJY4bQ9yLChvITPmpyBq1kFs4VVvY+Ow3ayi?= =?iso-8859-1?q?jQeIISqARHGW5Z0osdElZBFDy7VmRawxDrIA20dAiOeIkjKzx0R8rBPSLdoA?= =?iso-8859-1?q?Hsy7A67jYieIrUqgjWS3Wnz40ZoFMALxaltygEEVYYoL6HHRKVV0i1hw+SRl?= =?iso-8859-1?q?8RXdrzlhHATQaP0PqaRs2+0kywfberRkgXZquAhhEmznxBuudmPk4eliLVYJ?= =?iso-8859-1?q?gh/kXgGF0QlwMBK3gNvg6IS0d81L+BX2gcSDzbzT0W/ssIwfpt2eW38mMngk?= =?iso-8859-1?q?rX7cp7HZByfHz6M/NdI1yYZVKu9aLpy7ISs8QTLtvyhqGgdeNbihfBO+HXkK?= =?iso-8859-1?q?uqLQ3BaZZx1Vm8Emv6zxLEK0vKeqefTqtmqPaEVKad3KC0sqt0OmYTVHIdDt?= =?iso-8859-1?q?ROjlTCSjJW6LXWVmVF8anFqwn7B1ozPtPFSGrL4o1yulXr4iIV2+rySHoUnl?= =?iso-8859-1?q?RrX81W8Mn+5FrgBm0K8PVpoxJJstQUsoZB8uHsuretoW+HLT0kn62Izs8rHz?= =?iso-8859-1?q?9TfgjrAK/G2+0nbQAZ3B8Sx5hAt6U3Wa+61bDczV883VAgrQBHgoCQvd9YmU?= =?iso-8859-1?q?tL5d8QOLhyzt/L1tfe2sQArZuxuvhPBXpLFpkJmi1hSxNBW5JlIB58BxTaRs?= =?iso-8859-1?q?1tfYdW?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR09MB4864.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?iq7m7I5D5TmPygPEeQcdKHU?= =?iso-8859-1?q?OOdmXzP0lS1SDsC5xtvxFp1n6ZhNv34B3kWfR5qimogHekM8q5HLbLzKX/Og?= =?iso-8859-1?q?5M2UtLdMtecX3AU4PpLd472JrMPtqCtonELoADKgBVuJY1TxjNoBmHKKihcb?= =?iso-8859-1?q?74qSjQ81T6AGs0otnQHPilvMeNYo3s542f94c3Iq9EMjYevQGmmwj/3F3AEO?= =?iso-8859-1?q?wEI/Mct3AxaSYKW3jf4ztzgmFW+CGC+RIgIIiTv2v8+vef2Jeb8fen8zcx9F?= =?iso-8859-1?q?GUCq/4hbOyqiy66fLMppgO5lHts4ZNzIKu2TjYFI+qui6HWF2qSt5LpJrh/m?= =?iso-8859-1?q?/tUWmqP61+FYzKZC2UQVFZrnO+dlSSKgbYnYYWq6/KcTncuOLtsu0Kxa/7Hf?= =?iso-8859-1?q?MMdUX4pa8BDIL4ZmlKdQ9cQtlnPzHY+jfNUeJ0kd0FDFsTagwmUrZDxtN3G/?= =?iso-8859-1?q?SPijx3Oym2kN8TLvu+qOYHQrwqfEN3UEW5FENXtzAFV9YPMjv1gVlMlMy53X?= =?iso-8859-1?q?NiTkYi/5VbwQznFB7HlEzNqFU0HwJ7/4HuRNnS9XqXaHChgtbLGk+Zys/OF1?= =?iso-8859-1?q?ViaK5zGkt2qOj0FBa0/r2vqyB8UH4ACBpAl8LFygxsvQwg0MwVHGbttZMzRd?= =?iso-8859-1?q?/9sklfJYdGCqXgPb+rpBhfQ2UjZ0SAJUNnWEhRNnF1Wv7byFB4KlBKrascQY?= =?iso-8859-1?q?dczN7MRTiNAadv/Um6xFsGFwMa/Zu+3u7H5WjFlc7JI6w0XSGsdsIRUw9ngE?= =?iso-8859-1?q?vXiGFbOtwH+iRJ4nzBR5aMvpJRYRs7HwnqySouYVbVRLivB9IT20c0FLXF7v?= =?iso-8859-1?q?SS1Ec21SpjpFNfUgyvnyUtfbbbBSPOlRljPeUCgd2GrzPe7LLm87sj4EaCrz?= =?iso-8859-1?q?ZM/QxlmnWJ4b8JUfRSHRGWRRuYRhZm4WinvZn7YI/JhCJH9Hr59S23GwJOXh?= =?iso-8859-1?q?7doz1fNj3ijK2yldZa12/69cGZK09N9+hxBGVKhbCV+HgF/nHziIHHNHeuqO?= =?iso-8859-1?q?1bz2juEB24SoYpGU2GSSucMyosnxVll3ndKZbeo97/HX3slSwi4myezV+uLi?= =?iso-8859-1?q?cYDi9BTd6EipgnVeVBjDNvH4W8CA0I6Apwm4JP4W7lzyKTBl2h6HY8SASawT?= =?iso-8859-1?q?5uWbXMM5cQvnh9xNE05eyRACs8PQRLws/bsKyoxtrRoBYrSse2vhZD5FqlwZ?= =?iso-8859-1?q?t+tWBzQKWuXTg1Es/uJzLksQRJT40NMyr3sRLD2ElC/Jld+SFrR7KZdzKB7j?= =?iso-8859-1?q?cQet6rlQJHZU9Fb1JAKNavuJbJoKDm5iJ1TmsUqsmx6fVoJeQAKosVrytbUx?= =?iso-8859-1?q?6oLXsfNQfnvxYAXk3xDuahj2ibjbfvO9OkLGiN6BNdEvEo0kiKGETQgRUzp5?= =?iso-8859-1?q?qbdG47ttD8sop9KinBauB8LThqiyPl0Y+KEAUz9Z8uDzBRv6rcJ6hMBwlSAJ?= =?iso-8859-1?q?/jsDhYeUPtj6MWrH7L3Ya2t6UeABL9x7dwWlkJqEHe8he5HtIs9NKFxM0PTy?= =?iso-8859-1?q?CujKKhdbp2lTmWBV0ZVy2cyN4KUh0+tdRMkrdm7jqY6pz1Gi2qDzdy47vMlC?= =?iso-8859-1?q?+qFMGIpsO6WYzFD981pzc1W4+Ys365cNvdFoOCL809ktbCikQchtCJp6BrXg?= =?iso-8859-1?q?SbgY2cZyVgrKGBzmihC5FoOCxTIT6yfplYC4FTaieub0T3D/kYykN7UglOvo?= =?iso-8859-1?q?=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: htecgroup.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR09MB4864.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91bcf7e8-1b0a-4a6b-b9c0-08dd421a9790 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jan 2025 17:13:33.5890 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9f85665b-7efd-4776-9dfe-b6bfda2565ee X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: oAPe+hwaxqonjzYmWuUzxesYC5ryjgDRfuG5gNzsDg/JYlwF61ESMi5P89N74RVlQjjV2Y3woLAyy9rojdpH6o9Tp8NliPzG/RJX97V8K4k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR09MB7727 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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.30 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> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
Series |
Improve Mips target
|
|
Commit Message
Aleksandar Rakic
Jan. 31, 2025, 5:13 p.m. UTC
From: Robert Suchanek <robert.suchanek@imgtec.com> The problematic test case shows that the use of __builtin_unreachable () has a branch not optimised away causing confusion in the eager delay slot filler if the "unreachable" is moved elsewhere by the block reordering pass. It appears that a series of unfortunate events causes a wrong instruction to be placed in the delay slot: 1. The branch is not optimised away during expansion. It has a diamond shape so the unreachable case falls through. 2. The block reordering pass moves the basic block elsewhere. 3. The eager delay slot filler (EDSF): a. It initially skips all the consecutive labels, ignoring barriers, until it finds an instruction. This is done by design. Similarly what first_active_target_insn() does. b. The branch now points to a load for the branch taken case. c. The arithmetic shift left instruction is not placed in the slot because the EDSF detects that there is a conflict with the resource usage (because of a set $4, $4 being referenced or both but very likely because it's referenced). d. As (c) failed, another attempt is taken and the other thread/path explored. This time it succeeds as, at least it appears that, the reverse search for the branch taken path looks for the beginning of the basic block and it does not see that $4 is also used. The lack of referencing $4 by the shift is likely to be the cause of not seeing the usage. e. As (d) succeeded, the load is "legitimately" placed in the delay slot. Perhaps this is a vague description but this is more and less what is happening. The fix attempts to treat the unreachable block (that represents __builtin_unreachable) in a special way: 1. The label is not skipped if it is a label with a barrier only. Notes and debug instructions are ignored. This prevents redirecting the jump to a wrong place that seemed to be treated as a valid redirection. Since the behaviour of such branching is undefined, we don't want to analyse the taken path. 2. The first_active_target_insn() must recognize the unreachable block and not to go beyond the barrier for the same reason as above. 3. With this in place, the eager delay slot filler uses the correct instruction. We don't care where the branch branches to as the behaviour of the program is undefined. The slot is not filled letting the assembler to do the right thing (.set noreorder/reorder are not emitted). gcc/ * reorg.cc (label_with_barrier_p): New function. (skip_consecutive_labels): Use it. Don't skip the label if an empty block is found. (first_active_target_insn): Likewise. Don't ignore the empty block when searching for the next active instruction. Cherry-picked 3667d07c7f0512e8996eab9ab75efc79ac1827c2 from https://github.com/MIPS/gcc Signed-off-by: Robert Suchanek <robert.suchanek@mips.com> Signed-off-by: Faraz Shahbazker <fshahbazker@wavecomp.com> Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com> --- gcc/reorg.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
Comments
See PR rtl-optimization/117327 for a similar issue. > gcc/ > * reorg.cc (label_with_barrier_p): New function. > (skip_consecutive_labels): Use it. Don't skip the label if an > empty block is found. > (first_active_target_insn): Likewise. Don't ignore the empty > block when searching for the next active instruction.
diff --git a/gcc/reorg.cc b/gcc/reorg.cc index 68bf30801cf..91a752b7d4a 100644 --- a/gcc/reorg.cc +++ b/gcc/reorg.cc @@ -113,6 +113,30 @@ along with GCC; see the file COPYING3. If not see These functions are now only used here in reorg.cc, and have therefore been moved here to avoid inadvertent misuse elsewhere in the compiler. */ +/* Return true if a LABEL is followed by a BARRIER. Ignore notes and debug + instructions. */ + +static bool +label_with_barrier_p (rtx_insn *label) +{ + bool empty_bb = true; + + if (GET_CODE (label) != CODE_LABEL) + empty_bb = false; + else + label = NEXT_INSN (label); + + while (!BARRIER_P (label) && empty_bb) + { + if (!(DEBUG_INSN_P (label) + || NOTE_P (label))) + empty_bb = false; + label = NEXT_INSN (label); + } + + return empty_bb; +} + /* Return the last label to mark the same position as LABEL. Return LABEL itself if it is null or any return rtx. */ @@ -140,6 +164,8 @@ skip_consecutive_labels (rtx label_or_return) for (insn = label; insn != 0 && !INSN_P (insn) && !BARRIER_P (insn); insn = NEXT_INSN (insn)) + if (LABEL_P (insn) && label_with_barrier_p (insn)) + break; if (LABEL_P (insn)) label = insn; @@ -230,6 +256,8 @@ first_active_target_insn (rtx insn) { if (ANY_RETURN_P (insn)) return insn; + if (LABEL_P (insn) && label_with_barrier_p ((rtx_insn *)insn)) + return NULL_RTX; return next_active_insn (as_a <rtx_insn *> (insn)); }