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 @f() #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 18 %init_suspend = call i8 @llvm.coro.suspend(token %save, i1 false) 19 switch i8 %init_suspend, label %coro.end [ 20 i8 0, label %await.ready 21 i8 1, label %coro.end 22 ] 23await.ready: 24 %save2 = call token @llvm.coro.save(ptr null) 25 26 call void @llvm.coro.await.suspend.handle(ptr null, ptr null, ptr @await_suspend_function) 27 %suspend = call i8 @llvm.coro.suspend(token %save2, i1 true) 28 %switch = icmp ult i8 %suspend, 2 29 br i1 %switch, label %cleanup, label %coro.end 30 31cleanup: 32 %free.handle = call ptr @llvm.coro.free(token %id, ptr %vFrame) 33 %.not = icmp eq ptr %free.handle, null 34 br i1 %.not, label %coro.end, label %coro.free 35 36coro.free: 37 call void @delete(ptr nonnull %free.handle) #2 38 br label %coro.end 39 40coro.end: 41 call i1 @llvm.coro.end(ptr null, i1 false, token none) 42 ret void 43} 44 45; CHECK-LABEL: @f.resume( 46; CHECK: 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 void @delete(ptr nonnull) #2 61declare ptr @await_suspend_function(ptr %awaiter, ptr %hdl) 62 63attributes #0 = { presplitcoroutine } 64attributes #1 = { argmemonly nounwind readonly } 65attributes #2 = { nounwind } 66attributes #3 = { nounwind readnone } 67