From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20269 invoked by alias); 6 Jun 2002 04:30:21 -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 20262 invoked from network); 6 Jun 2002 04:30:19 -0000 Received: from unknown (HELO hiauly1.hia.nrc.ca) (132.246.100.193) by sources.redhat.com with SMTP; 6 Jun 2002 04:30:19 -0000 Received: from hiauly1.hia.nrc.ca (localhost [127.0.0.1]) by hiauly1.hia.nrc.ca (8.12.0.Beta16/8.12.0.Beta16) with ESMTP id g564UIFN021279; Thu, 6 Jun 2002 00:30:18 -0400 (EDT) Received: (from dave@localhost) by hiauly1.hia.nrc.ca (8.12.0.Beta16/8.12.0.Beta16) id g564UHjX021278; Thu, 6 Jun 2002 00:30:17 -0400 (EDT) Message-Id: <200206060430.g564UHjX021278@hiauly1.hia.nrc.ca> Subject: Re: [PATCH] Jump bypassing and improved cprop (take 2) To: jh@suse.cz (Jan Hubicka) Date: Wed, 05 Jun 2002 21:30:00 -0000 From: "John David Anglin" Cc: jh@suse.cz, law@redhat.com, gcc-patches@gcc.gnu.org, rth@redhat.com In-Reply-To: <20020604161157.GO29372@atrey.karlin.mff.cuni.cz> from "Jan Hubicka" at Jun 4, 2002 06:11:58 pm MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SW-Source: 2002-06/txt/msg00518.txt.bz2 > > There only appears to be a couple of other ports with similar code to > > determine the size of a function. Most other uses of INSN_ADDRESSES > > are probably ok. Possibly, the function "get_last_nonnote_insn" could > > be put in emit-rtl.c. Then, it wouldn't be too onerous to change all > > the ports. > > Yes, this looks like sensible approach to me. Thanks for fixing it! This is the fix that I would like to apply to fix the problem of determining the size of a function under hppa-linux and hppa64-hp-hpux11. I believe that the patch is functionally equivalent to what I proposed before for just the PA port. I have moved get_last_nonnote_insn to emit-rtl.c and created a corresponding get_first_nonnote_insn for the avr port. There is some question in my mind whether the latter question is actually necessary but I don't want to second guess the code in avr.c. Bootstrapped and regression tested under hppa-linux. OK for mainline? Dave -- J. David Anglin dave.anglin@nrc.ca National Research Council of Canada (613) 990-0752 (FAX: 952-6605) 2002-06-04 John David Anglin * emit-rtl.c (get_first_nonnote_insn, get_last_nonnote_insn): New functions. * rtl.h (get_first_nonnote_insn, get_last_nonnote_insn): Declare. * avr/avr.c (avr_output_function_epilogue): Use above to determine function size. * pa/pa.c (pa_output_function_prologue): Likewise. Index: emit-rtl.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/emit-rtl.c,v retrieving revision 1.269 diff -u -3 -p -r1.269 emit-rtl.c --- emit-rtl.c 3 Jun 2002 01:13:14 -0000 1.269 +++ emit-rtl.c 4 Jun 2002 16:53:47 -0000 @@ -2743,6 +2743,42 @@ get_last_insn_anywhere () return 0; } +/* Return the first nonnote insn emitted in current sequence or current + function. This routine looks inside SEQUENCEs. */ + +rtx +get_first_nonnote_insn () +{ + rtx insn = first_insn; + + while (insn) + { + insn = next_insn (insn); + if (insn == 0 || GET_CODE (insn) != NOTE) + break; + } + + return insn; +} + +/* Return the last nonnote insn emitted in current sequence or current + function. This routine looks inside SEQUENCEs. */ + +rtx +get_last_nonnote_insn () +{ + rtx insn = last_insn; + + while (insn) + { + insn = previous_insn (insn); + if (insn == 0 || GET_CODE (insn) != NOTE) + break; + } + + return insn; +} + /* Return a number larger than any instruction's uid in this function. */ int Index: rtl.h =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/rtl.h,v retrieving revision 1.352 diff -u -3 -p -r1.352 rtl.h --- rtl.h 2 Jun 2002 21:09:43 -0000 1.352 +++ rtl.h 4 Jun 2002 16:53:48 -0000 @@ -1447,6 +1447,8 @@ extern rtx get_insns PARAMS ((void)); extern const char *get_insn_name PARAMS ((int)); extern rtx get_last_insn PARAMS ((void)); extern rtx get_last_insn_anywhere PARAMS ((void)); +extern rtx get_first_nonnote_insn PARAMS ((void)); +extern rtx get_last_nonnote_insn PARAMS ((void)); extern void start_sequence PARAMS ((void)); extern void push_to_sequence PARAMS ((rtx)); extern void end_sequence PARAMS ((void)); Index: config/avr/avr.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/config/avr/avr.c,v retrieving revision 1.72 diff -u -3 -p -r1.72 avr.c --- config/avr/avr.c 1 Jun 2002 23:33:47 -0000 1.72 +++ config/avr/avr.c 4 Jun 2002 16:53:48 -0000 @@ -749,8 +749,8 @@ avr_output_function_epilogue (file, size interrupt_func_p = interrupt_function_p (current_function_decl); signal_func_p = signal_function_p (current_function_decl); main_p = MAIN_NAME_P (DECL_NAME (current_function_decl)); - function_size = (INSN_ADDRESSES (INSN_UID (get_last_insn ())) - - INSN_ADDRESSES (INSN_UID (get_insns ()))); + function_size = (INSN_ADDRESSES (INSN_UID (get_last_nonnote_insn ())) + - INSN_ADDRESSES (INSN_UID (get_first_nonnote_insn ()))); function_size += jump_tables_size; live_seq = sequent_regs_live (); minimize = (TARGET_CALL_PROLOGUES Index: config/pa/pa.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/config/pa/pa.c,v retrieving revision 1.167 diff -u -3 -p -r1.167 pa.c --- config/pa/pa.c 31 May 2002 18:01:13 -0000 1.167 +++ config/pa/pa.c 4 Jun 2002 16:53:49 -0000 @@ -3182,7 +3182,7 @@ pa_output_function_prologue (file, size) { unsigned int old_total = total_code_bytes; - total_code_bytes += INSN_ADDRESSES (INSN_UID (get_last_insn ())); + total_code_bytes += INSN_ADDRESSES (INSN_UID (get_last_nonnote_insn ())); total_code_bytes += FUNCTION_BOUNDARY / BITS_PER_UNIT; /* Be prepared to handle overflows. */