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
7 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
8 %alloc = call i8* @malloc(i64 16) #3
9 %vFrame = call noalias nonnull i8* @llvm.coro.begin(token %id, i8* %alloc)
11 %save = call token @llvm.coro.save(i8* null)
12 %addr1 = call i8* @llvm.coro.subfn.addr(i8* null, i8 0)
13 %pv1 = bitcast i8* %addr1 to void (i8*)*
14 call fastcc void %pv1(i8* null)
16 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
17 switch i8 %suspend, label %exit [
18 i8 0, label %await.ready
22 %save2 = call token @llvm.coro.save(i8* null)
23 %addr2 = call i8* @llvm.coro.subfn.addr(i8* null, i8 0)
24 %pv2 = bitcast i8* %addr2 to void (i8*)*
25 call fastcc void %pv2(i8* null)
27 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
28 switch i8 %suspend2, label %exit [
33 call i1 @llvm.coro.end(i8* null, i1 false)
37 ; Verify that in the initial function resume is not marked with musttail.
39 ; CHECK: %[[addr1:.+]] = call i8* @llvm.coro.subfn.addr(i8* null, i8 0)
40 ; CHECK-NEXT: %[[pv1:.+]] = bitcast i8* %[[addr1]] to void (i8*)*
41 ; CHECK-NOT: musttail call fastcc void %[[pv1]](i8* null)
43 ; Verify that in the resume part resume call is marked with musttail.
44 ; CHECK-LABEL: @f.resume(
45 ; CHECK: %[[addr2:.+]] = call i8* @llvm.coro.subfn.addr(i8* null, i8 0)
46 ; CHECK-NEXT: %[[pv2:.+]] = bitcast i8* %[[addr2]] to void (i8*)*
47 ; CHECK-NEXT: musttail call fastcc void %[[pv2]](i8* null)
48 ; CHECK-NEXT: ret void
50 declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) #1
51 declare i1 @llvm.coro.alloc(token) #2
52 declare i64 @llvm.coro.size.i64() #3
53 declare i8* @llvm.coro.begin(token, i8* writeonly) #2
54 declare token @llvm.coro.save(i8*) #2
55 declare i8* @llvm.coro.frame() #3
56 declare i8 @llvm.coro.suspend(token, i1) #2
57 declare i8* @llvm.coro.free(token, i8* nocapture readonly) #1
58 declare i1 @llvm.coro.end(i8*, i1) #2
59 declare i8* @llvm.coro.subfn.addr(i8* nocapture readonly, i8) #1
60 declare i8* @malloc(i64)
62 attributes #0 = { presplitcoroutine }
63 attributes #1 = { argmemonly nounwind readonly }
64 attributes #2 = { nounwind }
65 attributes #3 = { nounwind readnone }