public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/96156] New: d: No RVO when returning struct literals initialized with constructor.
@ 2020-07-10 15:22 ibuclaw at gdcproject dot org
2020-07-27 22:34 ` [Bug d/96156] " ibuclaw at gdcproject dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-07-10 15:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96156
Bug ID: 96156
Summary: d: No RVO when returning struct literals initialized
with constructor.
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: ibuclaw at gdcproject dot org
Target Milestone: ---
The address of 's' should become the 'this' pointer of the __ctor() call.
struct S66 {
int x;
__gshared void* ptr;
@disable this(this);
this(int x) { ptr = &this; this.x = x; }
}
auto f66() { return g66(); }
auto g66() { return h66(); }
auto h66() { return S66(100); }
void main()
{
auto s = f66();
assert(&s == S66.ptr);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug d/96156] d: No RVO when returning struct literals initialized with constructor.
2020-07-10 15:22 [Bug d/96156] New: d: No RVO when returning struct literals initialized with constructor ibuclaw at gdcproject dot org
@ 2020-07-27 22:34 ` ibuclaw at gdcproject dot org
2020-08-26 7:45 ` ibuclaw at gdcproject dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-07-27 22:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96156
--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
The fix for this is blocked by pr96347.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug d/96156] d: No RVO when returning struct literals initialized with constructor.
2020-07-10 15:22 [Bug d/96156] New: d: No RVO when returning struct literals initialized with constructor 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
2020-08-26 8:07 ` ibuclaw at gdcproject dot org
3 siblings, 0 replies; 5+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-08-26 7:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96156
Iain Buclaw <ibuclaw at gdcproject dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on|96347 |
--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Generated code has been sufficiently altered that it is no longer blocked, but
the underlying depends-on bug still exists under the right conditions.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96347
[Bug 96347] note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable
location
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug d/96156] d: No RVO when returning struct literals initialized with constructor.
2020-07-10 15:22 [Bug d/96156] New: d: No RVO when returning struct literals initialized with constructor 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
2020-08-26 8:07 ` ibuclaw at gdcproject dot org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-26 8:05 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug d/96156] d: No RVO when returning struct literals initialized with constructor.
2020-07-10 15:22 [Bug d/96156] New: d: No RVO when returning struct literals initialized with constructor ibuclaw at gdcproject dot org
` (2 preceding siblings ...)
2020-08-26 8:05 ` cvs-commit at gcc dot gnu.org
@ 2020-08-26 8:07 ` ibuclaw at gdcproject dot org
3 siblings, 0 replies; 5+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-08-26 8:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96156
Iain Buclaw <ibuclaw at gdcproject dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #4 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Done.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-26 8:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10 15:22 [Bug d/96156] New: d: No RVO when returning struct literals initialized with constructor 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
2020-08-26 8:07 ` ibuclaw at gdcproject dot org
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).