From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18289 invoked by alias); 30 Nov 2003 06:33:39 -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 18282 invoked from network); 30 Nov 2003 06:33:39 -0000 Received: from unknown (HELO localhost.localdomain) (24.7.123.142) by sources.redhat.com with SMTP; 30 Nov 2003 06:33:39 -0000 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id hAU6XuON025601; Sat, 29 Nov 2003 22:33:56 -0800 Subject: Re: avoid unnecessary register saves for setjmp From: Jim Wilson To: Geoff Keating Cc: gcc-patches@gcc.gnu.org, Daniel Jacobowitz In-Reply-To: References: <1069393614.1023.66.camel@leaf.tuliptree.org> Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Sun, 30 Nov 2003 09:23:00 -0000 Message-Id: <1070174037.1020.39.camel@leaf.tuliptree.org> Mime-Version: 1.0 X-SW-Source: 2003-11/txt/msg02340.txt.bz2 On Fri, 2003-11-21 at 12:11, Geoff Keating wrote: > 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 is an attempt to make NON_SAVING_SETJMP work again, as I offered to do a week ago before I caught the flu. As mentioned before, the current code which sets regs_ever_live in final_start_function only works if there is no register elimination, and if the prologue/epilogue are emitted as assembly language. This makes the code work again by moving the code to reload. The result is similar to the code I deleted a week ago, except that it is only enabled if NON_SAVING_SETMP is true. There is only one port that defines NON_SAVING_SETJMP: i386-sysv. It won't build because of bit-rot, and it is on the list of targets to be obsoleted, and I don't have access to it anyways. So there is no good way to test this change. I tested this by building a i386-linux toolchain, with NON_SAVING_SETJMP set to true and compiling a small testcase. No registers are saved without this patch. With this patch, all call-saved regs are saved in the prologue and restored in the epilogue. There is code in function.c to avoid using registers for locals in a function that calls setjmp when NON_SAVING_SETJMP is true, so this is sufficient to ensure that gcc works even if setjmp doesn't save registers. To make sure I didn't introduce a stupid typo, I did 3 x86-linux bootstraps with --enable-languages=c, one with NON_SAVING_SETMP undefined, one with it defined to 0, and one with it defined to 1. 2003-11-29 James E Wilson * final.c (final_start_function): Delete code for NON_SAVING_SETJMP. * reload1.c (reload): Re-add it here. Index: reload1.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/reload1.c,v retrieving revision 1.413 diff -p -r1.413 reload1.c *** reload1.c 21 Nov 2003 05:49:05 -0000 1.413 --- reload1.c 30 Nov 2003 05:12:16 -0000 *************** reload (rtx first, int global) *** 673,678 **** --- 673,689 ---- if (! call_used_regs[i] && ! fixed_regs[i] && ! LOCAL_REGNO (i)) regs_ever_live[i] = 1; + #ifdef NON_SAVING_SETJMP + /* A function that calls setjmp should save and restore all the + call-saved registers on a system where longjmp clobbers them. */ + if (NON_SAVING_SETJMP && current_function_calls_setjmp) + { + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) + if (! call_used_regs[i]) + regs_ever_live[i] = 1; + } + #endif + /* Find all the pseudo registers that didn't get hard regs but do have known equivalent constants or memory slots. These include parameters (known equivalent to parameter slots) Index: final.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/final.c,v retrieving revision 1.294 diff -p -r1.294 final.c *** final.c 1 Nov 2003 00:48:50 -0000 1.294 --- final.c 30 Nov 2003 05:12:19 -0000 *************** final_start_function (rtx first ATTRIBUT *** 1336,1354 **** this_is_asm_operands = 0; - #ifdef NON_SAVING_SETJMP - /* A function that calls setjmp should save and restore all the - call-saved registers on a system where longjmp clobbers them. */ - if (NON_SAVING_SETJMP && current_function_calls_setjmp) - { - int i; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (!call_used_regs[i]) - regs_ever_live[i] = 1; - } - #endif - last_filename = locator_file (prologue_locator); last_linenum = locator_line (prologue_locator); --- 1336,1341 ---- -- Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com