From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18176 invoked by alias); 21 Nov 2003 05:46:46 -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 18169 invoked from network); 21 Nov 2003 05:46:45 -0000 Received: from unknown (HELO localhost.localdomain) (24.7.123.142) by sources.redhat.com with SMTP; 21 Nov 2003 05:46:45 -0000 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id hAL5ksiM012577 for ; Thu, 20 Nov 2003 21:46:54 -0800 Subject: avoid unnecessary register saves for setjmp From: Jim Wilson To: gcc-patches@gcc.gnu.org Content-Type: multipart/mixed; boundary="=-hyeLa2SYb6GgQZEm7Cvq" Date: Fri, 21 Nov 2003 05:54:00 -0000 Message-Id: <1069393614.1023.66.camel@leaf.tuliptree.org> Mime-Version: 1.0 X-SW-Source: 2003-11/txt/msg01668.txt.bz2 --=-hyeLa2SYb6GgQZEm7Cvq Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1862 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. -- Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com --=-hyeLa2SYb6GgQZEm7Cvq Content-Disposition: attachment; filename=patch.reload.setjmp Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; name=patch.reload.setjmp; charset=UTF-8 Content-length: 2050 2003-11-20 James E Wilson PR c/13133 * reload1.c (reload): Delete special handling for setjmp. Index: reload1.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/gcc/gcc/gcc/reload1.c,v retrieving revision 1.408 diff -p -r1.408 reload1.c *** reload1.c 27 Oct 2003 10:52:46 -0000 1.408 --- reload1.c 16 Nov 2003 07:45:13 -0000 *************** reload (rtx first, int global) *** 698,706 **** /* Look for REG_EQUIV notes; record what each pseudo is equivalent to. Also find all paradoxical subregs and find largest such for each pse= udo. On machines with small register classes, record hard registers that ! are used for user variables. These can never be used for spills. ! Also look for a "constant" REG_SETJMP. This means that all ! caller-saved registers must be marked live. */ =20=20 num_eliminable_invariants =3D 0; for (insn =3D first; insn; insn =3D NEXT_INSN (insn)) --- 698,704 ---- /* Look for REG_EQUIV notes; record what each pseudo is equivalent to. Also find all paradoxical subregs and find largest such for each pse= udo. On machines with small register classes, record hard registers that ! are used for user variables. These can never be used for spills. */ =20=20 num_eliminable_invariants =3D 0; for (insn =3D first; insn; insn =3D NEXT_INSN (insn)) *************** reload (rtx first, int global) *** 713,724 **** if (INSN_P (insn) && GET_CODE (PATTERN (insn)) =3D=3D USE && GET_MODE (insn) !=3D VOIDmode) PUT_MODE (insn, VOIDmode); -=20 - if (GET_CODE (insn) =3D=3D CALL_INSN - && find_reg_note (insn, REG_SETJMP, NULL)) - for (i =3D 0; i < FIRST_PSEUDO_REGISTER; i++) - if (! call_used_regs[i]) - regs_ever_live[i] =3D 1; =20=20 if (set !=3D 0 && GET_CODE (SET_DEST (set)) =3D=3D REG) { --- 711,716 ---- --=-hyeLa2SYb6GgQZEm7Cvq--