[PATCH] D145641: [Coroutines] Implement fix for cwg2563 issue and enable RVO under certain conditions
Chuanqi Xu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 9 01:48:55 PST 2023
ChuanqiXu added inline comments.
================
Comment at: clang/lib/CodeGen/CGCoroutine.cpp:475
const CoroutineBodyStmt &S;
+ bool DirectEmit = false;
----------------
nit. Rewords it if you like.
================
Comment at: clang/lib/CodeGen/CGCoroutine.cpp:483-499
+ // The call to get_return_object is sequenced before the call to
+ // initial_suspend and is invoked at most once, but there are caveats
+ // regarding on whether the prvalue result object may be initialized
+ // directly/eager or delayed, depending on the types involved.
+ //
+ // The general cases:
+ // 1. Same type of get_return_object and coroutine return type (direct
----------------
I'll feel better if we can attach the conclusion and links from the wg21.
================
Comment at: clang/lib/CodeGen/CGCoroutine.cpp:500-508
+ DirectEmit = [&]() {
+ auto *RVI = S.getReturnValueInit();
+ if (!RVI || CGF.FnRetTy->isVoidType())
+ return true;
+ auto GroType = RVI->getType();
+ if (GroType->isVoidType())
+ return true;
----------------
What's the case about returning void and the return_object type is different from the returning type?
================
Comment at: clang/lib/Sema/SemaCoroutine.cpp:1733
+ bool GroMatchesRetType = GroType == FnRetType;
+
----------------
Let's have some comments here.
================
Comment at: clang/test/SemaCXX/coroutine-no-move-ctor.cpp:24-26
invoker f() {
co_return;
}
----------------
How about adding a failing case that the types are not matched?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145641/new/
https://reviews.llvm.org/D145641
More information about the cfe-commits
mailing list