1 // This tests that the coroutine elide optimization could happen succesfully.
2 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-linux-gnu -std=c++20 -O2 -emit-llvm %s -o - | FileCheck %s
4 #include "Inputs/coroutine.h"
9 bool await_ready() const noexcept
{ return false; }
10 template <typename PromiseType
>
11 std::coroutine_handle
<> await_suspend(std::coroutine_handle
<PromiseType
> h
) noexcept
{
13 return std::noop_coroutine();
14 return h
.promise().continuation
;
16 void await_resume() noexcept
{}
18 Task
get_return_object() noexcept
{
19 return std::coroutine_handle
<promise_type
>::from_promise(*this);
21 std::suspend_always
initial_suspend() noexcept
{ return {}; }
22 FinalAwaiter
final_suspend() noexcept
{ return {}; }
23 void unhandled_exception() noexcept
{}
24 void return_value(int x
) noexcept
{
27 std::coroutine_handle
<> continuation
;
31 Task(std::coroutine_handle
<promise_type
> handle
) : handle(handle
) {}
38 bool await_ready() const noexcept
{ return false; }
39 void await_suspend(std::coroutine_handle
<void> continuation
) noexcept
{}
40 int await_resume() noexcept
{
45 auto operator co_await() {
50 std::coroutine_handle
<promise_type
> handle
;
58 co_return co_await
task0();
61 // CHECK: %_Z5task1v.Frame = type {{.*}}%_Z5task0v.Frame
62 // CHECK-LABEL: define{{.*}} void @_Z5task1v.resume
63 // CHECK-NOT: call{{.*}}_Znwm