This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

avoid unnecessary register saves for setjmp


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: patch.reload.setjmp
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]