From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1714 invoked by alias); 21 Nov 2003 20:13:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 1707 invoked from network); 21 Nov 2003 20:13:01 -0000 Received: from unknown (HELO desire.geoffk.org) (24.6.233.40) by sources.redhat.com with SMTP; 21 Nov 2003 20:13:01 -0000 Received: (from geoffk@localhost) by desire.geoffk.org (8.11.6/8.11.6) id hALKBwH12563; Fri, 21 Nov 2003 12:11:58 -0800 X-Authentication-Warning: desire.geoffk.org: geoffk set sender to geoffk@geoffk.org using -f To: Jim Wilson CC: gcc-patches@gcc.gnu.org, Daniel Jacobowitz Subject: Re: avoid unnecessary register saves for setjmp References: <1069393614.1023.66.camel@leaf.tuliptree.org> From: Geoff Keating Date: Fri, 21 Nov 2003 20:14:00 -0000 In-Reply-To: <1069393614.1023.66.camel@leaf.tuliptree.org> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-11/txt/msg01733.txt.bz2 Jim Wilson writes: > This is for PR c/13133. > > Gcc saves and restores all call-saved registers around a call to > setjmp. This is unnecessary, and is a performance regression from > gcc-3.0 and earlier. This showed up on IA-64 as a libpthread > performance problem, as some critical paths in libpthread use setjmp, > and IA-64 has lots of registers that get saved and restored. This has > also been reported as a problem for PowerPC with Altivec. See PR 12817. > > The code in question was originally added Feb 23, 1996 by Richard > Kenner. He modified the builtin setjmp expander to emit a CONST_CALL_P > NOTE_INSN_SETJMP note, and he added code to reload to mark all call > saved registers as live when one of these notes was seen. > > On Nov 1, 1997, Jeff Law deleted the code in the buildint setjmp > expander that was emitting the CONST_CALL_P NOTE_INSN_SETJMP note, but > the code in reload remained. It now did nothing. A little bit later, > the expander was modified to set current_function_has_nonlocal_label > which gives the same effect as the reload code, but in a way that flow > can understand. > > On Aug 7, 2001, Jan Hubicka checked in a patch that removed > NOTE_INSN_SETJMP notes and replaced them with REG_SETJMP reg notes. > When this change was made, the CONST_CALL_P test in the reload code was > lost, and now the code was enabled for every setjmp call, which was not > the intent of the code. > > The proper fix here is to just delete the long obsolete reload code for > REG_SETJMP. > > This was tested with a ia64-linux bootstrap and make check. There were > no regressions. This was also tested with the testcase in PR 13133. > > I realize this is a bit risky, since running the testsuite does not > really test setjmp. So I am interested in hearing about any problems > this might cause. > > I have checked in the attached patch for this problem. I've looked at this some time in the past (I don't remember the exact circumstances). I came to the same conclusion as you, except in the case when NON_SAVING_SETJMP is defined, when we do need to save any call-saved registers. This should also fix Daniel Jacobowitz's problems: targets can define that macro to be 1 if the library's setjmp isn't complete. -- - Geoffrey Keating