Another bug exposed by PA64

Jeffrey A Law law@cygnus.com
Sat Jul 31 03:30:00 GMT 1999


When PA64 support is added to the compiler STARTING_FRAME_OFFSET varies
based on whether or not we're generating 64bit code.

compute_frame_size and hppa_expand_prologue used the magic constant "8"
instead of using STARTING_FRAME_OFFSET.  It is safe to assume this caused
some unpleasant problems once the value for STARTING_FRAME_OFFSET varied :(

	* pa.c (compute_frame_size): Use STARTINg_FRAME_OFFSET instead
	of depending on a magic constant value.  Update comments.
	(hppa_expand_prologue): Similarly.
	
Index: pa.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/pa/pa.c,v
retrieving revision 1.50
diff -c -3 -p -r1.50 pa.c
*** pa.c	1999/07/30 09:01:20	1.50
--- pa.c	1999/07/31 10:25:53
*************** compute_frame_size (size, fregs_live)
*** 2593,2602 ****
    extern int current_function_outgoing_args_size;
    int i, fsize;
  
!   /* 8 is space for frame pointer + filler. If any frame is allocated
!      we need to add this in because of STARTING_FRAME_OFFSET. */
!   fsize = size + (size || frame_pointer_needed ? 8 : 0);
  
    for (i = 18; i >= 3; i--)
      if (regs_ever_live[i])
        fsize += UNITS_PER_WORD;
--- 2593,2606 ----
    extern int current_function_outgoing_args_size;
    int i, fsize;
  
!   /* Space for frame pointer + filler. If any frame is allocated
!      we need to add this in because of STARTING_FRAME_OFFSET.
  
+      Similar code also appears in hppa_expand_prologue.  Change both
+      of them at the same time.  */
+   fsize = size + (size || frame_pointer_needed ? STARTING_FRAME_OFFSET : 0);
+ 
+   /* Account for space used by the callee general register saves.  */
    for (i = 18; i >= 3; i--)
      if (regs_ever_live[i])
        fsize += UNITS_PER_WORD;
*************** compute_frame_size (size, fregs_live)
*** 2604,2619 ****
--- 2608,2632 ----
    /* Round the stack.  */
    fsize = (fsize + 7) & ~7;
  
+   /* Account for space used by the callee floating point register saves.  */
    for (i = 66; i >= 48; i -= 2)
      if (regs_ever_live[i] || regs_ever_live[i + 1])
        {
  	if (fregs_live)
  	  *fregs_live = 1;
  
+ 	/* We always save both halves of the FP register, so always
+ 	   increment the frame size by 8 bytes.  */
  	fsize += 8;
        }
  
+   /* The various ABIs include space for the outgoing parameters in the
+      size of the current function's stack frame.  */
    fsize += current_function_outgoing_args_size;
+ 
+   /* Allocate space for the fixed frame marker.  This space must be
+      allocated for any function that makes calls or otherwise allocates
+      stack space.  */
    if (! leaf_function_p () || fsize)
      fsize += 32;
    return (fsize + STACK_BOUNDARY - 1) & ~(STACK_BOUNDARY - 1);
*************** hppa_expand_prologue()
*** 2703,2709 ****
    gr_saved = 0;
    fr_saved = 0;
    save_fregs = 0;
!   local_fsize =  size + (size || frame_pointer_needed ? 8 : 0);
    actual_fsize = compute_frame_size (size, &save_fregs);
  
    /* Compute a few things we will use often.  */
--- 2716,2730 ----
    gr_saved = 0;
    fr_saved = 0;
    save_fregs = 0;
! 
!   /* Allocate space for frame pointer + filler. If any frame is allocated
!      we need to add this in because of STARTING_FRAME_OFFSET.
! 
!      Similar code also appears in compute_frame_size.  Change both
!      of them at the same time.  */
!   local_fsize = size + (size || frame_pointer_needed
! 			? STARTING_FRAME_OFFSET : 0);
! 
    actual_fsize = compute_frame_size (size, &save_fregs);
  
    /* Compute a few things we will use often.  */





More information about the Gcc-patches mailing list