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]

return value changes


[this patch is needed to make "sibcall tweek" effective.  It appears that
I forgot to send it, so here it is]

Hi,
the sibcalls optimization fails in many cases, because it tests the return
register for equality.  In function.c the didle_return_value generates it's own
return values, so the gen_rtx_reg is called multiple times and multiple
different instances of return register exist.

This patch avoids it by amning the second copy of return register generation
code.  Even if we decide to change situation above differently, it is IMO good
cleanup.

Honza

Wed Jun  6 15:03:10 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* function.c (diddle_return_value): Kill code to determine
	return value before expand_function_end.
	(expand_function_end): Delay call to clobber_return_register
	after fucntion return value is computed.

Index: function.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.c,v
retrieving revision 1.273
diff -c -3 -p -r1.273 function.c
*** function.c	2001/06/05 06:51:02	1.273
--- function.c	2001/06/06 12:56:58
*************** diddle_return_value (doit, arg)
*** 6542,6578 ****
       void *arg;
  {
    rtx outgoing = current_function_return_rtx;
-   int pcc;
  
    if (! outgoing)
      return;
  
-   pcc = (current_function_returns_struct
- 	 || current_function_returns_pcc_struct);
- 
-   if ((GET_CODE (outgoing) == REG
-        && REGNO (outgoing) >= FIRST_PSEUDO_REGISTER)
-       || pcc)
-     {
-       tree type = TREE_TYPE (DECL_RESULT (current_function_decl));
- 
-       /* A PCC-style return returns a pointer to the memory in which
- 	 the structure is stored.  */
-       if (pcc)
- 	type = build_pointer_type (type);
- 
- #ifdef FUNCTION_OUTGOING_VALUE
-       outgoing = FUNCTION_OUTGOING_VALUE (type, current_function_decl);
- #else
-       outgoing = FUNCTION_VALUE (type, current_function_decl);
- #endif
-       /* If this is a BLKmode structure being returned in registers, then use
- 	 the mode computed in expand_return.  */
-       if (GET_MODE (outgoing) == BLKmode)
- 	PUT_MODE (outgoing, GET_MODE (current_function_return_rtx));
-       REG_FUNCTION_VALUE_P (outgoing) = 1;
-     }
- 
    if (GET_CODE (outgoing) == REG)
      (*doit) (outgoing, arg);
    else if (GET_CODE (outgoing) == PARALLEL)
--- 6542,6551 ----
*************** expand_function_end (filename, line, end
*** 6630,6635 ****
--- 6616,6622 ----
       int end_bindings;
  {
    tree link;
+   rtx clobber_after;
  
  #ifdef TRAMPOLINE_TEMPLATE
    static rtx initial_trampoline;
*************** expand_function_end (filename, line, end
*** 6776,6792 ****
       registers so that they are not propogated live to the rest of
       the function.  This can only happen with functions that drop
       through; if there had been a return statement, there would
!      have either been a return rtx, or a jump to the return label.  */
!   {
!     rtx before, after;
!     
!     before = get_last_insn ();
!     clobber_return_register ();
!     after = get_last_insn ();
!     
!     if (before != after)
!       cfun->x_clobber_return_insn = after;
!   }
  
    /* Output the label for the actual return from the function,
       if one is expected.  This happens either because a function epilogue
--- 6763,6773 ----
       registers so that they are not propogated live to the rest of
       the function.  This can only happen with functions that drop
       through; if there had been a return statement, there would
!      have either been a return rtx, or a jump to the return label.
! 
!      We delay actual code generation after the current_function_value_rtx
!      is computed.  */
!   clobber_after = get_last_insn ();
  
    /* Output the label for the actual return from the function,
       if one is expected.  This happens either because a function epilogue
*************** expand_function_end (filename, line, end
*** 6934,6939 ****
--- 6915,6935 ----
    /* If this is an implementation of throw, do what's necessary to
       communicate between __builtin_eh_return and the epilogue.  */
    expand_eh_return ();
+ 
+   /* Emit the actual code to clobber return register.  */
+   {
+     rtx seq, after;
+     
+     start_sequence ();
+     clobber_return_register ();
+     seq = gen_sequence ();
+     end_sequence ();
+ 
+     after = emit_insn_after (seq, clobber_after);
+     
+     if (clobber_after != after)
+       cfun->x_clobber_return_insn = after;
+   }
  
    /* ??? This should no longer be necessary since stupid is no longer with
       us, but there are some parts of the compiler (eg reload_combine, and


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