[Bug d/101273] d: missed RVO optimization with non-pod structs

ibuclaw at gdcproject dot org gcc-bugzilla@gcc.gnu.org
Thu Jul 1 10:29:50 GMT 2021


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

--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to Iain Buclaw from comment #0)
> It looks like fixing PR d/100882 introduced a small regression:
On further inspection, this is not the case.  The front-end semantic pass
returns us code that uses an intermediate temporary. i.e:

  return __ctor((S tmp = S(), &tmp), 42);

The code generator in D just doesn't detect this pattern and replace `tmp' with
the DECL_RESULT variable to give us a more desired representation:

  S tmp [value-expr: <retval>];
  __ctor(<retval> = S(), &<retval>, 42);
  return <retval>;


More information about the Gcc-bugs mailing list