1 // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
3 void *myAlloc(long long);
7 // CHECK: %n.addr = alloca i32
8 // CHECK: %promise = alloca i32
11 // CHECK: %[[COROID:.+]] = call token @llvm.coro.id(i32 32, ptr %promise, ptr null, ptr null)
12 __builtin_coro_id(32, &promise
, 0, 0);
14 // CHECK-NEXT: call i1 @llvm.coro.alloc(token %[[COROID]])
15 __builtin_coro_alloc();
17 // CHECK-NEXT: call ptr @llvm.coro.noop()
18 __builtin_coro_noop();
20 // CHECK-NEXT: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
21 // CHECK-NEXT: %[[MEM:.+]] = call ptr @myAlloc(i64 noundef %[[SIZE]])
22 // CHECK-NEXT: %[[FRAME:.+]] = call ptr @llvm.coro.begin(token %[[COROID]], ptr %[[MEM]])
23 __builtin_coro_begin(myAlloc(__builtin_coro_size()));
25 // CHECK-NEXT: call void @llvm.coro.resume(ptr %[[FRAME]])
26 __builtin_coro_resume(__builtin_coro_frame());
28 // CHECK-NEXT: call void @llvm.coro.destroy(ptr %[[FRAME]])
29 __builtin_coro_destroy(__builtin_coro_frame());
31 // CHECK-NEXT: call i1 @llvm.coro.done(ptr %[[FRAME]])
32 __builtin_coro_done(__builtin_coro_frame());
34 // CHECK-NEXT: call ptr @llvm.coro.promise(ptr %[[FRAME]], i32 48, i1 false)
35 __builtin_coro_promise(__builtin_coro_frame(), 48, 0);
37 // CHECK-NEXT: call ptr @llvm.coro.free(token %[[COROID]], ptr %[[FRAME]])
38 __builtin_coro_free(__builtin_coro_frame());
40 // CHECK-NEXT: call i1 @llvm.coro.end(ptr %[[FRAME]], i1 false, token none)
41 __builtin_coro_end(__builtin_coro_frame(), 0);
43 // CHECK-NEXT: call i8 @llvm.coro.suspend(token none, i1 true)
44 __builtin_coro_suspend(1);