Izaron marked an inline comment as done. Izaron added inline comments.
================ Comment at: clang/test/CodeGenCXX/nrvo.cpp:165 if (B) - return y; - return x; + return y; // NRVO is impossible + return x; // NRVO is impossible ---------------- Quuxplusone wrote: > Technically, because `B` is a constant throughout this function, we probably > //could// do NRVO here by hoisting the condition as if by > ``` > X x; > if (B) { X y; return y; } // NRVO is possible here > X y; return x; // NRVO is impossible > ``` > Whether we //should// is another question. :) Also, changing `bool B` to > `const bool& B` would defeat my idea. I have been thinking on "sorting" variables within the scope to get the optimal NRVO condition (right after seeing `test2`), but didn't come up with anything =( I guess that it's not legal at all, because initializing constructors (unlike copy/move constructors) tend to have meaningful actions (starting a timer, etc.), and many things will break badly if we will shift the declarations as we want. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119927/new/ https://reviews.llvm.org/D119927 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits