[PATCH] D11394: Fix warnings about pessimizing return moves for C++11 and higher

Richard Smith richard at metafoo.co.uk
Sat Jul 25 17:54:27 PDT 2015


On Sat, Jul 25, 2015 at 6:57 AM, Dimitry Andric <dimitry at andric.com> wrote:

> dim added inline comments.
>
> ================
> Comment at: include/__config:724
> @@ -719,1 +723,3 @@
> +#endif
> +
>  #ifndef _LIBCPP_HAS_NO_ASAN
> ----------------
> mclow.lists wrote:
> > I think that this needs more exploration; someone needs to look at the
> codegen.
> >
> >      return x;
> >
> > is different from:
> >
> >      return (x);   // this is an expression
> >
> > I suspect that only one will trigger RVO.
> >
> Would you really think so?  I would think the parentheses are superfluous,
> and can be removed by parsing stages before it gets to RVO.  But I will try
> to check the codegen anyway.
>

Please file a bug if you find any cases where the parenthesized and
non-parenthesized form behave differently wrt RVO / NRVO.


> Alternatively, since the macro is for 'internal use only', we might try to
> just remove the parentheses, e.g.:
>
>     #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
>     #  define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
>     #else
>     #  define _LIBCPP_EXPLICIT_MOVE(x) x
>     #endif
>
> It is a bit ugly, but at least the code itself does not have to be
> littered with #ifdefs.
>
>
> http://reviews.llvm.org/D11394
>
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150725/ba403565/attachment.html>


More information about the cfe-commits mailing list