[LV] Add test showing debug output for loops with uncountable BTCs.
[llvm-project.git] / clang / test / CodeGenCoroutines / coro-aligned-alloc.cpp
blob156fa64f454caff00422e5195749e2d9ab89dff3
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 \
3 // RUN: | FileCheck %s
5 #include "Inputs/coroutine.h"
7 namespace std {
8 typedef __SIZE_TYPE__ size_t;
9 enum class align_val_t : size_t {};
12 struct task {
13 struct promise_type {
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(
23 // CHECK: coro.alloc:
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]])
28 // CHECK: coro.free:
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]])
33 task f() {
34 co_return 43;
37 struct task2 {
38 struct promise_type {
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{}; }
48 namespace std {
49 struct nothrow_t {};
50 constexpr nothrow_t nothrow = {};
53 void *operator new(std::size_t, std::align_val_t, std::nothrow_t) noexcept;
55 // CHECK: define{{.*}}@_Z2f2v(
56 // CHECK: coro.alloc:
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]])
61 // CHECK: coro.free:
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]])
66 task2 f2() {
67 co_return 43;
70 struct task3 {
71 struct promise_type {
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
82 // CHECK: coro.free:
83 // CHECK: call{{.*}}void @_ZN5task312promise_typedlEPv(
85 task3 f3() {
86 co_return 43;
89 struct task4 {
90 struct promise_type {
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
102 // CHECK: coro.free:
103 // CHECK: %[[coro_align_for_free:.+]] = call{{.*}}@llvm.coro.align
104 // CHECK: call{{.*}}void @_ZN5task412promise_typedlEPvSt11align_val_t({{.*}}, i64{{.*}}[[coro_align_for_free]]
106 task4 f4() {
107 co_return 43;
110 struct task5 {
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]])
125 task5 f5() {
126 co_return 43;
129 struct task6 {
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]],
145 task6 f6(int i) {
146 co_return i;
149 struct task7 {
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]])
167 task7 f7(int i) {
168 co_return i;
171 struct task8 {
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]],
190 task8 f8(int i) {
191 co_return i;