[all-commits] [llvm/llvm-project] d30ca5: [C++20] [Coroutines] Implement return value optimi...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Tue Feb 15 21:38:27 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d30ca5e2e23fe50dcd8d5d602bf7cfc61b4c1561
      https://github.com/llvm/llvm-project/commit/d30ca5e2e23fe50dcd8d5d602bf7cfc61b4c1561
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2022-02-16 (Wed, 16 Feb 2022)

  Changed paths:
    M clang/include/clang/AST/StmtCXX.h
    M clang/lib/AST/StmtCXX.cpp
    M clang/lib/CodeGen/CGCoroutine.cpp
    M clang/lib/Sema/SemaCoroutine.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/test/CodeGenCoroutines/coro-alloc-exp-namespace.cpp
    M clang/test/CodeGenCoroutines/coro-alloc.cpp
    M clang/test/CodeGenCoroutines/coro-gro-exp-namespace.cpp
    R clang/test/CodeGenCoroutines/coro-gro-nrvo-exp-namespace.cpp
    R clang/test/CodeGenCoroutines/coro-gro-nrvo.cpp
    M clang/test/CodeGenCoroutines/coro-gro.cpp
    A clang/test/CodeGenCoroutines/coro-gro2-exp-namespace.cpp
    A clang/test/CodeGenCoroutines/coro-gro2.cpp
    M clang/test/CodeGenCoroutines/coro-promise-dtor-exp-namespace.cpp
    M clang/test/CodeGenCoroutines/coro-promise-dtor.cpp
    A clang/test/SemaCXX/coroutine-no-move-ctor.cpp
    M clang/test/SemaCXX/coroutines-exp-namespace.cpp
    M clang/test/SemaCXX/coroutines.cpp

  Log Message:
  -----------
  [C++20] [Coroutines] Implement return value optimization for get_return_object

This patch tries to implement RVO for coroutine's return object got from
get_return_object.
>From [dcl.fct.def.coroutine]/p7 we could know that the return value of
get_return_object is either a reference or a prvalue. So it makes sense
to do copy elision for the return value. The return object should be
constructed directly into the storage where they would otherwise be
copied/moved to.

Test Plan: folly, check-all

Reviewed By: junparser

Differential revision: https://reviews.llvm.org/D117087




More information about the All-commits mailing list