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]

[PATCH] On targets without setup for cfa_base_rtx don't try to replace sp/hfp (PR target/45250, take 2)


On Wed, Oct 27, 2010 at 03:03:59PM -0400, Richard Henderson wrote:
> On 10/27/2010 02:37 PM, Jakub Jelinek wrote:
> > I think we can drop !MAY_HAVE_DEBUG_STMTS || check here, I believe we
> > can without it generate wrong debug info for -fno-var-tracking-assignments,
> > on the other side that's what the code was doing before ...
> 
> Ok, let's do that then.
> 
> >> Also, it seems to me that compute_cfa_pointer is wrong in
> >> that it should not effectively re-compute cfa_base_rtx, but
> >> should use that existing decision.
> > 
> > You mean using cfa_base_rtx instead of {frame,arg}_pointer_rtx
> > or also just remembering the adjustment bias in vta_init_cfa_base
> > in HWI static global and using it in compute_cfa_pointer?
> > Just the former would still mean we'd need to have #ifdef...
> 
> Then let's use the later so that we consolidate the ifdef
> into a single place.

Ok, here it is.  Bootstrapped/regtested on x86_64-linux and i686-linux,
verified cc1plus identical there (minus var-tracking.o of course):

2010-10-27  Jakub Jelinek  <jakub@redhat.com>

	PR target/45250
	* var-tracking.c (cfa_base_rtx): Move definition earlier in the file.
	(cfa_base_offset): New variable.
	(compute_cfa_pointer): Use cfa_base_rtx and cfa_base_offset.
	(adjust_mems): Don't do any sp or hfp replacements if cfa_base_rtx
	is NULL.
	(vt_init_cfa_base): Initialize cfa_base_offset.

--- gcc/var-tracking.c.jj	2010-10-26 05:42:51.483342434 +0200
+++ gcc/var-tracking.c	2010-10-27 21:18:10.516655190 +0200
@@ -408,7 +408,6 @@ static void stack_adjust_offset_pre_post
 static void insn_stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
 					       HOST_WIDE_INT *);
 static bool vt_stack_adjustments (void);
-static rtx compute_cfa_pointer (HOST_WIDE_INT);
 static hashval_t variable_htab_hash (const void *);
 static int variable_htab_eq (const void *, const void *);
 static void variable_htab_free (void *);
@@ -695,22 +694,17 @@ vt_stack_adjustments (void)
   return true;
 }
 
+/* arg_pointer_rtx resp. frame_pointer_rtx if stack_pointer_rtx or
+   hard_frame_pointer_rtx is being mapped to it and offset for it.  */
+static rtx cfa_base_rtx;
+static HOST_WIDE_INT cfa_base_offset;
+
 /* Compute a CFA-based value for the stack pointer.  */
 
-static rtx
+static inline rtx
 compute_cfa_pointer (HOST_WIDE_INT adjustment)
 {
-  rtx cfa;
-
-#ifdef FRAME_POINTER_CFA_OFFSET
-  adjustment -= FRAME_POINTER_CFA_OFFSET (current_function_decl);
-  cfa = plus_constant (frame_pointer_rtx, adjustment);
-#else
-  adjustment -= ARG_POINTER_CFA_OFFSET (current_function_decl);
-  cfa = plus_constant (arg_pointer_rtx, adjustment);
-#endif
-
-  return cfa;
+  return plus_constant (cfa_base_rtx, adjustment + cfa_base_offset);
 }
 
 /* Adjustment for hard_frame_pointer_rtx to cfa base reg,
@@ -803,11 +797,13 @@ adjust_mems (rtx loc, const_rtx old_rtx,
       if (amd->mem_mode == VOIDmode && amd->store)
 	return loc;
       if (loc == stack_pointer_rtx
-	  && !frame_pointer_needed)
+	  && !frame_pointer_needed
+	  && cfa_base_rtx)
 	return compute_cfa_pointer (amd->stack_adjust);
       else if (loc == hard_frame_pointer_rtx
 	       && frame_pointer_needed
-	       && hard_frame_pointer_adjustment != -1)
+	       && hard_frame_pointer_adjustment != -1
+	       && cfa_base_rtx)
 	return compute_cfa_pointer (hard_frame_pointer_adjustment);
       return loc;
     case MEM:
@@ -4757,10 +4753,6 @@ var_lowpart (enum machine_mode mode, rtx
   return gen_rtx_REG_offset (loc, mode, regno, offset);
 }
 
-/* arg_pointer_rtx resp. frame_pointer_rtx if stack_pointer_rtx or
-   hard_frame_pointer_rtx is being mapped to it.  */
-static rtx cfa_base_rtx;
-
 /* Carry information about uses and stores while walking rtx.  */
 
 struct count_use_info
@@ -8213,8 +8205,10 @@ vt_init_cfa_base (void)
 
 #ifdef FRAME_POINTER_CFA_OFFSET
   cfa_base_rtx = frame_pointer_rtx;
+  cfa_base_offset = -FRAME_POINTER_CFA_OFFSET (current_function_decl);
 #else
   cfa_base_rtx = arg_pointer_rtx;
+  cfa_base_offset = -ARG_POINTER_CFA_OFFSET (current_function_decl);
 #endif
   if (cfa_base_rtx == hard_frame_pointer_rtx
       || !fixed_regs[REGNO (cfa_base_rtx)])


	Jakub


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