85 lines · plain
1; Tests that coro-split won't convert the cmp instruction prematurely.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 @print()7 8define void @f(i1 %cond) #0 {9entry:10 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)11 %alloc = call ptr @malloc(i64 16) #312 %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)13 14 %save = call token @llvm.coro.save(ptr null)15 16 %init_suspend = call i8 @llvm.coro.suspend(token %save, i1 false)17 switch i8 %init_suspend, label %coro.end [18 i8 0, label %await.ready19 i8 1, label %coro.end20 ]21await.ready:22 %save2 = call token @llvm.coro.save(ptr null)23 br i1 %cond, label %then, label %else24 25then:26 call fastcc void @fakeresume1(ptr align 8 null)27 br label %merge28 29else:30 br label %merge31 32merge:33 %v0 = phi i1 [0, %then], [1, %else]34 br label %compare35 36compare:37 %cond.cmp = icmp eq i1 %v0, 038 br i1 %cond.cmp, label %ready, label %prepare39 40prepare:41 call void @print()42 br label %ready43 44ready:45 %suspend = call i8 @llvm.coro.suspend(token %save2, i1 true)46 %switch = icmp ult i8 %suspend, 247 br i1 %switch, label %cleanup, label %coro.end48 49cleanup:50 %free.handle = call ptr @llvm.coro.free(token %id, ptr %vFrame)51 %.not = icmp eq ptr %free.handle, null52 br i1 %.not, label %coro.end, label %coro.free53 54coro.free:55 call void @delete(ptr nonnull %free.handle) #256 br label %coro.end57 58coro.end:59 call void @llvm.coro.end(ptr null, i1 false, token none)60 ret void61}62 63; CHECK-LABEL: @f.resume(64; CHECK-NOT: }65; CHECK: call void @print()66 67 68declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #169declare i1 @llvm.coro.alloc(token) #270declare i64 @llvm.coro.size.i64() #371declare ptr @llvm.coro.begin(token, ptr writeonly) #272declare token @llvm.coro.save(ptr) #273declare ptr @llvm.coro.frame() #374declare i8 @llvm.coro.suspend(token, i1) #275declare ptr @llvm.coro.free(token, ptr nocapture readonly) #176declare void @llvm.coro.end(ptr, i1, token) #277declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #178declare ptr @malloc(i64)79declare void @delete(ptr nonnull) #280 81attributes #0 = { presplitcoroutine }82attributes #1 = { argmemonly nounwind readonly }83attributes #2 = { nounwind }84attributes #3 = { nounwind readnone }85