1 ; Tests that we would convert coro.resume to a musttail call if the target is
2 ; Wasm32 with tail-call support.
3 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 ; RUN: opt < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
6 target triple = "wasm32-unknown-unknown"
10 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
11 %alloc = call ptr @malloc(i64 16) #3
12 %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)
14 %save = call token @llvm.coro.save(ptr null)
15 %addr1 = call ptr @llvm.coro.subfn.addr(ptr null, i8 0)
16 call fastcc void %addr1(ptr null)
18 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
19 switch i8 %suspend, label %exit [
20 i8 0, label %await.ready
24 %save2 = call token @llvm.coro.save(ptr null)
25 %addr2 = call ptr @llvm.coro.subfn.addr(ptr null, i8 0)
26 call fastcc void %addr2(ptr null)
28 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
29 switch i8 %suspend2, label %exit [
34 call i1 @llvm.coro.end(ptr null, i1 false, token none)
38 ; CHECK: musttail call
40 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1
41 declare i1 @llvm.coro.alloc(token) #2
42 declare i64 @llvm.coro.size.i64() #3
43 declare ptr @llvm.coro.begin(token, ptr writeonly) #2
44 declare token @llvm.coro.save(ptr) #2
45 declare ptr @llvm.coro.frame() #3
46 declare i8 @llvm.coro.suspend(token, i1) #2
47 declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1
48 declare i1 @llvm.coro.end(ptr, i1, token) #2
49 declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1
50 declare ptr @malloc(i64)
52 attributes #0 = { presplitcoroutine "target-features"="+tail-call" }
53 attributes #1 = { argmemonly nounwind readonly }
54 attributes #2 = { nounwind }
55 attributes #3 = { nounwind readnone }