1 ; Tests lowerings of different versions of coro.await.suspend
2 ; RUN: opt < %s -passes='module(coro-early),cgscc(coro-split),simplifycfg' -S | FileCheck %s
6 define void @f() presplitcoroutine {
8 %awaiter = alloca %Awaiter
9 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
10 %size = call i32 @llvm.coro.size.i32()
11 %alloc = call ptr @malloc(i32 %size)
12 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
13 call void @llvm.coro.await.suspend.handle(ptr %awaiter, ptr %hdl, ptr @await_suspend_wrapper_handle)
14 %suspend.init = call i8 @llvm.coro.suspend(token none, i1 false)
15 switch i8 %suspend.init, label %ret [
20 ; Check the calling convention for resuming function is fastcc
21 ; CHECK: define {{[^@]*}} @f()
23 ; CHECK: %[[NEXT_HDL:.+]] = call ptr @await_suspend_wrapper_handle(
24 ; CHECK-NEXT: %[[CONT:.+]] = call ptr @llvm.coro.subfn.addr(ptr %[[NEXT_HDL]], i8 0)
25 ; CHECK-NEXT: call fastcc void %[[CONT]](ptr %[[NEXT_HDL]])
30 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
31 call void @free(ptr %mem)
35 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
39 ; check that we were haven't accidentally went out of @f body
40 ; CHECK-LABEL: @f.resume(
41 ; CHECK-LABEL: @f.destroy(
42 ; CHECK-LABEL: @f.cleanup(
44 declare ptr @await_suspend_wrapper_handle(ptr, ptr)
46 declare ptr @llvm.coro.free(token, ptr)
47 declare i32 @llvm.coro.size.i32()
48 declare i8 @llvm.coro.suspend(token, i1)
49 declare void @llvm.coro.resume(ptr)
50 declare void @llvm.coro.destroy(ptr)
52 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
53 declare i1 @llvm.coro.alloc(token)
54 declare ptr @llvm.coro.begin(token, ptr)
55 declare void @llvm.coro.await.suspend.handle(ptr, ptr, ptr)
56 declare i1 @llvm.coro.end(ptr, i1, token)
58 declare noalias ptr @malloc(i32)
59 declare void @free(ptr)