public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug d/96156] d: No RVO when returning struct literals initialized with constructor.
Date: Wed, 26 Aug 2020 08:05:13 +0000	[thread overview]
Message-ID: <bug-96156-4-8xpRor10YZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96156-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:87e36d9baf41a8642ca8687e846764e0828a088b

commit r11-2869-g87e36d9baf41a8642ca8687e846764e0828a088b
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Fri Jul 24 18:06:51 2020 +0200

    d: Fix no RVO when returning struct literals initialized with constructor.

    Backports a change from upstream dmd that moves front-end NRVO checking
    from ReturnStatement semantic to the end of FuncDeclaration semantic.

    In the codegen, retStyle has been partially implemented so that only
    structs and static arrays return RETstack.  This isn't accurate, but
    don't need to be for the purposes of semantic analysis.

    If a function either has TREE_ADDRESSABLE or must return in memory, then
    DECL_RESULT is set as the shidden field for the function.  This is used
    in the codegen pass for ReturnStatement where it is now detected whether
    a function is returning a struct literal or a constructor function, then
    the DECL_RESULT is used to directly construct the return value, instead
    of doing so via temporaries.

    Reviewed-on: https://github.com/dlang/dmd/pull/11622

    gcc/d/ChangeLog:

            PR d/96156
            * d-frontend.cc (retStyle): Only return RETstack for struct and
static
            array types.
            * decl.cc (DeclVisitor::visit (FuncDeclaration *)): Use NRVO return
            for all TREE_ADDRESSABLE types.  Set shidden to the RESULT_DECL.
            * expr.cc (ExprVisitor::visit (CallExp *)): Force TARGET_EXPR if
the
            'this' pointer reference is a CONSTRUCTOR.
            (ExprVisitor::visit (StructLiteralExp *)): Generate assignment to
the
            symbol to initialize with literal.
            * toir.cc (IRVisitor::visit (ReturnStatement *)): Detect returning
            struct literals and write directly into the RESULT_DECL.
            * dmd/MERGE: Merge upstream dmd fe5f388d8.

    gcc/testsuite/ChangeLog:

            PR d/96156
            * gdc.dg/pr96156.d: New test.

  parent reply	other threads:[~2020-08-26  8:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-10 15:22 [Bug d/96156] New: " ibuclaw at gdcproject dot org
2020-07-27 22:34 ` [Bug d/96156] " ibuclaw at gdcproject dot org
2020-08-26  7:45 ` ibuclaw at gdcproject dot org
2020-08-26  8:05 ` cvs-commit at gcc dot gnu.org [this message]
2020-08-26  8:07 ` ibuclaw at gdcproject dot 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-96156-4-8xpRor10YZ@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).