From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2085 invoked by alias); 27 Oct 2008 20:34:55 -0000 Received: (qmail 2073 invoked by uid 22791); 27 Oct 2008 20:34:54 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 27 Oct 2008 20:34:11 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m9RKXWNs009135; Mon, 27 Oct 2008 16:33:57 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m9RKXWRe011776; Mon, 27 Oct 2008 16:33:32 -0400 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.2/8.14.2/Submit) id m9RKYCJt021513; Mon, 27 Oct 2008 21:34:12 +0100 Date: Mon, 27 Oct 2008 21:14:00 -0000 From: Jakub Jelinek To: Kenneth Zadeck Cc: Ian Lance Taylor , gcc-patches@gcc.gnu.org Subject: [PATCH] EH_USES df fix (PR target/37378, take 2) Message-ID: <20081027203412.GV14706@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20081027134736.GT14706@tyan-ft48-01.lab.bos.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081027134736.GT14706@tyan-ft48-01.lab.bos.redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes 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 X-SW-Source: 2008-10/txt/msg01170.txt.bz2 Hi! As pointed out by Hans-Peter Nilsson, we want to make EH_USES regs live even if some code path ends with an endless loop, the insns in between still might throw, or during debugging the debugger (or something called from async signal handler) might want to do a backtrace). The patch I've posted earlier doesn't cure e.g. extern int foo (int, int); extern int bar (void); int baz (int x, int y) { if (__builtin_expect (y == 0, 0)) { foo (x + y, x * y); bar (); while (1) ; } if (x == (int) 0x80000000L && y == -1) return x; return x / y; } at -O2 - rp is saved into a local register only if y != 0. The following alternative patch makes EH_USES registers just live everywhere, which IMHO matches best what we really want - let those registers stay live through the whole function. Bootstrapped/regtested on ia64-linux, ok for trunk? 2008-10-27 Jakub Jelinek PR target/37378 * df-scan.c (df_bb_refs_collect): Don't handle EH_USES here. (df_get_entry_block_def_set): Neither here. (df_get_regular_block_artificial_uses): Add EH_USES registers. --- gcc/df-scan.c.jj 2008-10-14 07:58:50.000000000 -0400 +++ gcc/df-scan.c 2008-10-27 14:13:41.000000000 -0400 @@ -3555,29 +3555,6 @@ df_bb_refs_collect (struct df_collection } #endif - -#ifdef EH_USES - if (bb_has_eh_pred (bb)) - { - unsigned int i; - /* This code is putting in an artificial ref for the use at the - TOP of the block that receives the exception. It is too - cumbersome to actually put the ref on the edge. We could - either model this at the top of the receiver block or the - bottom of the sender block. - - The bottom of the sender block is problematic because not all - out-edges of a block are eh-edges. However, it is true - that all edges into a block are either eh-edges or none of - them are eh-edges. Thus, we can model this at the top of the - eh-receiver for all of the edges at once. */ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (EH_USES (i)) - df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[i], NULL, - bb, NULL, DF_REF_REG_USE, DF_REF_AT_TOP, -1, -1, 0); - } -#endif - /* Add the hard_frame_pointer if this block is the target of a non-local goto. */ if (bb->flags & BB_NON_LOCAL_GOTO_TARGET) @@ -3667,6 +3644,8 @@ df_bb_refs_record (int bb_index, bool sc static void df_get_regular_block_artificial_uses (bitmap regular_block_artificial_uses) { + unsigned int i; + bitmap_clear (regular_block_artificial_uses); if (reload_completed) @@ -3702,6 +3681,20 @@ df_get_regular_block_artificial_uses (bi } /* The all-important stack pointer must always be live. */ bitmap_set_bit (regular_block_artificial_uses, STACK_POINTER_REGNUM); + +#ifdef EH_USES + /* EH_USES registers are used: + 1) at all insns that might throw (calls or with -fnon-call-exceptions + trapping insns) + 2) in all EH edges + 3) to support backtraces and/or debugging, anywhere between their + initialization and where they the saved registers are restored + from them, including the cases where we don't reach the epilogue + (noreturn call or infinite loop). */ + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) + if (EH_USES (i)) + bitmap_set_bit (regular_block_artificial_uses, i); +#endif } @@ -3826,16 +3819,6 @@ df_get_entry_block_def_set (bitmap entry /* These registers are live everywhere. */ if (!reload_completed) { -#ifdef EH_USES - /* The ia-64, the only machine that uses this, does not define these - until after reload. */ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (EH_USES (i)) - { - bitmap_set_bit (entry_block_defs, i); - } -#endif - #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM /* Pseudos with argument area equivalences may require reloading via the argument pointer. */ Jakub