From: Fergus Henderson <fjh@cs.mu.oz.au>
To: Richard Henderson <rth@redhat.com>
Cc: gcc@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: forcing tail/sibling call optimization
Date: Wed, 03 Jan 2001 16:36:00 -0000 [thread overview]
Message-ID: <20010104113549.A25503@hg.cs.mu.oz.au> (raw)
In-Reply-To: <20010103161149.A18293@redhat.com>
On 03-Jan-2001, Richard Henderson <rth@redhat.com> wrote:
> On Thu, Jan 04, 2001 at 10:53:15AM +1100, Fergus Henderson wrote:
> > On 03-Jan-2001, Richard Henderson <rth@redhat.com> wrote:
> > > if the front end didn't really care if the tail
> > > call didn't happen, it could query the target before setting the bit.
> >
> > How can it query the target? The query needed is not just "does this
> > target support tail calls", it is "does this target support *this*
> > tail call", and the answer can depend on lots of stuff that the front
> > end doesn't want to know about.
>
> See FUNCTION_OK_FOR_SIBCALL; cfun->decl must be valid during the
> query so that the target can compare return types (see the x86
> version for why this matters).
But that's just one of the many ways in which sibling call optimization
can fail. There's lots of other ways it can fail in expand_call()
[see below]. Note that quite a few of these ways are just limitations
of the current implementation, not inherent requirements. It seems
like a bad idea to duplicate that logic in the language front-end.
P.S.
For completeness here a list of some of the other ways it can
fail in expand_call().
| || args_size.var)
...
| #ifdef HAVE_sibcall_epilogue
| !HAVE_sibcall_epilogue
| #else
| 1
| #endif
...
| /* Doing sibling call optimization needs some work, since
| structure_value_addr can be allocated on the stack.
| It does not seem worth the effort since few optimizable
| sibling calls will return a structure. */
| || structure_value_addr != NULL_RTX
| /* If the register holding the address is a callee saved
| register, then we lose. We have no way to prevent that,
| so we only allow calls to named functions. */
| /* ??? This could be done by having the insn constraints
| use a register class that is all call-clobbered. Any
| reload insns generated to fix things up would appear
| before the sibcall_epilogue. */
| || fndecl == NULL_TREE
| || (flags & (ECF_RETURNS_TWICE | ECF_LONGJMP))
| || TREE_THIS_VOLATILE (fndecl)
| || !FUNCTION_OK_FOR_SIBCALL (fndecl)
| /* If this function requires more stack slots than the current
| function, we cannot change it into a sibling call. */
| || args_size.constant > current_function_args_size
| /* If the callee pops its own arguments, then it must pop exactly
| the same number of arguments as the current function. */
| || RETURN_POPS_ARGS (fndecl, funtype, args_size.constant)
| != RETURN_POPS_ARGS (current_function_decl,
| TREE_TYPE (current_function_decl),
| current_function_args_size))
...
| /* Handle calls that return values in multiple non-contiguous locations.
| The Irix 6 ABI has examples of this. */
| else if (GET_CODE (valreg) == PARALLEL)
| {
...
| /* We can not support sibling calls for this case. */
| sibcall_failure = 1;
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: < http://www.cs.mu.oz.au/~fjh > | -- the last words of T. S. Garp.
next prev parent reply other threads:[~2001-01-03 16:36 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-26 8:14 Robert Dewar
2000-11-26 13:43 ` Fergus Henderson
2000-11-27 7:58 ` Jeffrey A Law
2000-11-27 8:05 ` David Edelsohn
2000-11-27 8:07 ` Andi Kleen
2000-11-27 8:25 ` Jeffrey A Law
2000-11-27 8:39 ` Andi Kleen
2000-11-27 9:48 ` Jeffrey A Law
2000-11-27 11:21 ` Lars Brinkhoff
2000-11-27 10:54 ` Mark Mitchell
2000-11-27 8:38 ` Bernd Schmidt
2000-11-27 11:26 ` Eric W. Biederman
2000-11-27 10:48 ` Mark Mitchell
2000-11-27 12:46 ` Harvey J. Stein
2000-11-27 13:02 ` Travis Moulton
2000-11-27 10:47 ` Mark Mitchell
2000-11-28 19:21 ` Fergus Henderson
2000-11-29 2:09 ` Mark Mitchell
2000-11-30 23:59 ` Fergus Henderson
2000-12-01 15:51 ` Joe Buck
2001-01-03 12:24 ` Fergus Henderson
2001-01-03 13:09 ` Richard Henderson
2001-01-03 14:59 ` Fergus Henderson
2001-01-03 15:32 ` Richard Henderson
2001-01-03 15:53 ` Fergus Henderson
2001-01-03 16:11 ` Richard Henderson
2001-01-03 16:36 ` Fergus Henderson [this message]
2002-09-14 23:35 ` Fergus Henderson
2002-09-16 9:26 ` Richard Henderson
2000-11-27 23:39 ` Fergus Henderson
-- strict thread matches above, loose matches on Subject: below --
2000-11-29 4:58 Robert Dewar
2000-11-27 15:33 Mike Stump
2000-11-27 10:04 Robert Dewar
2000-11-27 9:39 Geert Bosch
2000-11-27 12:06 ` Jeffrey A Law
2000-11-27 9:08 Robert Dewar
2000-11-27 9:14 ` Bernd Schmidt
2000-11-27 10:09 ` Michael Matz
2000-11-27 8:44 Robert Dewar
2000-11-27 9:44 ` Jeffrey A Law
2000-11-27 10:22 ` Mark Probst
2000-11-27 14:42 ` Harvey J. Stein
2000-11-27 16:07 ` Mark Probst
2000-11-27 14:30 ` Harvey J. Stein
2000-11-26 18:09 Robert Dewar
2000-11-26 15:46 Robert Dewar
2000-11-26 16:21 ` Joseph S. Myers
2000-11-26 18:08 ` Fergus Henderson
2000-11-26 21:50 ` Jeffrey A Law
2000-11-26 15:27 Robert Dewar
2000-11-26 17:56 ` Fergus Henderson
2000-11-26 10:59 Timothy J. Wood
2000-11-26 9:12 Geert Bosch
2000-11-26 8:21 Robert Dewar
2000-11-26 13:51 ` Fergus Henderson
2000-11-26 5:00 Robert Dewar
2000-11-26 7:44 ` Fergus Henderson
2000-11-26 8:18 ` Bernd Schmidt
2000-11-26 9:55 ` Andi Kleen
2000-11-26 11:34 ` Per Bothner
2000-11-26 11:55 ` Mark Probst
2000-11-26 17:40 ` Fergus Henderson
2000-11-26 3:56 Fergus Henderson
2000-11-26 5:22 ` Mark Probst
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010104113549.A25503@hg.cs.mu.oz.au \
--to=fjh@cs.mu.oz.au \
--cc=gcc-patches@gcc.gnu.org \
--cc=gcc@gcc.gnu.org \
--cc=rth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).