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: [4/7] v7: Update DWARF2


On Sat, Jul 05, 2008 at 09:50:55PM -0700, H.J. Lu wrote:
> On Fri, Jul 04, 2008 at 10:09:22PM -0400, Jason Merrill wrote:
> > This approach looks a lot better, thanks.
> >
> > In the non-DRAP case, I think rule 19 could use an assert so that we  
> > give up if we try to save FP to the stack.
> 
> Did you mean rule 18?
> 
>  Rule 18:
>  (set (mem ({pre_inc, pre_dec} sp)) fp)
>   constraints: fde->stack_realign == 1
>                && cfa.reg != fp  (means use drap)
>   effects: cfa_store.offset = 0
> 
> We can add assert of cfa.reg != fp.
> 
> >
> > In the DRAP case, it looks like the current patch doesn't do anything to  
> > recognize the "mov %esp,%ebp" instruction, so since cfa.reg isn't SP  
> > anymore the existing code will treat it as saving SP in FP.  I think we  
> > want to notice this case and just assert that after stack alignment, we  
> > copy SP into FP in order to match the assumption in reg_save.
> >
> 
> I am working on a patch.
> 
> 

I am testing this patch on stack branch. I will check it in
if it passes on Linux/ia32, Linux/ia64 and Linux/x86-64.

Thanks.


H.J.
---
2008-07-05  H.J. Lu  <hongjiu.lu@intel.com>

	* dwarf2out.c (dw_fde_node): Add fp_has_aligned_sp.
	(dwarf2out_frame_debug_expr): Check fp_has_aligned_sp instead
	of stack_realign for rules 19 and 20.  Set fp_has_aligned_sp.
	Assert cfa.reg != FP for rule 18.  Simplify rule 19.

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 3154)
+++ dwarf2out.c	(working copy)
@@ -249,6 +249,8 @@ typedef struct dw_fde_struct GTY(())
   unsigned uses_eh_lsda : 1;
   /* Whether we did stack realign in this call frame.  */
   unsigned stack_realign : 1;
+  /* Whether FP has aligned SP in this call frame.  */
+  unsigned fp_has_aligned_sp : 1;
 }
 dw_fde_node;
 
@@ -1682,7 +1684,7 @@ dwarf2out_frame_debug_expr (rtx expr, co
 
   if (GET_CODE (src) == REG
       && fde
-      && fde->stack_realign
+      && fde->fp_has_aligned_sp
       && ((fde->drap_reg != INVALID_REGNUM
 	   && fde->drap_reg == REGNO (src))
 	  || (GET_CODE (dest) == REG
@@ -1731,7 +1733,15 @@ dwarf2out_frame_debug_expr (rtx expr, co
 			  /* For the SPARC and its register window.  */
 			  || (DWARF_FRAME_REGNUM (REGNO (src))
 			      == DWARF_FRAME_RETURN_COLUMN));
-	      queue_reg_save (label, src, dest, 0);
+	      if (fde
+		  && fde->stack_realign
+		  && cfa.reg != REGNO (dest)
+		  && cfa.reg != REGNO (src)
+		  && REGNO (dest) == HARD_FRAME_POINTER_REGNUM
+		  && REGNO (src) == STACK_POINTER_REGNUM)
+		fde->fp_has_aligned_sp = 1;
+	      else
+		queue_reg_save (label, src, dest, 0);
 	    }
 	  break;
 
@@ -1927,9 +1937,11 @@ dwarf2out_frame_debug_expr (rtx expr, co
 	     regiser.  */
           if (fde
               && fde->stack_realign
-              && cfa.reg != HARD_FRAME_POINTER_REGNUM
               && src == hard_frame_pointer_rtx)
-            cfa_store.offset = 0;
+	    {
+	      gcc_assert (cfa.reg != HARD_FRAME_POINTER_REGNUM);
+	      cfa_store.offset = 0;
+	    }
 
 	  if (cfa.reg == STACK_POINTER_REGNUM)
 	    cfa.offset = cfa_store.offset;
@@ -1996,6 +2008,7 @@ dwarf2out_frame_debug_expr (rtx expr, co
 	  && (unsigned) REGNO (src) == cfa.reg)
 	{
 	  /* We're storing the current CFA reg into the stack.  */
+	  dw_cfa_location *cfa_p;
 
 	  if (cfa.offset == 0)
 	    {
@@ -2006,30 +2019,27 @@ dwarf2out_frame_debug_expr (rtx expr, co
 		 result of this expression equals to the original CFA
 		 value.  */
               if (fde
-                  && fde->stack_realign
+		  && fde->fp_has_aligned_sp
                   && cfa.indirect == 0
                   && cfa.reg != HARD_FRAME_POINTER_REGNUM)
                 {
 		  dw_cfa_location cfa_exp;
 
+		  cfa_p = &cfa_exp;
 		  cfa_exp.indirect = 1;
 		  cfa_exp.reg = HARD_FRAME_POINTER_REGNUM;
 		  cfa_exp.base_offset = offset;
 		  cfa_exp.offset = 0;
 
 		  fde->drap_reg = cfa.reg;
-
-		  def_cfa_1 (label, &cfa_exp);
-
-		  queue_reg_save (label, stack_pointer_rtx, NULL_RTX,
-				  offset);
-                  break;
                 }
+	      else
+		cfa_p = &cfa;
 
 	      /* If the source register is exactly the CFA, assume
 		 we're saving SP like any other register; this happens
 		 on the ARM.  */
-	      def_cfa_1 (label, &cfa);
+	      def_cfa_1 (label, cfa_p);
 	      queue_reg_save (label, stack_pointer_rtx, NULL_RTX, offset);
 	      break;
 	    }


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