1 ; Tests that coro-split will convert coro.resume followed by a suspend to a
3 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 ; RUN: opt < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
6 define void @fakeresume1(ptr) {
11 define void @fakeresume2(ptr align 8) {
18 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
19 %alloc = call ptr @malloc(i64 16) #3
20 %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)
22 %save = call token @llvm.coro.save(ptr null)
23 call fastcc void @fakeresume1(ptr null)
25 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
26 switch i8 %suspend, label %exit [
27 i8 0, label %await.ready
31 %save2 = call token @llvm.coro.save(ptr null)
32 call fastcc void @fakeresume2(ptr align 8 null)
34 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
35 switch i8 %suspend2, label %exit [
40 call i1 @llvm.coro.end(ptr null, i1 false, token none)
44 ; Verify that in the initial function resume is not marked with musttail.
46 ; CHECK-NOT: musttail call fastcc void @fakeresume1(ptr null)
48 ; Verify that in the resume part resume call is marked with musttail.
49 ; CHECK-LABEL: @g.resume(
50 ; CHECK: musttail call fastcc void @fakeresume2(ptr align 8 null)
51 ; CHECK-NEXT: ret void
53 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1
54 declare i1 @llvm.coro.alloc(token) #2
55 declare i64 @llvm.coro.size.i64() #3
56 declare ptr @llvm.coro.begin(token, ptr writeonly) #2
57 declare token @llvm.coro.save(ptr) #2
58 declare ptr @llvm.coro.frame() #3
59 declare i8 @llvm.coro.suspend(token, i1) #2
60 declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1
61 declare i1 @llvm.coro.end(ptr, i1, token) #2
62 declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1
63 declare ptr @malloc(i64)
65 attributes #0 = { presplitcoroutine }
66 attributes #1 = { argmemonly nounwind readonly }
67 attributes #2 = { nounwind }
68 attributes #3 = { nounwind readnone }