1 // Test for PR59181. Tests that no conditional cleanup is created around await_suspend.
3 // REQUIRES: x86-registered-target
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - -std=c++20 -disable-llvm-passes -fsanitize-address-use-after-scope | FileCheck %s
7 #include "Inputs/coroutine.h"
12 Task
get_return_object() {
16 std::suspend_never
initial_suspend() noexcept
{
20 std::suspend_never
final_suspend() noexcept
{
24 void return_value(Task t
) noexcept
{}
25 void unhandled_exception() noexcept
{}
27 auto await_transform(Task t
) {
29 auto await_ready() noexcept
{ return false;}
30 auto await_suspend(std::coroutine_handle
<> coro
) {
34 auto await_resume() noexcept
{
44 co_return cond
? Task
{ co_await Task
{}}: Task
{};
51 // CHECK: cleanup.cont:{{.*}}
52 // CHECK-NEXT: load i8
54 // CHECK-NEXT: store i1 false
55 // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 8, ptr [[REF:%ref.tmp[0-9]+]])
57 // CHECK: await.suspend:{{.*}}
58 // CHECK-NOT: call void @llvm.lifetime.start.p0(i64 8, ptr [[REF]])
59 // CHECK: call void @_ZZN4Task12promise_type15await_transformES_EN10Suspension13await_suspendESt16coroutine_handleIvE
60 // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr [[REF]])