1 ; Tests that coro-split will convert a call before coro.suspend to a musttail call
2 ; while the user of the coro.suspend is a icmpinst.
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) {
13 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
14 %alloc = call ptr @malloc(i64 16) #3
15 %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)
17 %save = call token @llvm.coro.save(ptr null)
19 %init_suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
20 switch i8 %init_suspend, label %coro.end [
21 i8 0, label %await.ready
25 %save2 = call token @llvm.coro.save(ptr null)
27 call fastcc void @fakeresume1(ptr align 8 null)
28 %suspend = call i8 @llvm.coro.suspend(token %save2, i1 true)
29 %switch = icmp ult i8 %suspend, 2
30 br i1 %switch, label %cleanup, label %coro.end
33 %free.handle = call ptr @llvm.coro.free(token %id, ptr %vFrame)
34 %.not = icmp eq ptr %free.handle, null
35 br i1 %.not, label %coro.end, label %coro.free
38 call void @delete(ptr nonnull %free.handle) #2
42 call i1 @llvm.coro.end(ptr null, i1 false, token none)
46 ; CHECK-LABEL: @f.resume(
47 ; CHECK: musttail call fastcc void @fakeresume1(
48 ; CHECK-NEXT: ret void
50 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1
51 declare i1 @llvm.coro.alloc(token) #2
52 declare i64 @llvm.coro.size.i64() #3
53 declare ptr @llvm.coro.begin(token, ptr writeonly) #2
54 declare token @llvm.coro.save(ptr) #2
55 declare ptr @llvm.coro.frame() #3
56 declare i8 @llvm.coro.suspend(token, i1) #2
57 declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1
58 declare i1 @llvm.coro.end(ptr, i1, token) #2
59 declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1
60 declare ptr @malloc(i64)
61 declare void @delete(ptr nonnull) #2
63 attributes #0 = { presplitcoroutine }
64 attributes #1 = { argmemonly nounwind readonly }
65 attributes #2 = { nounwind }
66 attributes #3 = { nounwind readnone }