brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 36ae55e Raw
117 lines · plain
1; Tests that sinked lifetime markers wouldn't provent optimization2; to convert a coro.await.suspend.handle call to a musttail call.3; The difference between this and coro-split-musttail5.ll is that there is4; an extra bitcast instruction in the path, which makes it harder to5; optimize.6; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s7; RUN: opt < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s8 9declare void @fakeresume1(ptr align 8)10 11define void @g() #0 {12entry:13  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)14  %alloc = call ptr @malloc(i64 16) #315  %alloc.var = alloca i6416  call void @llvm.lifetime.start.p0(ptr %alloc.var)17  %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)18 19  %save = call token @llvm.coro.save(ptr null)20  %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)21 22  switch i8 %suspend, label %exit [23    i8 0, label %await.suspend24    i8 1, label %exit25  ]26await.suspend: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  %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)30  switch i8 %suspend2, label %exit [31    i8 0, label %await.ready32    i8 1, label %exit33  ]34await.ready:35  call void @consume(ptr %alloc.var)36  call void @llvm.lifetime.end.p0(ptr %alloc.var)37  br label %exit38exit:39  call void @llvm.coro.end(ptr null, i1 false, token none)40  ret void41}42 43; Verify that in the resume part resume call is marked with musttail.44; CHECK-LABEL: @g.resume(45; CHECK:      musttail call fastcc void46; CHECK-NEXT: ret void47 48; It has a cleanup bb.49define void @f() #0 {50entry:51  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)52  %alloc = call ptr @malloc(i64 16) #353  %alloc.var = alloca i6454  call void @llvm.lifetime.start.p0(ptr %alloc.var)55  %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)56 57  %save = call token @llvm.coro.save(ptr null)58  %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)59 60  switch i8 %suspend, label %exit [61    i8 0, label %await.suspend62    i8 1, label %exit63  ]64await.suspend:65  %save2 = call token @llvm.coro.save(ptr null)66  call void @llvm.coro.await.suspend.handle(ptr null, ptr null, ptr @await_suspend_function)67  %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)68  switch i8 %suspend2, label %exit [69    i8 0, label %await.ready70    i8 1, label %cleanup71  ]72await.ready:73  call void @consume(ptr %alloc.var)74  call void @llvm.lifetime.end.p0(ptr %alloc.var)75  br label %exit76 77cleanup:78  %free.handle = call ptr @llvm.coro.free(token %id, ptr %vFrame)79  %.not = icmp eq ptr %free.handle, null80  br i1 %.not, label %exit, label %coro.free81 82coro.free:83  call void @delete(ptr nonnull %free.handle) #284  br label %exit85 86exit:87  call void @llvm.coro.end(ptr null, i1 false, token none)88  ret void89}90 91; Verify that in the resume part resume call is marked with musttail.92; CHECK-LABEL: @f.resume(93; CHECK:      musttail call fastcc void94; CHECK-NEXT: ret void95 96declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #197declare i1 @llvm.coro.alloc(token) #298declare i64 @llvm.coro.size.i64() #399declare ptr @llvm.coro.begin(token, ptr writeonly) #2100declare token @llvm.coro.save(ptr) #2101declare ptr @llvm.coro.frame() #3102declare i8 @llvm.coro.suspend(token, i1) #2103declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1104declare void @llvm.coro.end(ptr, i1, token) #2105declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1106declare ptr @malloc(i64)107declare void @delete(ptr nonnull) #2108declare void @consume(ptr)109declare void @llvm.lifetime.start.p0(ptr nocapture)110declare void @llvm.lifetime.end.p0(ptr nocapture)111declare ptr @await_suspend_function(ptr %awaiter, ptr %hdl)112 113attributes #0 = { presplitcoroutine }114attributes #1 = { argmemonly nounwind readonly }115attributes #2 = { nounwind }116attributes #3 = { nounwind readnone }117