1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
3 #include "Inputs/coroutine.h"
9 coro
get_return_object();
10 suspend_always
initial_suspend();
11 suspend_never
final_suspend() noexcept
;
13 static void unhandled_exception();
17 extern "C" coro
f(int) { co_return
; }
18 // Verify that cleanup.dest.slot is eliminated in a coroutine.
20 // CHECK: %[[INIT_SUSPEND:.+]] = call i8 @llvm.coro.suspend(
21 // CHECK-NEXT: switch i8 %[[INIT_SUSPEND]], label
22 // CHECK-NEXT: i8 0, label %[[INIT_READY:.+]]
23 // CHECK-NEXT: i8 1, label %[[INIT_CLEANUP:.+]]
25 // CHECK: %[[CLEANUP_DEST0:.+]] = phi i32 [ 0, %[[INIT_READY]] ], [ 2, %[[INIT_CLEANUP]] ]
27 // CHECK: %[[FINAL_SUSPEND:.+]] = call i8 @llvm.coro.suspend(
28 // CHECK-NEXT: switch i8 %{{.*}}, label %coro.ret [
29 // CHECK-NEXT: i8 0, label %[[FINAL_READY:.+]]
30 // CHECK-NEXT: i8 1, label %[[FINAL_CLEANUP:.+]]
33 // CHECK: call void @_ZNSt13suspend_never12await_resumeEv(
34 // CHECK: %[[CLEANUP_DEST1:.+]] = phi i32 [ 0, %[[FINAL_READY]] ], [ 2, %[[FINAL_CLEANUP]] ]
35 // CHECK: %[[CLEANUP_DEST2:.+]] = phi i32 [ %[[CLEANUP_DEST0]], %{{.+}} ], [ %[[CLEANUP_DEST1]], %{{.+}} ], [ 0, %{{.+}} ]
36 // CHECK: call ptr @llvm.coro.free(
37 // CHECK: switch i32 %[[CLEANUP_DEST2]], label %{{.+}} [