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
5 define void @fakeresume1(i8*) {
10 define void @fakeresume2(i64* align 8) {
17 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
18 %alloc = call i8* @malloc(i64 16) #3
19 %vFrame = call noalias nonnull i8* @llvm.coro.begin(token %id, i8* %alloc)
21 %save = call token @llvm.coro.save(i8* null)
22 call fastcc void @fakeresume1(i8* null)
24 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
25 switch i8 %suspend, label %exit [
26 i8 0, label %await.ready
30 %save2 = call token @llvm.coro.save(i8* null)
31 call fastcc void @fakeresume2(i64* align 8 null)
33 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
34 switch i8 %suspend2, label %exit [
39 call i1 @llvm.coro.end(i8* null, i1 false)
43 ; Verify that in the initial function resume is not marked with musttail.
45 ; CHECK-NOT: musttail call fastcc void @fakeresume1(i8* null)
47 ; Verify that in the resume part resume call is marked with musttail.
48 ; CHECK-LABEL: @g.resume(
49 ; CHECK: musttail call fastcc void @fakeresume2(i64* align 8 null)
50 ; CHECK-NEXT: ret void
52 declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) #1
53 declare i1 @llvm.coro.alloc(token) #2
54 declare i64 @llvm.coro.size.i64() #3
55 declare i8* @llvm.coro.begin(token, i8* writeonly) #2
56 declare token @llvm.coro.save(i8*) #2
57 declare i8* @llvm.coro.frame() #3
58 declare i8 @llvm.coro.suspend(token, i1) #2
59 declare i8* @llvm.coro.free(token, i8* nocapture readonly) #1
60 declare i1 @llvm.coro.end(i8*, i1) #2
61 declare i8* @llvm.coro.subfn.addr(i8* nocapture readonly, i8) #1
62 declare i8* @malloc(i64)
64 attributes #0 = { "coroutine.presplit"="1" }
65 attributes #1 = { argmemonly nounwind readonly }
66 attributes #2 = { nounwind }
67 attributes #3 = { nounwind readnone }