[patch/mips] Don't allocate stack space when it wasn't used.

Andrew Cagney ac131313@cygnus.com
Fri Jun 23 04:09:00 GMT 2000


FYI,

Another edge condition in the inferior function call code.  Don't start
allocating stack space until it is being used.

	Andrew
Fri Jun 23 20:47:03 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* mips-tdep.c (mips_push_arguments): Use the variable stack_used_p
 	to determine if any arguments were written to the stack.  Do not
 	rely on NUMARG>=8.


Index: mips-tdep.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/mips-tdep.c,v
retrieving revision 1.229
diff -p -r1.229 mips-tdep.c
*** mips-tdep.c	2000/06/23 07:42:50	1.229
--- mips-tdep.c	2000/06/23 10:52:24
*************** mips_push_arguments (nargs, args, sp, st
*** 2284,2301 ****
               register are only written to memory. */
  	  while (len > 0)
  	    {
  	      int partial_len = len < MIPS_SAVED_REGSIZE ? len : MIPS_SAVED_REGSIZE;
  
  	      if (argreg > MIPS_LAST_ARG_REGNUM
  		  || odd_sized_struct
  		  || fp_register_arg_p (typecode, arg_type))
  		{
- 		  /* Write this portion of the argument to the stack.  */
  		  /* Should shorter than int integer values be
  		     promoted to int before being stored? */
- 
  		  int longword_offset = 0;
  		  CORE_ADDR addr;
  		  if (TARGET_BYTE_ORDER == BIG_ENDIAN)
  		    {
  		      if (MIPS_STACK_ARGSIZE == 8 &&
--- 2343,2362 ----
               register are only written to memory. */
  	  while (len > 0)
  	    {
+ 	      /* Rememer if the argument was written to the stack. */
+ 	      int stack_used_p = 0;
  	      int partial_len = len < MIPS_SAVED_REGSIZE ? len : MIPS_SAVED_REGSIZE;
  
+ 	      /* Write this portion of the argument to the stack.  */
  	      if (argreg > MIPS_LAST_ARG_REGNUM
  		  || odd_sized_struct
  		  || fp_register_arg_p (typecode, arg_type))
  		{
  		  /* Should shorter than int integer values be
  		     promoted to int before being stored? */
  		  int longword_offset = 0;
  		  CORE_ADDR addr;
+ 		  stack_used_p = 1;
  		  if (TARGET_BYTE_ORDER == BIG_ENDIAN)
  		    {
  		      if (MIPS_STACK_ARGSIZE == 8 &&
*************** mips_push_arguments (nargs, args, sp, st
*** 2334,2339 ****
--- 2395,2402 ----
  	      /* Note!!! This is NOT an else clause.  Odd sized
  	         structs may go thru BOTH paths.  Floating point
  	         arguments will not. */
+ 	      /* Write this portion of the argument to a general
+                  purpose register. */
  	      if (argreg <= MIPS_LAST_ARG_REGNUM
  		  && !fp_register_arg_p (typecode, arg_type))
  		{
*************** mips_push_arguments (nargs, args, sp, st
*** 2377,2393 ****
  	      len -= partial_len;
  	      val += partial_len;
  
! 	      /* The offset onto the stack at which we will start
! 	         copying parameters (after the registers are used up) 
! 	         begins at (4 * MIPS_REGSIZE) in the old ABI.  This 
! 	         leaves room for the "home" area for register parameters.
! 
! 	         In the new EABI (and the NABI32), the 8 register parameters 
! 	         do not have "home" stack space reserved for them, so the
! 	         stack offset does not get incremented until after
! 	         we have used up the 8 parameter registers.  */
  
! 	      if (MIPS_REGS_HAVE_HOME_P || argnum >= 8)
  		stack_offset += ROUND_UP (partial_len, MIPS_STACK_ARGSIZE);
  	    }
  	}
--- 2440,2457 ----
  	      len -= partial_len;
  	      val += partial_len;
  
! 	      /* Compute the the offset into the stack at which we
! 		 will copy the next parameter.
  
! 		 In older ABIs, the caller reserved space for
! 		 registers that contained arguments.  This was loosely
! 		 refered to as their "home".  Consequently, space is
! 		 always allocated.
! 
! 	         In the new EABI (and the NABI32), the stack_offset
! 	         only needs to be adjusted when it has been used.. */
! 
! 	      if (MIPS_REGS_HAVE_HOME_P || stack_used_p)
  		stack_offset += ROUND_UP (partial_len, MIPS_STACK_ARGSIZE);
  	    }
  	}


More information about the Gdb-patches mailing list