xref: /llvm-project/clang/test/CodeGenCoroutines/coro-alloc-2.cpp (revision 0d501f38f348cf046d40c9baee12f0c5145b6d8c)
1 // Tests that we wouldn't generate an allocation call in global scope with (std::size_t, p0, ..., pn)
2 // RUN: %clang_cc1 %s -std=c++20 -triple x86_64 -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
3 #include "Inputs/coroutine.h"
4 
5 namespace std {
6 typedef decltype(sizeof(int)) size_t;
7 }
8 
9 struct Allocator {};
10 
11 struct resumable {
12   struct promise_type {
13 
get_return_objectresumable::promise_type14     resumable get_return_object() { return {}; }
initial_suspendresumable::promise_type15     auto initial_suspend() { return std::suspend_always(); }
final_suspendresumable::promise_type16     auto final_suspend() noexcept { return std::suspend_always(); }
unhandled_exceptionresumable::promise_type17     void unhandled_exception() {}
return_voidresumable::promise_type18     void return_void(){};
19   };
20 };
21 
22 void *operator new(std::size_t, void *);
23 
f1(void *)24 resumable f1(void *) {
25   co_return;
26 }
27 
28 // CHECK: coro.alloc:
29 // CHECK-NEXT: [[SIZE:%.+]] = call [[BITWIDTH:.+]] @llvm.coro.size.[[BITWIDTH]]()
30 // CHECK-NEXT: call {{.*}} ptr @_Znwm([[BITWIDTH]] noundef [[SIZE]])
31