1; Tests that coro-split will convert coro.await.suspend.handle to a musttail call. 2; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s 3; RUN: opt < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s 4 5define void @fakeresume1(ptr) { 6entry: 7 ret void; 8} 9 10define void @g() #0 { 11entry: 12 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) 13 %alloc = call ptr @malloc(i64 16) #3 14 %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc) 15 16 %save = call token @llvm.coro.save(ptr null) 17 call fastcc void @fakeresume1(ptr null) 18 19 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false) 20 switch i8 %suspend, label %exit [ 21 i8 0, label %await.ready 22 i8 1, label %exit 23 ] 24await.ready: 25 %save2 = call token @llvm.coro.save(ptr null) 26 call void @llvm.coro.await.suspend.handle(ptr null, ptr null, ptr @await_suspend_function) 27 28 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false) 29 switch i8 %suspend2, label %exit [ 30 i8 0, label %exit 31 i8 1, label %exit 32 ] 33exit: 34 call i1 @llvm.coro.end(ptr null, i1 false, token none) 35 ret void 36} 37 38; Verify that in the initial function resume is not marked with musttail. 39; CHECK-LABEL: @g( 40; CHECK-NOT: musttail call fastcc void @fakeresume1(ptr null) 41 42; Verify that in the resume part resume call is marked with musttail. 43; CHECK-LABEL: @g.resume( 44; CHECK: call ptr @await_suspend_function 45; CHECK-NEXT: call ptr @llvm.coro.subfn.addr 46; CHECK-NEXT: musttail call fastcc void 47; CHECK-NEXT: ret void 48 49declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1 50declare i1 @llvm.coro.alloc(token) #2 51declare i64 @llvm.coro.size.i64() #3 52declare ptr @llvm.coro.begin(token, ptr writeonly) #2 53declare token @llvm.coro.save(ptr) #2 54declare ptr @llvm.coro.frame() #3 55declare i8 @llvm.coro.suspend(token, i1) #2 56declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1 57declare i1 @llvm.coro.end(ptr, i1, token) #2 58declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1 59declare ptr @malloc(i64) 60declare ptr @await_suspend_function(ptr %awaiter, ptr %hdl) 61 62attributes #0 = { presplitcoroutine } 63attributes #1 = { argmemonly nounwind readonly } 64attributes #2 = { nounwind } 65attributes #3 = { nounwind readnone } 66