[LV] Add test showing debug output for loops with uncountable BTCs.
[llvm-project.git] / clang / test / CodeGenCoroutines / coro-aligned-alloc-2.cpp
blobbfa124bb4dc43a63cbefea9919aab9b4a81dbe8e
1 // Tests that the combination of -fcoro-aligned-allocation and -fsized-deallocation works well.
2 // Test the compiler will chose sized deallocation correctly.
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
4 // RUN: -fcoro-aligned-allocation -emit-llvm %s -o - -disable-llvm-passes \
5 // RUN: | FileCheck %s
7 #include "Inputs/coroutine.h"
9 namespace std {
10 typedef __SIZE_TYPE__ size_t;
11 enum class align_val_t : size_t {};
14 struct task {
15 struct promise_type {
16 auto initial_suspend() { return std::suspend_always{}; }
17 auto final_suspend() noexcept { return std::suspend_always{}; }
18 auto get_return_object() { return task{}; }
19 void unhandled_exception() {}
20 void return_value(int) {}
24 // CHECK: define{{.*}}@_Z1fv
25 // CHECK: coro.free:
26 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
27 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
28 // CHECK: call{{.*}}void @_ZdlPvmSt11align_val_t(ptr{{.*}}, i64{{.*}}%[[coro_size]], i64{{.*}}%[[coro_align]])
30 task f() {
31 co_return 43;
34 struct task2 {
35 struct promise_type {
36 auto initial_suspend() { return std::suspend_always{}; }
37 auto final_suspend() noexcept { return std::suspend_always{}; }
38 auto get_return_object() { return task2{}; }
39 void unhandled_exception() {}
40 void return_value(int) {}
41 void operator delete(void *ptr);
45 // CHECK: define{{.*}}@_Z2f2v
46 // CHECK: %[[FREE_HANDLE:.+]] = call{{.*}}ptr @llvm.coro.free(
47 // CHECK: coro.free:
48 // CHECK: call{{.*}}void @_ZN5task212promise_typedlEPv(ptr{{.*}} %[[FREE_HANDLE]])
50 task2 f2() {
51 co_return 43;
54 struct task3 {
55 struct promise_type {
56 auto initial_suspend() { return std::suspend_always{}; }
57 auto final_suspend() noexcept { return std::suspend_always{}; }
58 auto get_return_object() { return task3{}; }
59 void unhandled_exception() {}
60 void return_value(int) {}
61 void operator delete(void *ptr, std::size_t);
62 void operator delete(void *ptr);
66 // CHECK: define{{.*}}@_Z2f3v
67 // CHECK: %[[FREE_HANDLE:.+]] = call{{.*}}ptr @llvm.coro.free(
68 // CHECK: coro.free:
69 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
70 // CHECK: call{{.*}}void @_ZN5task312promise_typedlEPvm(ptr{{.*}} %[[FREE_HANDLE]], i64{{.*}}%[[coro_size]]
72 task3 f3() {
73 co_return 43;
76 struct task4 {
77 struct promise_type {
78 auto initial_suspend() { return std::suspend_always{}; }
79 auto final_suspend() noexcept { return std::suspend_always{}; }
80 auto get_return_object() { return task4{}; }
81 void unhandled_exception() {}
82 void return_value(int) {}
83 void operator delete(void *ptr, std::size_t);
84 void operator delete(void *ptr, std::align_val_t);
85 void operator delete(void *ptr);
89 // CHECK: define{{.*}}@_Z2f4v
90 // CHECK: %[[FREE_HANDLE:.+]] = call{{.*}}ptr @llvm.coro.free(
91 // CHECK: coro.free:
92 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
93 // CHECK: call{{.*}}void @_ZN5task412promise_typedlEPvSt11align_val_t(ptr{{.*}} %[[FREE_HANDLE]], i64{{.*}}%[[coro_align]])
95 task4 f4() {
96 co_return 43;
99 struct task5 {
100 struct promise_type {
101 auto initial_suspend() { return std::suspend_always{}; }
102 auto final_suspend() noexcept { return std::suspend_always{}; }
103 auto get_return_object() { return task5{}; }
104 void unhandled_exception() {}
105 void return_value(int) {}
106 void operator delete(void *ptr, std::size_t);
107 void operator delete(void *ptr, std::size_t, std::align_val_t);
108 void operator delete(void *ptr);
112 // CHECK: define{{.*}}@_Z2f5v
113 // CHECK: %[[FREE_HANDLE:.+]] = call{{.*}}ptr @llvm.coro.free(
114 // CHECK: coro.free:
115 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
116 // CHECK: %[[coro_align:.+]] = call{{.*}}@llvm.coro.align
117 // CHECK: call{{.*}}void @_ZN5task512promise_typedlEPvmSt11align_val_t(ptr{{.*}} %[[FREE_HANDLE]], i64{{.*}}%[[coro_size]], i64{{.*}}%[[coro_align]])
119 task5 f5() {
120 co_return 43;