This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Mindless ABI adherence
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Subject: Re: Mindless ABI adherence
- From: Linus Torvalds <torvalds at transmeta dot com>
- Date: Fri, 19 Oct 2001 10:28:01 -0700 (PDT)
- cc: <gcc-bugs at gcc dot gnu dot org>
On Fri, 19 Oct 2001, Florian Weimer wrote:
>
> > add:
> > addl %edx,%eax
> > ret;
> >
> > stub$add:
> > movl 4(%esp),eax
> > movl 8(%esp),edx
> > jmp add;
>
> I think you could even avoid the jump, just by reordering the code.
In this case, yes. However, it was meant to be an example of:
- not needing a stub at all when not needed (ie generating it later only
if required - without having any global analysis)
- the generic case, which can NOT be done with a re-order, because the
calling convention change might require saving/restoring of registers
(this doesn't happen with the x86 regcall optimization, but it could
happen with other calling convention changes: return values in
registers vs stack etc)
But my example was obviously too limited to show what the stub approach
_really_ can do.
(NOTE! The whole point of a stub approach is to not have to use it. If the
stub ends up being common, then that just means that the "optimization"
was a bad one. So the common case _should_ be that the stub doesn't exist
at all, or if it exists it should be at least dynamically the rare case.
And I realize that you cannot guarantee _that_ without a global pass, but
in many cases simple local heuristics are likely to be good for 99% of all
cases)
Linus