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: PATCH [i386 windows targets]: Disallow regparm for functions that probe stack


> On Sun, Oct 12, 2003 at 07:32:14PM -0400, Christopher Faylor wrote:
> >On Mon, Oct 13, 2003 at 07:29:12AM +1000, Danny Smith wrote:
> >>Hello, this fixes a bug on win32 targets that is related to PR 12209.
> >>
> >>The stack probing code (i386/cygwin.asm) that is emitted when a function
> >>requests allocation of more than CHECK_STACK_LIMIT bytes on the stack
> >>overwrites EAX register.  This causes functions with regparm attribute
> >>to return nonsense results, without warning.  eg:
> >
> >Hmm.  I could have sworn that this was fixed once already in a different
> >way.
> >
> >I'll have to do some email archaelogy.
> 
> I couldn't find any email about this but I do recall researching what
> needed to be done to fix it.

I believe that the conclusion is to use fastcall registers instead of
regparm registers for local functions.  I saw patch for this and it
fixes the bootstrap -funit-at-a-time problems, not sure whether it has
been approved.  I don't think any effort has been made to get regparm
attribute working.
> 
> It seems like it should be possible to detect the case where EAX is
> live, push it on the stack, and "pop" it after calling __chkstk/alloca.
> It won't be a true, "pop" of course because the stack will have been
> adjusted but it should still be possible to retrieve the register,
> regardless.

Adding push/pop pair is possible sollution, but it will result in large
runtime penalty, probably greater than the gain from using regparm, so
possibly completely ignoring it would be better sollution.

Honza
> 
> I'll look into doing this but it will require some digging on my part.
> If anyone has a suggestion to point me in the right direction, I'd
> appreciate it.
> 
> cgf


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