1 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-linux-gnu -emit-llvm -fcoroutines-ts \
2 // RUN:   -O0 %s -o - | FileCheck %s
3 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-linux-gnu -emit-llvm -fcoroutines-ts \
4 // RUN:   -fno-inline -O0 %s -o - | FileCheck %s
5 
6 namespace std {
7 namespace experimental {
8 
9 struct handle {};
10 
11 struct awaitable {
await_readystd::experimental::awaitable12   bool await_ready() noexcept { return true; }
13   // CHECK-NOT: await_suspend
await_suspendstd::experimental::awaitable14   inline void __attribute__((__always_inline__)) await_suspend(handle) noexcept {}
await_resumestd::experimental::awaitable15   bool await_resume() noexcept { return true; }
16 };
17 
18 template <typename T>
19 struct coroutine_handle {
from_addressstd::experimental::coroutine_handle20   static handle from_address(void *address) noexcept { return {}; }
21 };
22 
23 template <typename T = void>
24 struct coroutine_traits {
25   struct promise_type {
initial_suspendstd::experimental::coroutine_traits::promise_type26     awaitable initial_suspend() { return {}; }
final_suspendstd::experimental::coroutine_traits::promise_type27     awaitable final_suspend() noexcept { return {}; }
return_voidstd::experimental::coroutine_traits::promise_type28     void return_void() {}
get_return_objectstd::experimental::coroutine_traits::promise_type29     T get_return_object() { return T(); }
unhandled_exceptionstd::experimental::coroutine_traits::promise_type30     void unhandled_exception() {}
31   };
32 };
33 } // namespace experimental
34 } // namespace std
35 
36 // CHECK-LABEL: @_Z3foov
37 // CHECK-LABEL: entry:
38 // CHECK: [[CAST0:%[0-9]+]] = bitcast %"struct.std::experimental::awaitable"* %ref.tmp{{.*}} to i8*
39 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 1, i8* [[CAST0]])
40 // CHECK: [[CAST1:%[0-9]+]] = bitcast %"struct.std::experimental::awaitable"* %ref.tmp{{.*}} to i8*
41 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 1, i8* [[CAST1]])
42 
43 // CHECK: [[CAST2:%[0-9]+]] = bitcast %"struct.std::experimental::awaitable"* %ref.tmp{{.*}} to i8*
44 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 1, i8* [[CAST2]])
45 // CHECK: [[CAST3:%[0-9]+]] = bitcast %"struct.std::experimental::awaitable"* %ref.tmp{{.*}} to i8*
46 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 1, i8* [[CAST3]])
foo()47 void foo() { co_return; }
48