1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
2 // RUN: -fcoro-aligned-allocation -S -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_align_for_free:.+]] = call{{.*}}@llvm.coro.align
30 // CHECK: call void @_ZdlPvSt11align_val_t({{.*}}[[coro_align_for_free]]
38 auto initial_suspend() { return std::suspend_always
{}; }
39 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
40 auto get_return_object() { return task2
{}; }
41 void unhandled_exception() {}
42 void return_value(int) {}
43 static task2
get_return_object_on_allocation_failure() { return task2
{}; }
49 constexpr nothrow_t nothrow
= {};
52 void *operator new(std::size_t, std::align_val_t
, std::nothrow_t
) noexcept
;
54 // CHECK: define{{.*}}@_Z2f2v(
56 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
57 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
58 // CHECK: %[[aligned_new:.+]] = call{{.*}}@_ZnwmSt11align_val_tSt9nothrow_t({{.*}}%[[coro_size]],{{.*}}%[[coro_align]])
61 // CHECK: %[[coro_align_for_free:.+]] = call{{.*}}@llvm.coro.align
62 // CHECK: call void @_ZdlPvSt11align_val_t({{.*}}[[coro_align_for_free]]
70 auto initial_suspend() { return std::suspend_always
{}; }
71 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
72 auto get_return_object() { return task3
{}; }
73 void unhandled_exception() {}
74 void return_value(int) {}
75 void operator delete(void *ptr
);
79 // CHECK: define{{.*}}@_Z2f3v
81 // CHECK: call{{.*}}void @_ZN5task312promise_typedlEPv(
89 auto initial_suspend() { return std::suspend_always
{}; }
90 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
91 auto get_return_object() { return task4
{}; }
92 void unhandled_exception() {}
93 void return_value(int) {}
94 void operator delete(void *ptr
, std::align_val_t
);
95 void operator delete(void *ptr
);
99 // CHECK: define{{.*}}@_Z2f4v
101 // CHECK: %[[coro_align_for_free:.+]] = call{{.*}}@llvm.coro.align
102 // CHECK: call{{.*}}void @_ZN5task412promise_typedlEPvSt11align_val_t({{.*}}, i64{{.*}}[[coro_align_for_free]]
109 struct promise_type
{
110 auto initial_suspend() { return std::suspend_always
{}; }
111 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
112 auto get_return_object() { return task5
{}; }
113 void unhandled_exception() {}
114 void return_value(int) {}
115 void *operator new(std::size_t);
119 // CHECK: define{{.*}}@_Z2f5v
120 // CHECK: coro.alloc:
121 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
122 // CHECK: call{{.*}}ptr @_ZN5task512promise_typenwEm(i64{{.*}}%[[coro_size]])
128 struct promise_type
{
129 auto initial_suspend() { return std::suspend_always
{}; }
130 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
131 auto get_return_object() { return task6
{}; }
132 void unhandled_exception() {}
133 void return_value(int) {}
134 void *operator new(std::size_t);
135 void *operator new(std::size_t, int i
);
139 // CHECK: define{{.*}}@_Z2f6i
140 // CHECK: coro.alloc:
141 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
142 // CHECK: call{{.*}}ptr @_ZN5task612promise_typenwEmi(i64{{.*}}%[[coro_size]],
148 struct promise_type
{
149 auto initial_suspend() { return std::suspend_always
{}; }
150 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
151 auto get_return_object() { return task7
{}; }
152 void unhandled_exception() {}
153 void return_value(int) {}
154 void *operator new(std::size_t);
155 void *operator new(std::size_t, int i
);
156 void *operator new(std::size_t, std::align_val_t
);
160 // CHECK: define{{.*}}@_Z2f7i
161 // CHECK: coro.alloc:
162 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
163 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
164 // CHECK: call{{.*}}ptr @_ZN5task712promise_typenwEmSt11align_val_t(i64{{.*}}%[[coro_size]], i64{{.*}}[[coro_align]])
170 struct promise_type
{
171 auto initial_suspend() { return std::suspend_always
{}; }
172 auto final_suspend() noexcept
{ return std::suspend_always
{}; }
173 auto get_return_object() { return task8
{}; }
174 void unhandled_exception() {}
175 void return_value(int) {}
176 void *operator new(std::size_t);
177 void *operator new(std::size_t, int i
);
178 void *operator new(std::size_t, std::align_val_t
);
179 void *operator new(std::size_t, std::align_val_t
, int i
);
183 // CHECK: define{{.*}}@_Z2f8i
184 // CHECK: coro.alloc:
185 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
186 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
187 // CHECK: call{{.*}}ptr @_ZN5task812promise_typenwEmSt11align_val_ti(i64{{.*}}%[[coro_size]], i64{{.*}}[[coro_align]],