public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jim Wilson <wilson@specifixinc.com>
To: gcc-patches@gcc.gnu.org
Subject: avoid unnecessary register saves for setjmp
Date: Fri, 21 Nov 2003 05:54:00 -0000	[thread overview]
Message-ID: <1069393614.1023.66.camel@leaf.tuliptree.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1862 bytes --]

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

[-- Attachment #2: patch.reload.setjmp --]
[-- Type: text/plain, Size: 1908 bytes --]

2003-11-20  James E Wilson  <wilson@specifixinc.com>

	PR c/13133
	* reload1.c (reload): Delete special handling for setjmp.

Index: reload1.c
===================================================================
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 pseudo.
       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.  */
  
    num_eliminable_invariants = 0;
    for (insn = first; insn; insn = 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 pseudo.
       On machines with small register classes, record hard registers that
!      are used for user variables.  These can never be used for spills.  */
  
    num_eliminable_invariants = 0;
    for (insn = first; insn; insn = NEXT_INSN (insn))
*************** reload (rtx first, int global)
*** 713,724 ****
        if (INSN_P (insn) && GET_CODE (PATTERN (insn)) == USE
  	  && GET_MODE (insn) != VOIDmode)
  	PUT_MODE (insn, VOIDmode);
- 
-       if (GET_CODE (insn) == CALL_INSN
- 	  && find_reg_note (insn, REG_SETJMP, NULL))
- 	for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
- 	  if (! call_used_regs[i])
- 	    regs_ever_live[i] = 1;
  
        if (set != 0 && GET_CODE (SET_DEST (set)) == REG)
  	{
--- 711,716 ----

             reply	other threads:[~2003-11-21  5:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-21  5:54 Jim Wilson [this message]
2003-11-21 18:39 ` Daniel Jacobowitz
2003-11-22  0:22   ` Jim Wilson
2003-11-22  3:57     ` Daniel Jacobowitz
2003-11-22  9:06       ` Jim Wilson
2003-11-22 14:37         ` Richard Earnshaw
2003-11-22 16:33           ` Daniel Jacobowitz
2003-11-27  9:11             ` Zack Weinberg
2003-11-27 17:11               ` Andrew Pinski
2003-11-27 18:23                 ` Zack Weinberg
2003-11-28  5:15                   ` Geert Bosch
2003-11-28 11:14                   ` Richard Earnshaw
2003-11-28 14:02             ` Richard Earnshaw
2003-11-21 20:14 ` Geoff Keating
2003-11-22  0:20   ` Jim Wilson
2003-11-30  9:23   ` Jim Wilson
2003-11-22  4:13 Richard Kenner
2003-12-01  3:29 ` Jim Wilson
2003-11-27  9:19 Chris Lattner
2003-11-27  9:21 ` Andrew Haley
2003-11-27  9:22   ` Chris Lattner
2003-11-27  9:39     ` Andrew Haley
2003-11-27  9:43       ` Chris Lattner
2003-11-27 10:14       ` Zack Weinberg
2003-11-27 10:15         ` Chris Lattner
2003-11-27 11:01           ` Zack Weinberg
2003-11-27 20:28             ` Chris Lattner
2003-11-27 20:51               ` Gabriel Dos Reis
2003-11-27 15:41           ` Jan Vroonhof
2003-11-27 16:23           ` Jan Vroonhof
2003-11-27 10:31         ` Andrew Haley
2003-11-27 10:53           ` Zack Weinberg
     [not found] <5cad8ef043da68f2a3332f00bd6a186a3fc6195b@mail.esmertec.com>
2003-11-27 20:44 ` Chris Lattner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1069393614.1023.66.camel@leaf.tuliptree.org \
    --to=wilson@specifixinc.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).