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

Dimitry Andric dimitry at andric.com
Sat Jul 25 06:57:24 PDT 2015


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.

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







More information about the cfe-commits mailing list