From patchwork Fri Nov 18 23:15:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 126509 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 907A9B7239 for ; Sat, 19 Nov 2011 10:16:35 +1100 (EST) Received: (qmail 17468 invoked by alias); 18 Nov 2011 23:16:33 -0000 Received: (qmail 17453 invoked by uid 22791); 18 Nov 2011 23:16:31 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,TW_CF X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Nov 2011 23:16:15 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1RRXfK-0007bK-CT from Tom_deVries@mentor.com ; Fri, 18 Nov 2011 15:16:14 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 18 Nov 2011 15:13:36 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Fri, 18 Nov 2011 23:16:12 +0000 Message-ID: <4EC6E724.4090008@mentor.com> Date: Sat, 19 Nov 2011 00:15:48 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15 MIME-Version: 1.0 To: Eric Botcazou CC: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH] Remove dead labels to increase superblock scope References: <4EC65977.4020501@mentor.com> <201111182229.14399.ebotcazou@adacore.com> In-Reply-To: <201111182229.14399.ebotcazou@adacore.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 11/18/2011 10:29 PM, Eric Botcazou wrote: >> For the test-case of PR50764, a dead label is introduced by >> fixup_reorder_chain in cfg_layout_finalize, called from >> pass_reorder_blocks. > > I presume that there is no reasonable way of preventing fixup_reorder_chain > from introducing it or of teaching fixup_reorder_chain to remove it? > This (untested) patch also removes the dead label for the PR, and I think it is safe. ... ... But I see 2 potential issues: - it only catches this case in fixup_reorder_chain. I don't know if there are more cases, but the earlier catch-all-afterwards patch surely will catch those, this patch probably not. - I'm not sure if the use count will drop always drop to 0 in fixup_reorder_chain, that might only happen after rebuild_jump_labels. Thanks, - Tom Index: cfglayout.c =================================================================== --- cfglayout.c (revision 181377) +++ cfglayout.c (working copy) @@ -702,6 +702,21 @@ relink_block_chain (bool stay_in_cfglayo } +static bool +forced_label_p (rtx label) +{ + rtx insn, forced_label; + for (insn = forced_labels; insn; insn = XEXP (insn, 1)) + { + forced_label = XEXP (insn, 0); + if (!LABEL_P (forced_label)) + continue; + if (forced_label == label) + return true; + } + return false; +} + /* Given a reorder chain, rearrange the code to match. */ static void @@ -857,6 +872,12 @@ fixup_reorder_chain (void) (e_taken->src, e_taken->dest)); e_taken->flags |= EDGE_FALLTHRU; update_br_prob_note (bb); + if (LABEL_NUSES (ret_label) == 0 + && !LABEL_PRESERVE_P (ret_label) + && LABEL_NAME (ret_label) == NULL + && !forced_label_p (ret_label) + && single_pred_p (e_taken->dest)) + delete_insn (ret_label); continue; } }