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
5 target triple = "wasm32-unknown-unknown"
9 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
10 %alloc = call i8* @malloc(i64 16) #3
11 %vFrame = call noalias nonnull i8* @llvm.coro.begin(token %id, i8* %alloc)
13 %save = call token @llvm.coro.save(i8* null)
14 %addr1 = call i8* @llvm.coro.subfn.addr(i8* null, i8 0)
15 %pv1 = bitcast i8* %addr1 to void (i8*)*
16 call fastcc void %pv1(i8* 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(i8* null)
25 %addr2 = call i8* @llvm.coro.subfn.addr(i8* null, i8 0)
26 %pv2 = bitcast i8* %addr2 to void (i8*)*
27 call fastcc void %pv2(i8* null)
29 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
30 switch i8 %suspend2, label %exit [
35 call i1 @llvm.coro.end(i8* null, i1 false)
39 ; CHECK: musttail call
41 declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) #1
42 declare i1 @llvm.coro.alloc(token) #2
43 declare i64 @llvm.coro.size.i64() #3
44 declare i8* @llvm.coro.begin(token, i8* writeonly) #2
45 declare token @llvm.coro.save(i8*) #2
46 declare i8* @llvm.coro.frame() #3
47 declare i8 @llvm.coro.suspend(token, i1) #2
48 declare i8* @llvm.coro.free(token, i8* nocapture readonly) #1
49 declare i1 @llvm.coro.end(i8*, i1) #2
50 declare i8* @llvm.coro.subfn.addr(i8* nocapture readonly, i8) #1
51 declare i8* @malloc(i64)
53 attributes #0 = { presplitcoroutine "target-features"="+tail-call" }
54 attributes #1 = { argmemonly nounwind readonly }
55 attributes #2 = { nounwind }
56 attributes #3 = { nounwind readnone }