public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ibuclaw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug d/106977] [13 regression] d21 dies with SIGBUS on 32-bit Darwin
Date: Fri, 24 Feb 2023 01:13:21 +0000 [thread overview]
Message-ID: <bug-106977-4-kmFvmYI00E@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106977-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106977
--- Comment #20 from ibuclaw at gcc dot gnu.org ---
(In reply to Andrew Pinski from comment #19)
> (In reply to Andrew Pinski from comment #18)
> > > I think the visibility type is POD (assuming D has that concept)
>
> At least the front-end does.
> See dmd/dstruct.d:443
>
> if isPOD return false, TREE_ADDRESSABLE is set on the struct.
> I have not gone through the code otherwise.
See d/decl.cc:950
It's not TREE_ADDRESSABLE, but on 32-bit the struct is considered to be
'aggregate_value_p', which in turn sets up return by hidden reference.
This effects how the return is handled later (around toir.cc:1044), which
splits up the init and return expression. Returning this way I guess is fine
for extern(D) functions, however we should not be so eager to do rvo/sret for
other extern language functions.
Having a quick look at C++ front-end, they require both `aggregate_value_p` and
for a named variable to be in the return expression.
```
if (current_function_return_value)
{
tree r = current_function_return_value;
tree outer;
if (r != error_mark_node
/* This is only worth doing for fns that return in memory--and
simpler, since we don't have to worry about promoted modes. */
&& aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl)), fndecl)
```
So for the current gate in D:
```
if (TREE_ADDRESSABLE (TREE_TYPE (resdecl))
|| aggregate_value_p (TREE_TYPE (resdecl), fndecl))
```
I think tightening that to (its late, and my parentheses may be wrong).
```
if (TREE_ADDRESSABLE (TREE_TYPE (resdecl))
|| ((d->resolvedLinkage () == LINK::d
|| (d->resolvedLinkage () == LINK::cpp && d->nrvo_var))
&& aggregate_value_p (TREE_TYPE (resdecl), fndecl)))
```
Which is:
1. TREE_ADDRESSABLE
2. extern(D) and aggregate_value_p
3. extern(C++) and have NVRO variable and aggregate_value_p
I guess for extern(C) functions we should just forget even attempting to do any
(N)RVO/SRET returns and let tree-nrv.cc decide whether to optimize or not.
next prev parent reply other threads:[~2023-02-24 1:13 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 14:06 [Bug d/106977] New: " ro at gcc dot gnu.org
2022-09-21 7:48 ` [Bug d/106977] " rguenth at gcc dot gnu.org
2022-11-07 14:37 ` ibuclaw at gdcproject dot org
2022-11-07 14:49 ` ro at CeBiTec dot Uni-Bielefeld.DE
2022-11-07 15:34 ` ibuclaw at gdcproject dot org
2022-11-07 15:43 ` ro at CeBiTec dot Uni-Bielefeld.DE
2023-02-22 23:58 ` iains at gcc dot gnu.org
2023-02-23 1:20 ` ibuclaw at gcc dot gnu.org
2023-02-23 7:38 ` iains at gcc dot gnu.org
2023-02-23 10:21 ` iains at gcc dot gnu.org
2023-02-23 10:43 ` ibuclaw at gcc dot gnu.org
2023-02-23 10:50 ` ibuclaw at gcc dot gnu.org
2023-02-23 10:51 ` iains at gcc dot gnu.org
2023-02-23 22:49 ` ibuclaw at gcc dot gnu.org
2023-02-23 23:11 ` ibuclaw at gcc dot gnu.org
2023-02-23 23:29 ` iains at gcc dot gnu.org
2023-02-23 23:33 ` pinskia at gcc dot gnu.org
2023-02-23 23:34 ` iains at gcc dot gnu.org
2023-02-23 23:36 ` iains at gcc dot gnu.org
2023-02-23 23:55 ` pinskia at gcc dot gnu.org
2023-02-24 0:00 ` pinskia at gcc dot gnu.org
2023-02-24 1:13 ` ibuclaw at gcc dot gnu.org [this message]
2023-02-24 2:03 ` ibuclaw at gcc dot gnu.org
2023-02-24 2:12 ` ibuclaw at gcc dot gnu.org
2023-02-24 7:52 ` iains at gcc dot gnu.org
2023-02-24 8:20 ` ibuclaw at gcc dot gnu.org
2023-02-24 8:46 ` iains at gcc dot gnu.org
2023-02-24 11:39 ` ibuclaw at gcc dot gnu.org
2023-02-24 17:48 ` iains at gcc dot gnu.org
2023-02-24 18:14 ` iains at gcc dot gnu.org
2023-02-24 18:39 ` ibuclaw at gcc dot gnu.org
2023-02-24 20:07 ` iains at gcc dot gnu.org
2023-04-26 6:56 ` [Bug d/106977] [13/14 " rguenth at gcc dot gnu.org
2023-06-28 18:19 ` cvs-commit at gcc dot gnu.org
2023-06-28 18:52 ` cvs-commit at gcc dot gnu.org
2023-06-28 18:57 ` ibuclaw at gcc dot gnu.org
2023-06-29 7:52 ` 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-106977-4-kmFvmYI00E@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).