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<optimizing>),simplifycfg,early-cse' -S | FileCheck %s
5 define void @fakeresume1(i8*) {
12 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
13 %alloc = call i8* @malloc(i64 16) #3
14 %vFrame = call noalias nonnull i8* @llvm.coro.begin(token %id, i8* %alloc)
16 %save = call token @llvm.coro.save(i8* null)
18 %init_suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
19 switch i8 %init_suspend, label %coro.end [
20 i8 0, label %await.ready
24 %save2 = call token @llvm.coro.save(i8* null)
26 call fastcc void @fakeresume1(i8* align 8 null)
27 %suspend = call i8 @llvm.coro.suspend(token %save2, i1 true)
28 %switch = icmp ult i8 %suspend, 2
29 br i1 %switch, label %cleanup, label %coro.end
32 %free.handle = call i8* @llvm.coro.free(token %id, i8* %vFrame)
33 %.not = icmp eq i8* %free.handle, null
34 br i1 %.not, label %coro.end, label %coro.free
37 call void @delete(i8* nonnull %free.handle) #2
41 call i1 @llvm.coro.end(i8* null, i1 false)
45 ; CHECK-LABEL: @f.resume(
46 ; CHECK: musttail call fastcc void @fakeresume1(
47 ; CHECK-NEXT: ret void
49 declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) #1
50 declare i1 @llvm.coro.alloc(token) #2
51 declare i64 @llvm.coro.size.i64() #3
52 declare i8* @llvm.coro.begin(token, i8* writeonly) #2
53 declare token @llvm.coro.save(i8*) #2
54 declare i8* @llvm.coro.frame() #3
55 declare i8 @llvm.coro.suspend(token, i1) #2
56 declare i8* @llvm.coro.free(token, i8* nocapture readonly) #1
57 declare i1 @llvm.coro.end(i8*, i1) #2
58 declare i8* @llvm.coro.subfn.addr(i8* nocapture readonly, i8) #1
59 declare i8* @malloc(i64)
60 declare void @delete(i8* nonnull) #2
62 attributes #0 = { presplitcoroutine }
63 attributes #1 = { argmemonly nounwind readonly }
64 attributes #2 = { nounwind }
65 attributes #3 = { nounwind readnone }