public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "iains at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/102528] Unused out-of-line functions emitted for trivial coroutines
Date: Mon, 04 Oct 2021 19:31:15 +0000	[thread overview]
Message-ID: <bug-102528-4-3cgOZlDVqM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102528-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102528

--- Comment #3 from Iain Sandoe <iains at gcc dot gnu.org> ---
 (In reply to Mathias Stearn from comment #0)
 > https://godbolt.org/z/aoab9W4xG
 > 
 > This should all compile away, and test() should just be a single ret
 > instruction. That is not what happens now, even with -O3.

Hi Mathias,

Yes, ideally, that would be the case - so I agree it's a missed optimisation.

On the other hand, to say that the emitted code is unused is not quite right;

We inline the ramp but fail to inline the 'actor' (i.e. the resume).
GCC does not have 'halo' coroutine frame elision, so that we create a frame in
the inlined ramp, and that holds references to the resumer and destroyer.

The net result is that all the code is "used" in the sense that it is referred
to by the emitted test ().

I have an idea (old not new) about altering the internal interfaces in the
generated code to avoid a devirtualisation being necessary to see the inline
opportunity - although I cannot be sure that this is the effect in play, it
seems plausible.

-- so the bottom line is that this is a failure to inline rather than a failure
to elide unused code.

  parent reply	other threads:[~2021-10-04 19:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29 14:47 [Bug c++/102528] New: Unable to inline even " redbeard0531 at gmail dot com
2021-09-29 16:52 ` [Bug c++/102528] Unused out-of-line functions emitted for " redbeard0531 at gmail dot com
2021-10-04 19:23 ` iains at gcc dot gnu.org
2021-10-04 19:31 ` iains at gcc dot gnu.org [this message]
2021-10-04 19:41 ` iains at gcc dot gnu.org
2021-10-04 19:55 ` iains at gcc dot gnu.org
2021-10-05  9:24 ` [Bug ipa/102528] " iains at gcc dot gnu.org
2021-10-05  9:31 ` rguenth at gcc dot gnu.org
2021-10-05  9:46 ` redbeard0531 at gmail dot com
2021-10-05 10:09 ` iains at gcc dot gnu.org

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=bug-102528-4-3cgOZlDVqM@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).