1 ; Tests that coro-split will convert coro.resume followed by a suspend to a
3 ; RUN: opt < %s -coro-split -S | FileCheck %s
5 define void @f() "coroutine.presplit"="1" {
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*)
51 declare i1 @llvm.coro.alloc(token) #3
52 declare i64 @llvm.coro.size.i64() #5
53 declare i8* @llvm.coro.begin(token, i8* writeonly) #3
54 declare token @llvm.coro.save(i8*) #3
55 declare i8* @llvm.coro.frame() #5
56 declare i8 @llvm.coro.suspend(token, i1) #3
57 declare i8* @llvm.coro.free(token, i8* nocapture readonly) #2
58 declare i1 @llvm.coro.end(i8*, i1) #3
59 declare i8* @llvm.coro.subfn.addr(i8* nocapture readonly, i8) #5
60 declare i8* @malloc(i64)