public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: Jeff Law <jeffreyalaw@gmail.com>,
	gcc-help@gcc.gnu.org, Marc Feeley <feeley@iro.umontreal.ca>,
	lucier@purdue.edu, Bradley Lucier <lucier@math.purdue.edu>
Subject: Re: CALL_EXPR_MUST_TAIL_CALL and LLVM's musttail
Date: Thu, 9 Dec 2021 16:00:37 -0600	[thread overview]
Message-ID: <20211209220037.GV614@gate.crashing.org> (raw)
In-Reply-To: <87tufigi5s.fsf@oldenburg.str.redhat.com>

On Thu, Dec 09, 2021 at 11:57:19AM +0100, Florian Weimer wrote:
> * Segher Boessenkool:
> 
> > On Wed, Dec 08, 2021 at 04:17:33PM -0700, Jeff Law via Gcc-help wrote:
> >> On 12/7/2021 3:38 PM, Bradley Lucier via Gcc-help wrote:
> >> >So I've been investigating whether gcc's -foptimize-sibling-calls 
> >> >option (for which I've found very little documentation) might produce 
> >> >similar results.
> >> The option has been around for probably 20+ years at this point, you 
> >> just might not have been aware of it.  They try, but do not guarantee 
> >> tail call optimization.   They have all kinds of checks that might cause 
> >> any particular call site to be rejected for tail call elimination.  It's 
> >> enabled by default at O2 or higher.
> >
> > (Including -Os.)
> >
> > GCC will never not do a tail call if it knows any way to do it.
> 
> GCC will never do a tail call if the target function is known not to
> return normally, to preserve the stack backtrace.

Yes, and that is arguably a bug.  We usually can generate better code
without this artificial limitation, and there are many other cases where
we do similar optimisations that make non-DWARF backtraces harder.  Such
backtraces are of questionable value these days since we have inlining
as well as outlining (or partial inlining at least).

I think we have a PR open for this already?

This usually does not matter much at all, since such paths are called at
most once per program run.

Some targets will never tail call, and some have further limitations,
but on most targets (more mainstream targets anyway) you get tail calls
wherever you could.


Segher

      parent reply	other threads:[~2021-12-09 22:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07 22:38 Bradley Lucier
2021-12-08 23:17 ` Jeff Law
2021-12-09  0:07   ` Segher Boessenkool
2021-12-09  3:31     ` Bradley Lucier
2021-12-09 10:56       ` Florian Weimer
2021-12-09 23:15       ` Segher Boessenkool
2021-12-09 10:57     ` Florian Weimer
2021-12-09 13:30       ` Marc Feeley
2021-12-09 14:04         ` Florian Weimer
2021-12-09 14:17           ` Marc Feeley
2021-12-10  4:31             ` Florian Weimer
2021-12-11  2:44               ` Segher Boessenkool
2021-12-09 23:36         ` Segher Boessenkool
2021-12-10  1:06           ` Marc Feeley
2021-12-10 22:40             ` Jeff Law
2021-12-12 17:32               ` Segher Boessenkool
2021-12-12 18:08                 ` Jonathan Wakely
2021-12-12 21:41                   ` Segher Boessenkool
2021-12-11 23:02             ` Segher Boessenkool
2021-12-13 17:48             ` Avi Kivity
2021-12-15 18:29               ` Bradley Lucier
2021-12-09 22:00       ` Segher Boessenkool [this message]

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=20211209220037.GV614@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=feeley@iro.umontreal.ca \
    --cc=fweimer@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=lucier@math.purdue.edu \
    --cc=lucier@purdue.edu \
    /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).