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]

RFA: fix up dwarf2 stack frame information for xstormy16


Hi Geoff,

  Sanyo reported that the dwarf2 stack frame information generated by
  gcc for the xstormy16 port was incorrect.  The problem was that in
  the prologue, if the stack pointer was copied into the hard frame
  pointer, the insn was marked as frame-creation insn.  This was
  despite the fact that further adjustments to the stack pointer were
  also marked as frame-creating insns.  Then in the epilogue if the
  hard frame pointer was copied back into the stack pointer, the insn
  was not being labelled as frame-adjustment insn.

  Here is a patch developed by Andrew Macleod that provides one
  solution to the problem.  It simply chooses to leave the stack frame
  be based entirely on the stack pointer, and it ignores any copies
  to/from the hard frame pointer.  This is the simplest solution and
  Sanyo have reported that the dwarf2 debug information generated by a
  patched gcc is compatible with their own debugger.
  
  May I apply this patch to the mainline gcc sources please ?

Cheers
        Nick
        
2003-05-15  Andrew Macleod  <amacleod@redhat.com>

	* config/stormy16/stormy16.c (xstormy16_expand_prologue): Do
	not mark assignments to the hard frame pointer as being stack
	frame related.
	(xstormy16_expand_epilogue): Mark adjustments to the stack
	pointer as being stack frame related.
	
Index: gcc/config/stormy16/stormy16.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/stormy16/stormy16.c,v
retrieving revision 1.41
diff -c -3 -p -w -r1.41 stormy16.c
*** gcc/config/stormy16/stormy16.c	9 May 2003 00:00:44 -0000	1.41
--- gcc/config/stormy16/stormy16.c	15 May 2003 18:10:03 -0000
*************** xstormy16_expand_prologue ()
*** 1127,1136 ****
    /* It's just possible that the SP here might be what we need for
       the new FP...  */
    if (frame_pointer_needed && layout.sp_minus_fp == layout.locals_size)
!     {
!       insn = emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx);
!       RTX_FRAME_RELATED_P (insn) = 1;
!     }
  
    /* Allocate space for local variables.  */
    if (layout.locals_size)
--- 1127,1133 ----
    /* It's just possible that the SP here might be what we need for
       the new FP...  */
    if (frame_pointer_needed && layout.sp_minus_fp == layout.locals_size)
!     emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx);
  
    /* Allocate space for local variables.  */
    if (layout.locals_size)
*************** xstormy16_expand_prologue ()
*** 1144,1157 ****
    if (frame_pointer_needed && layout.sp_minus_fp != layout.locals_size)
      {
        insn = emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx);
!       RTX_FRAME_RELATED_P (insn) = 1;
        if (layout.sp_minus_fp)
! 	{
! 	  insn = emit_addhi3_postreload (hard_frame_pointer_rtx,
  					 hard_frame_pointer_rtx,
  					 GEN_INT (-layout.sp_minus_fp));
- 	  RTX_FRAME_RELATED_P (insn) = 1;
- 	}
      }
  }
  
--- 1141,1151 ----
    if (frame_pointer_needed && layout.sp_minus_fp != layout.locals_size)
      {
        insn = emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx);
! 
        if (layout.sp_minus_fp)
! 	emit_addhi3_postreload (hard_frame_pointer_rtx,
  				hard_frame_pointer_rtx,
  				GEN_INT (-layout.sp_minus_fp));
      }
  }
  
*************** void
*** 1175,1181 ****
  xstormy16_expand_epilogue ()
  {
    struct xstormy16_stack_layout layout;
!   rtx mem_pop_rtx;
    int regno;
    const int ifun = xstormy16_interrupt_function_p ();
    
--- 1169,1175 ----
  xstormy16_expand_epilogue ()
  {
    struct xstormy16_stack_layout layout;
!   rtx mem_pop_rtx, insn;
    int regno;
    const int ifun = xstormy16_interrupt_function_p ();
    
*************** xstormy16_expand_epilogue ()
*** 1190,1208 ****
        if (frame_pointer_needed && layout.sp_minus_fp == layout.locals_size)
  	emit_move_insn (stack_pointer_rtx, hard_frame_pointer_rtx);
        else
! 	emit_addhi3_postreload (stack_pointer_rtx, stack_pointer_rtx,
  				GEN_INT (- layout.locals_size));
      }
  
    /* Restore any call-saved registers.  */
    for (regno = FIRST_PSEUDO_REGISTER - 1; regno >= 0; regno--)
      if (REG_NEEDS_SAVE (regno, ifun))
!       emit_move_insn (gen_rtx_REG (HImode, regno), mem_pop_rtx);
    
    /* Pop the stack for the stdarg save area.  */
    if (layout.stdarg_save_size)
!     emit_addhi3_postreload (stack_pointer_rtx, stack_pointer_rtx,
  			    GEN_INT (- layout.stdarg_save_size));
  
    /* Return.  */
    if (ifun)
--- 1184,1219 ----
        if (frame_pointer_needed && layout.sp_minus_fp == layout.locals_size)
  	emit_move_insn (stack_pointer_rtx, hard_frame_pointer_rtx);
        else
!         {
! 	  insn = emit_addhi3_postreload (stack_pointer_rtx, stack_pointer_rtx,
  					 GEN_INT (- layout.locals_size));
+ 	  RTX_FRAME_RELATED_P (insn) = 1;
+ 	}
      }
  
    /* Restore any call-saved registers.  */
    for (regno = FIRST_PSEUDO_REGISTER - 1; regno >= 0; regno--)
      if (REG_NEEDS_SAVE (regno, ifun))
!       {
!         rtx dwarf;
! 
! 	insn = emit_move_insn (gen_rtx_REG (HImode, regno), mem_pop_rtx);
! 	RTX_FRAME_RELATED_P (insn) = 1;
! 	dwarf = gen_rtx_SET (Pmode, stack_pointer_rtx,
! 			     plus_constant (stack_pointer_rtx,
! 					    -GET_MODE_SIZE (Pmode)));
! 	REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
! 					      dwarf,
! 					      REG_NOTES (insn));
!       }
    
    /* Pop the stack for the stdarg save area.  */
    if (layout.stdarg_save_size)
!     {
!       insn = emit_addhi3_postreload (stack_pointer_rtx, stack_pointer_rtx,
  				     GEN_INT (- layout.stdarg_save_size));
+       RTX_FRAME_RELATED_P (insn) = 1;
+     }
  
    /* Return.  */
    if (ifun)


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