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 --check-prefixes=CHECK,NOPGO %s
4 ; RUN: opt < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck --check-prefixes=CHECK,PGO %s
8 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
9 %alloc = call ptr @malloc(i64 16) #3
10 %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)
12 %save = call token @llvm.coro.save(ptr null)
13 %addr1 = call ptr @llvm.coro.subfn.addr(ptr null, i8 0)
14 call fastcc void %addr1(ptr 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(ptr null)
23 %addr2 = call ptr @llvm.coro.subfn.addr(ptr null, i8 0)
24 call fastcc void %addr2(ptr null)
26 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
27 switch i8 %suspend2, label %exit [
32 call i1 @llvm.coro.end(ptr null, i1 false, token none)
36 ; Verify that in the initial function resume is not marked with musttail.
38 ; CHECK: %[[addr1:.+]] = call ptr @llvm.coro.subfn.addr(ptr null, i8 0)
39 ; CHECK-NOT: musttail call fastcc void %[[addr1]](ptr null)
41 ; Verify that in the resume part resume call is marked with musttail.
42 ; CHECK-LABEL: @f.resume(
43 ; CHECK: %[[addr2:.+]] = call ptr @llvm.coro.subfn.addr(ptr null, i8 0)
44 ; NOPGO-NEXT: musttail call fastcc void %[[addr2]](ptr null)
45 ; PGO: call void @llvm.instrprof
46 ; PGO-NEXT: musttail call fastcc void %[[addr2]](ptr null)
47 ; CHECK-NEXT: ret void
49 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1
50 declare i1 @llvm.coro.alloc(token) #2
51 declare i64 @llvm.coro.size.i64() #3
52 declare ptr @llvm.coro.begin(token, ptr writeonly) #2
53 declare token @llvm.coro.save(ptr) #2
54 declare ptr @llvm.coro.frame() #3
55 declare i8 @llvm.coro.suspend(token, i1) #2
56 declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1
57 declare i1 @llvm.coro.end(ptr, i1, token) #2
58 declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1
59 declare ptr @malloc(i64)
61 attributes #0 = { presplitcoroutine }
62 attributes #1 = { argmemonly nounwind readonly }
63 attributes #2 = { nounwind }
64 attributes #3 = { nounwind readnone }