]> git.ipfire.org Git - thirdparty/gcc.git/commit
d: Missed RVO optimization with non-POD structs
authorIain Buclaw <ibuclaw@gdcproject.org>
Sat, 3 Jul 2021 00:42:14 +0000 (02:42 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Sat, 3 Jul 2021 11:00:56 +0000 (13:00 +0200)
commit152f4d0e4d3b524ce30d05f20e23a44b0dd29765
tree305b63554a1557882c9258852a71e97706044670
parent7a60a6e8b36dec960939494baef0f1f15dbfc450
d: Missed RVO optimization with non-POD structs

The D front-end semantic pass sometimes declares a temporary inside a
return expression.  This is now detected with the RESULT_DECL replacing
the temporary, allowing for RVO to be done.

PR d/101273

gcc/d/ChangeLog:

* toir.cc (IRVisitor::visit (ReturnStatement *)): Detect returns that
use a temporary, and replace with return value.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr101273.d: New test.
gcc/d/toir.cc
gcc/testsuite/gdc.dg/torture/pr101273.d [new file with mode: 0644]