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]

Re: [PATCH] Jump bypassing and improved cprop (take 2)


> > 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  <dave@hiauly1.hia.nrc.ca>

	* 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.  */


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