1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
2 // RUN: -fcoro-aligned-allocation -emit-llvm %s -o - -disable-llvm-passes \
5 #include "Inputs/coroutine.h"
8 typedef __SIZE_TYPE__
size_t;
9 enum class align_val_t
: size_t {};
14 auto initial_suspend() { return std::suspend_always
{}; }
15 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
16 auto get_return_object() { return task
{}; }
17 void unhandled_exception() {}
18 void return_value(int) {}
22 // CHECK: define{{.*}}@_Z1fv(
24 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
25 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
26 // CHECK: %[[aligned_new:.+]] = call{{.*}}@_ZnwmSt11align_val_t({{.*}}%[[coro_size]],{{.*}}%[[coro_align]])
29 // CHECK: %[[coro_size_for_free:.+]] = call{{.*}}@llvm.coro.size
30 // CHECK: %[[coro_align_for_free:.+]] = call{{.*}}@llvm.coro.align
31 // CHECK: call void @_ZdlPvmSt11align_val_t({{.*}}%[[coro_size_for_free]],{{.*}}%[[coro_align_for_free]])
39 auto initial_suspend() { return std::suspend_always
{}; }
40 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
41 auto get_return_object() { return task2
{}; }
42 void unhandled_exception() {}
43 void return_value(int) {}
44 static task2
get_return_object_on_allocation_failure() { return task2
{}; }
50 constexpr nothrow_t nothrow
= {};
53 void *operator new(std::size_t, std::align_val_t
, std::nothrow_t
) noexcept
;
55 // CHECK: define{{.*}}@_Z2f2v(
57 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
58 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
59 // CHECK: %[[aligned_new:.+]] = call{{.*}}@_ZnwmSt11align_val_tSt9nothrow_t({{.*}}%[[coro_size]],{{.*}}%[[coro_align]])
62 // CHECK: %[[coro_size_for_free:.+]] = call{{.*}}@llvm.coro.size
63 // CHECK: %[[coro_align_for_free:.+]] = call{{.*}}@llvm.coro.align
64 // CHECK: call void @_ZdlPvmSt11align_val_t({{.*}}%[[coro_size_for_free]],{{.*}}%[[coro_align_for_free]])
72 auto initial_suspend() { return std::suspend_always
{}; }
73 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
74 auto get_return_object() { return task3
{}; }
75 void unhandled_exception() {}
76 void return_value(int) {}
77 void operator delete(void *ptr
);
81 // CHECK: define{{.*}}@_Z2f3v
83 // CHECK: call{{.*}}void @_ZN5task312promise_typedlEPv(
91 auto initial_suspend() { return std::suspend_always
{}; }
92 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
93 auto get_return_object() { return task4
{}; }
94 void unhandled_exception() {}
95 void return_value(int) {}
96 void operator delete(void *ptr
, std::align_val_t
);
97 void operator delete(void *ptr
);
101 // CHECK: define{{.*}}@_Z2f4v
103 // CHECK: %[[coro_align_for_free:.+]] = call{{.*}}@llvm.coro.align
104 // CHECK: call{{.*}}void @_ZN5task412promise_typedlEPvSt11align_val_t({{.*}}, i64{{.*}}[[coro_align_for_free]]
111 struct promise_type
{
112 auto initial_suspend() { return std::suspend_always
{}; }
113 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
114 auto get_return_object() { return task5
{}; }
115 void unhandled_exception() {}
116 void return_value(int) {}
117 void *operator new(std::size_t);
121 // CHECK: define{{.*}}@_Z2f5v
122 // CHECK: coro.alloc:
123 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
124 // CHECK: call{{.*}}ptr @_ZN5task512promise_typenwEm(i64{{.*}}%[[coro_size]])
130 struct promise_type
{
131 auto initial_suspend() { return std::suspend_always
{}; }
132 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
133 auto get_return_object() { return task6
{}; }
134 void unhandled_exception() {}
135 void return_value(int) {}
136 void *operator new(std::size_t);
137 void *operator new(std::size_t, int i
);
141 // CHECK: define{{.*}}@_Z2f6i
142 // CHECK: coro.alloc:
143 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
144 // CHECK: call{{.*}}ptr @_ZN5task612promise_typenwEmi(i64{{.*}}%[[coro_size]],
150 struct promise_type
{
151 auto initial_suspend() { return std::suspend_always
{}; }
152 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
153 auto get_return_object() { return task7
{}; }
154 void unhandled_exception() {}
155 void return_value(int) {}
156 void *operator new(std::size_t);
157 void *operator new(std::size_t, int i
);
158 void *operator new(std::size_t, std::align_val_t
);
162 // CHECK: define{{.*}}@_Z2f7i
163 // CHECK: coro.alloc:
164 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
165 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
166 // CHECK: call{{.*}}ptr @_ZN5task712promise_typenwEmSt11align_val_t(i64{{.*}}%[[coro_size]], i64{{.*}}[[coro_align]])
172 struct promise_type
{
173 auto initial_suspend() { return std::suspend_always
{}; }
174 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
175 auto get_return_object() { return task8
{}; }
176 void unhandled_exception() {}
177 void return_value(int) {}
178 void *operator new(std::size_t);
179 void *operator new(std::size_t, int i
);
180 void *operator new(std::size_t, std::align_val_t
);
181 void *operator new(std::size_t, std::align_val_t
, int i
);
185 // CHECK: define{{.*}}@_Z2f8i
186 // CHECK: coro.alloc:
187 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
188 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
189 // CHECK: call{{.*}}ptr @_ZN5task812promise_typenwEmSt11align_val_ti(i64{{.*}}%[[coro_size]], i64{{.*}}[[coro_align]],