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: Fix a pretend_args goof in tail calling


On Mon, May 02, 2005 at 08:31:51AM -0700, Mark Mitchell wrote:
> Daniel Jacobowitz wrote:
> 
> >No, that's not right.  This patch was for a problem found on ARM
> >targets, and it is contiguous.  The problem is that the space is
> >"pretend".  It's allocated by the called function, not by the caller,
> >so it must be cleaned up before we leave this function or the stack
> >pointer will be corrupted.  Therefore it can not be used for outgoing
> >arguments.
> 
> Oh; the problem would be that when the eventual return occurred from the 
> sibcalled function, we'd have more stack space allocated than the 
> original caller expected.  So, if the original caller pops the 
> arguments, it won't pop enough.  If the ABI had the callee pop the args, 
> then things would work OK, I guess, because the sibcalled function would 
> pop all the space.  Is that right?

Basically.  In practice I think that GCC correctly restored the stack,
but then wrote more bytes of arguments than there were bytes of stack
frame, clobbering the parent's saved registers.

> >Therefore the existing comment is right.  It could be extended to:
> >       /* If this function requires more stack slots than the current
> >	  function, we cannot change it into a sibling call.
> >	  current_function_pretend_args_size is not part of the
> >	  stack allocated by our caller.  */
> >
> >OK with that change instead?
> 
> OK.

Thanks, will commit for HEAD.  Is this appropriate for 4.0?

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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