34 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \2// RUN: -emit-llvm %s -o - -disable-llvm-passes \3// RUN: | FileCheck %s4 5#include "Inputs/coroutine.h"6 7namespace std {8 typedef __SIZE_TYPE__ size_t;9 enum class align_val_t : size_t {};10}11 12struct 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) {}19 };20};21 22// Test the compiler will chose sized deallocation correctly.23void operator delete(void *ptr, std::size_t size) noexcept;24 25// CHECK: define{{.*}}@_Z1fv26// CHECK: %[[coro_free:.+]] = call{{.*}}@llvm.coro.free27// CHECK: coro.free:28// CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size29// CHECK: call{{.*}}void @_ZdlPvm(ptr{{.*}}%[[coro_free]], i64{{.*}}%[[coro_size]])30 31task f() {32 co_return 43;33}34