------- Comment #13 from dave at hiauly1 dot hia dot nrc dot ca  2007-06-15 
20:05 -------
Subject: Re:  [4.3 Regression] Bootstrap failure in stage1 on hppa*-*-*

> > We need to know that the return pointer (r2) is not used and that
> > the function is a leaf function (i.e., that the incoming value in
> > r2 is unchanged).  Calls clobber r2.
> > 
> > Dave
> 
> Sounds like the following patch would work:
> 
> diff -r 149399c845b5 gcc/config/pa/pa.c
> --- a/gcc/config/pa/pa.c        Tue Jun 12 15:49:27 2007 -0700
> +++ b/gcc/config/pa/pa.c        Wed Jun 13 18:37:17 2007 -0700
> @@ -4415,7 +4415,7 @@ hppa_can_use_return_insn_p (void)
>  {
>    return (reload_completed
>           && (compute_frame_size (get_frame_size (), 0) ? 0 : 1)
> -         && df_hard_reg_used_count (2) == 1
> +         && DF_REG_DEF_COUNT (2) == 0
>           && ! frame_pointer_needed);
>  }
> 
> 
> This essentially checks if r2 is ever written within the function
> (including the calls since r2 is included in the CALL_USED_REGS).

Ok, I've found the problem.  The code that outputs trivial returns
in function.c has changed and just outputs the return when optimize
and HAVE_RETURN are true.  As a result, we are generating trivial
returns in cases when we shouldn't.

I think the solution is to rename the "return" pattern and let
the pa epilogue expander control the show.  This is what I currently
have:

Index: config/pa/pa.md
===================================================================
--- config/pa/pa.md     (revision 125747)
+++ config/pa/pa.md     (working copy)
@@ -7345,11 +7345,11 @@

 ;; This can only be used in a leaf function, so we do
 ;; not need to use the PIC register when generating PIC code.
-(define_insn "return"
+(define_insn "trivial_return"
   [(return)
    (use (reg:SI 2))
    (const_int 0)]
-  "hppa_can_use_return_insn_p ()"
+  ""
   "*
 {
   if (TARGET_PA_20)
@@ -7409,7 +7409,7 @@
   /* Try to use the trivial return first.  Else use the full
      epilogue.  */
   if (hppa_can_use_return_insn_p ())
-    emit_jump_insn (gen_return ());
+    emit_jump_insn (gen_trivial_return ());
   else
     {
       rtx x;
Index: config/pa/pa.c
===================================================================
--- config/pa/pa.c      (revision 125747)
+++ config/pa/pa.c      (working copy)
@@ -47,6 +47,7 @@
 #include "tm_p.h"
 #include "target.h"
 #include "target-def.h"
+#include "df.h"

 /* Return nonzero if there is a bypass for the output of 
    OUT_INSN and the fp store IN_INSN.  */
@@ -4413,9 +4414,9 @@
 hppa_can_use_return_insn_p (void)
 {
   return (reload_completed
-         && (compute_frame_size (get_frame_size (), 0) ? 0 : 1)
-         && ! df_regs_ever_live_p (2)
-         && ! frame_pointer_needed);
+         && DF_REG_DEF_COUNT (2) == 0
+         && !frame_pointer_needed
+         && (compute_frame_size (get_frame_size (), 0) ? 0 : 1));
 }

 void

The code still seems to be generating trivial returns.  Full bootstrap
is in progress.

If this works, there's probably some minor cleanups that can be made.
hppa_can_use_return_insn_p() is only called by the epilogue expander
and it may be possible to move it there.  I also think we can do away
with one of trivial_return and return_internal in pa.md.

Dave


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32296

Reply via email to