brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · c726810 Raw
76 lines · plain
1; Tests that coro-split won't fall in infinite loop when simplify the terminators leading to ret.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 5declare void @fakeresume1(ptr)6declare void @may_throw(ptr)7declare void @print()8 9define void @f(i1 %cond) #0 personality i32 3 {10entry:11  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)12  %alloc = call ptr @malloc(i64 16) #313  %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)14 15  %save = call token @llvm.coro.save(ptr null)16 17  %init_suspend = call i8 @llvm.coro.suspend(token %save, i1 false)18  switch i8 %init_suspend, label %coro.end [19    i8 0, label %await.ready20    i8 1, label %coro.end21  ]22await.ready:23  call fastcc void @fakeresume1(ptr align 8 null)24  invoke void @may_throw(ptr null)25    to label %ready unwind label %lpad26 27ready:28  %save2 = call token @llvm.coro.save(ptr null)29  %suspend = call i8 @llvm.coro.suspend(token %save2, i1 true)30  %switch = icmp ult i8 %suspend, 231  br i1 %switch, label %cleanup, label %coro.end32 33cleanup:34  %free.handle = call ptr @llvm.coro.free(token %id, ptr %vFrame)35  %.not = icmp eq ptr %free.handle, null36  br i1 %.not, label %coro.end, label %coro.free37 38lpad:39  %lpval = landingpad { ptr, i32 }40     cleanup41 42  call void @llvm.coro.end(ptr null, i1 true, token none)43  resume { ptr, i32 } %lpval44 45coro.free:46  call void @delete(ptr nonnull %free.handle) #247  br label %coro.end48 49coro.end:50  call void @llvm.coro.end(ptr null, i1 false, token none)51  ret void52}53 54; CHECK-LABEL: @f.resume(55; CHECK-NOT:          musttail call fastcc void @fakeresume1(56; CHECK:     }57 58 59declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #160declare i1 @llvm.coro.alloc(token) #261declare i64 @llvm.coro.size.i64() #362declare ptr @llvm.coro.begin(token, ptr writeonly) #263declare token @llvm.coro.save(ptr) #264declare ptr @llvm.coro.frame() #365declare i8 @llvm.coro.suspend(token, i1) #266declare ptr @llvm.coro.free(token, ptr nocapture readonly) #167declare void @llvm.coro.end(ptr, i1, token) #268declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #169declare ptr @malloc(i64)70declare void @delete(ptr nonnull) #271 72attributes #0 = { presplitcoroutine }73attributes #1 = { argmemonly nounwind readonly }74attributes #2 = { nounwind }75attributes #3 = { nounwind readnone }76