brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 97cd6fb Raw
67 lines · plain
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 %s3; RUN: opt < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s4 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) #314  %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.ready21    i8 1, label %coro.end22  ]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, 229  br i1 %switch, label %cleanup, label %coro.end30 31cleanup:32  %free.handle = call ptr @llvm.coro.free(token %id, ptr %vFrame)33  %.not = icmp eq ptr %free.handle, null34  br i1 %.not, label %coro.end, label %coro.free35 36coro.free:37  call void @delete(ptr nonnull %free.handle) #238  br label %coro.end39 40coro.end:41  call void @llvm.coro.end(ptr null, i1 false, token none)42  ret void43}44 45; CHECK-LABEL: @f.resume(46; CHECK:          musttail call fastcc void47; CHECK-NEXT:     ret void48 49declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #150declare i1 @llvm.coro.alloc(token) #251declare i64 @llvm.coro.size.i64() #352declare ptr @llvm.coro.begin(token, ptr writeonly) #253declare token @llvm.coro.save(ptr) #254declare ptr @llvm.coro.frame() #355declare i8 @llvm.coro.suspend(token, i1) #256declare ptr @llvm.coro.free(token, ptr nocapture readonly) #157declare void @llvm.coro.end(ptr, i1, token) #258declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #159declare ptr @malloc(i64)60declare void @delete(ptr nonnull) #261declare 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