1; Tests that coro-split will convert coro.await.suspend.handle to a musttail call if the target is 2; Wasm64 or Wasm32 with tail-call support. 3; REQUIRES: webassembly-registered-target 4 5; RUN: opt -mtriple=wasm64-unknown-unknown < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s 6; RUN: opt -mtriple=wasm64-unknown-unknown < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s 7 8; RUN: opt -mtriple=wasm32-unknown-unknown < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s 9; RUN: opt -mtriple=wasm32-unknown-unknown < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s 10 11define void @f() #0 { 12entry: 13 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) 14 %alloc = call ptr @malloc(i64 16) #3 15 %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc) 16 17 %save = call token @llvm.coro.save(ptr null) 18 %addr1 = call ptr @llvm.coro.subfn.addr(ptr null, i8 0) 19 call fastcc void %addr1(ptr null) 20 21 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false) 22 switch i8 %suspend, label %exit [ 23 i8 0, label %await.ready 24 i8 1, label %exit 25 ] 26await.ready: 27 %save2 = call token @llvm.coro.save(ptr null) 28 call void @llvm.coro.await.suspend.handle(ptr null, ptr null, ptr @await_suspend_function) 29 30 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false) 31 switch i8 %suspend2, label %exit [ 32 i8 0, label %exit 33 i8 1, label %exit 34 ] 35exit: 36 call i1 @llvm.coro.end(ptr null, i1 false, token none) 37 ret void 38} 39 40; CHECK: musttail call 41 42declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1 43declare i1 @llvm.coro.alloc(token) #2 44declare i64 @llvm.coro.size.i64() #3 45declare ptr @llvm.coro.begin(token, ptr writeonly) #2 46declare token @llvm.coro.save(ptr) #2 47declare ptr @llvm.coro.frame() #3 48declare i8 @llvm.coro.suspend(token, i1) #2 49declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1 50declare i1 @llvm.coro.end(ptr, i1, token) #2 51declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1 52declare ptr @malloc(i64) 53declare ptr @await_suspend_function(ptr %awaiter, ptr %hdl) 54 55attributes #0 = { presplitcoroutine "target-features"="+tail-call" } 56attributes #1 = { argmemonly nounwind readonly } 57attributes #2 = { nounwind } 58attributes #3 = { nounwind readnone } 59