1 // The output of O0 is highly redundant and hard to test. Also it is not good
2 // limit the output of O0. So we test the optimized output from O0. The idea
3 // is the optimizations shouldn't change the semantics of the program.
4 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
5 // RUN: -O0 -emit-llvm %s -o - -disable-O0-optnone \
6 // RUN: | opt -passes='sroa,mem2reg,simplifycfg' -S | FileCheck %s --check-prefix=CHECK-O0
8 #include "Inputs/coroutine.h"
10 // A simple awaiter type with an await_suspend method that can't be
15 bool await_ready() { return false; }
16 std::coroutine_handle
<> await_suspend(const std::coroutine_handle
<> h
);
17 void await_resume() {}
21 // A lazy promise with an await_transform method that supports awaiting
22 // integer references using the Awaiter struct above.
24 MyTask
get_return_object() {
26 std::coroutine_handle
<promise_type
>::from_promise(*this),
30 std::suspend_always
initial_suspend() { return {}; }
31 std::suspend_always
final_suspend() noexcept
{ return {}; }
32 void unhandled_exception();
34 auto await_transform(const int& x
) { return Awaiter
{x
}; }
37 std::coroutine_handle
<> h
;
40 // A global array of integers.
43 // A coroutine that awaits each integer in the global array.
45 for (const int& x
: g_array
) {
50 // CHECK-O0: define{{.*}}@_Z6FooBarv.resume
51 // CHECK-O0: call{{.*}}@_Z6FooBarv.__await_suspend_wrapper__await(
52 // CHECK-O0-NOT: store