From patchwork Sun Oct 24 07:37:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 69026 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 B7301B6ED0 for ; Sun, 24 Oct 2010 18:45:48 +1100 (EST) Received: (qmail 22384 invoked by alias); 24 Oct 2010 07:45:45 -0000 Received: (qmail 22371 invoked by uid 22791); 24 Oct 2010 07:45:44 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 24 Oct 2010 07:45:38 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 3EA0FCB029C for ; Sun, 24 Oct 2010 09:45:35 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MM1O9O5pmWIP for ; Sun, 24 Oct 2010 09:45:35 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 13BB5CB01DF for ; Sun, 24 Oct 2010 09:45:35 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Tweaks to RTL locus preservation code (2) Date: Sun, 24 Oct 2010 09:37:27 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201010240937.27907.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 Another couple of small tweaks to the code introduced by Jakub to preserve location info at -O0, this time to fixup_reorder_chain. The first change makes it so that the code doesn't try to split non-fallthru edges to the exit block (this can happen with unusual combinations of options) and the second one avoids creating several artificial basic blocks because of the same locus on different edges. Tested (GCC + GDB) on x86_64-suse-linux, applied on the mainline. 2010-10-24 Eric Botcazou * cfglayout.c (fixup_reorder_chain): When ensuring that there is at least one insn with a locus corresponding to an edge's goto_locus, disregard non-fallthru edges to the exit block and merge the blocks created for the same goto_locus. Index: cfglayout.c =================================================================== --- cfglayout.c (revision 165881) +++ cfglayout.c (working copy) @@ -940,7 +940,9 @@ fixup_reorder_chain (void) FOR_EACH_EDGE (e, ei, bb->succs) if (e->goto_locus && !(e->flags & EDGE_ABNORMAL)) { - basic_block nb; + edge e2; + edge_iterator ei2; + basic_block dest, nb; rtx end; insn = BB_END (e->src); @@ -957,10 +959,17 @@ fixup_reorder_chain (void) INSN_LOCATOR (BB_END (e->src)) = e->goto_locus; continue; } - if (e->dest != EXIT_BLOCK_PTR) + dest = e->dest; + if (dest == EXIT_BLOCK_PTR) { - insn = BB_HEAD (e->dest); - end = NEXT_INSN (BB_END (e->dest)); + /* Non-fallthru edges to the exit block cannot be split. */ + if (!(e->flags & EDGE_FALLTHRU)) + continue; + } + else + { + insn = BB_HEAD (dest); + end = NEXT_INSN (BB_END (dest)); while (insn != end && !NONDEBUG_INSN_P (insn)) insn = NEXT_INSN (insn); if (insn != end && INSN_LOCATOR (insn) @@ -972,6 +981,18 @@ fixup_reorder_chain (void) BB_END (nb) = emit_insn_after_noloc (gen_nop (), BB_END (nb), nb); INSN_LOCATOR (BB_END (nb)) = e->goto_locus; + + /* If there are other incoming edges to the destination block + with the same goto locus, redirect them to the new block as + well, this can prevent other such blocks from being created + in subsequent iterations of the loop. */ + for (ei2 = ei_start (dest->preds); (e2 = ei_safe_edge (ei2)); ) + if (e2->goto_locus + && !(e2->flags & (EDGE_ABNORMAL | EDGE_FALLTHRU)) + && locator_eq (e->goto_locus, e2->goto_locus)) + redirect_edge_and_branch (e2, nb); + else + ei_next (&ei2); } } }