From: John David Anglin Date: Sat, 1 Feb 2003 04:50:32 +0000 (+0000) Subject: pa.c (pa_output_function_prologue, [...]): Move updating of total_code_bytes from... X-Git-Tag: releases/gcc-3.2.2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f6f2907823eac04880c8cc304688f18e3637c2f;p=thirdparty%2Fgcc.git pa.c (pa_output_function_prologue, [...]): Move updating of total_code_bytes from prologue to epilogue. * pa.c (pa_output_function_prologue, pa_output_function_epilogue): Move updating of total_code_bytes from prologue to epilogue. (get_last_nonnote_insn): New function. From-SVN: r62234 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 472e4ad77b74..1d72f77c09f7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-01-31 John David Anglin + + * pa.c (pa_output_function_prologue, pa_output_function_epilogue): Move + updating of total_code_bytes from prologue to epilogue. + (get_last_nonnote_insn): New function. + 2003-01-31 Jan Hubicka PR c/9506 diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 25d52f0e306a..18c7fbdb2789 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -1,6 +1,6 @@ /* Subroutines for insn-output.c for HPPA. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002 Free Software Foundation, Inc. + 2002, 2003 Free Software Foundation, Inc. Contributed by Tim Moore (moore@cs.utah.edu), based on sparc.c This file is part of GNU CC. @@ -81,6 +81,7 @@ static void remove_useless_addtr_insns PARAMS ((rtx, int)); static void store_reg PARAMS ((int, int, int)); static void load_reg PARAMS ((int, int, int)); static void set_reg_plus_d PARAMS ((int, int, int)); +static rtx get_last_nonnote_insn PARAMS ((void)); static void pa_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); static int pa_adjust_cost PARAMS ((rtx, rtx, rtx, int)); static int pa_adjust_priority PARAMS ((rtx, int)); @@ -3078,26 +3079,6 @@ pa_output_function_prologue (file, size) fputs ("\n\t.ENTRY\n", file); - /* If we're using GAS, SOM and not the portable runtime model, or if - we're using function sections, then we don't need to accumulate the - total number of code bytes in the translation unit. */ - if ((TARGET_GAS && TARGET_SOM && !TARGET_PORTABLE_RUNTIME) - || flag_function_sections) - total_code_bytes = 0; - else if (INSN_ADDRESSES_SET_P ()) - { - unsigned int old_total = total_code_bytes; - - total_code_bytes += INSN_ADDRESSES (INSN_UID (get_last_insn ())); - total_code_bytes += FUNCTION_BOUNDARY / BITS_PER_UNIT; - - /* Be prepared to handle overflows. */ - if (old_total > total_code_bytes) - total_code_bytes = -1; - } - else - total_code_bytes = -1; - remove_useless_addtr_insns (get_insns (), 0); } @@ -3352,6 +3333,24 @@ load_reg (reg, disp, base) } } +/* Return the last nonnote insn emitted in current sequence or current + function. This routine looks inside SEQUENCEs. */ + +static rtx +get_last_nonnote_insn () +{ + rtx insn = get_last_insn (); + + while (insn) + { + insn = previous_insn (insn); + if (insn == 0 || GET_CODE (insn) != NOTE) + break; + } + + return insn; +} + /* This function generates the assembly code for function exit. Args are as for output_function_prologue (). @@ -3365,6 +3364,7 @@ pa_output_function_epilogue (file, size) FILE *file; HOST_WIDE_INT size ATTRIBUTE_UNUSED; { + int last_address = 0; rtx insn = get_last_insn (); /* hppa_expand_epilogue does the dirty work now. We just need @@ -3387,9 +3387,36 @@ pa_output_function_epilogue (file, size) /* If insn is a CALL_INSN, then it must be a call to a volatile function (otherwise there would be epilogue insns). */ if (insn && GET_CODE (insn) == CALL_INSN) - fputs ("\tnop\n", file); + { + fputs ("\tnop\n", file); + last_address += 4; + } fputs ("\t.EXIT\n\t.PROCEND\n", file); + + /* Finally, update the total number of code bytes output so far. */ + if ((TARGET_PORTABLE_RUNTIME || !TARGET_GAS || !TARGET_SOM) + && !flag_function_sections) + { + if (INSN_ADDRESSES_SET_P ()) + { + unsigned long old_total = total_code_bytes; + + insn = get_last_nonnote_insn (); + last_address += INSN_ADDRESSES (INSN_UID (insn)); + if (INSN_P (insn)) + last_address += insn_default_length (insn); + + total_code_bytes += last_address; + total_code_bytes += FUNCTION_BOUNDARY / BITS_PER_UNIT; + + /* Be prepared to handle overflows. */ + if (old_total > total_code_bytes) + total_code_bytes = -1; + } + else + total_code_bytes = -1; + } } void