https://reviews.llvm.org/D47067 is a "Restricted Differential Revision", which I've never seen before! Peanut gallery says: This sounds awesome. How does this change interact with the diagnostics issued by -Wpessimizing-move and -Wreturn-std-move? Should any new test cases be added for those diagnostics?
On Fri, May 18, 2018 at 7:12 AM, Taiju Tsuiki via Phabricator via cfe-commits <cfe-commits@lists.llvm.org> wrote: > tzik created this revision. > Herald added a subscriber: cfe-commits. > > The previous implementation misses an opportunity to apply NRVO (Named > Return Value > > Optimization) below. That discourages user to write early return code. > ---------------------------------------------------------------------- > > struct Foo {}; > > Foo f(bool b) { > > if (b) > return Foo(); > Foo oo; > return oo; > > } > - > > That is, we can/should apply RVO for a return statement if it refers a > non-parameter local variable, > and the variable is referred by all return statements reachable from the > variable declaration. > While, the previous implementation disables the RVO in a scope if there > are multiple return > statements that refers different variables. > > On the new algorithm, local variables are in NRVO_Candidate state at > first, and a return > statement changes it to NRVO_Disabled for all visible variables but the > return statement refers. > Then, at the end of the function AST traversal, NRVO is enabled for > variables in NRVO_Candidate > state and refers from at least one return statement. > > > Repository: > rC Clang > > https://reviews.llvm.org/D47067 > > Files: > include/clang/AST/Decl.h > include/clang/Sema/Scope.h > lib/Sema/Scope.cpp > lib/Sema/SemaDecl.cpp > lib/Sema/SemaStmt.cpp > lib/Serialization/ASTReaderDecl.cpp > lib/Serialization/ASTWriterDecl.cpp > test/CodeGenCXX/nrvo.cpp > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits