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 %s 3; RUN: opt < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s 4 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) #3 12 %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.ready 19 i8 1, label %coro.end 20 ] 21await.ready: 22 %save2 = call token @llvm.coro.save(ptr null) 23 br i1 %cond, label %then, label %else 24 25then: 26 call fastcc void @fakeresume1(ptr align 8 null) 27 br label %merge 28 29else: 30 br label %merge 31 32merge: 33 %v0 = phi i1 [0, %then], [1, %else] 34 br label %compare 35 36compare: 37 %cond.cmp = icmp eq i1 %v0, 0 38 br i1 %cond.cmp, label %ready, label %prepare 39 40prepare: 41 call void @print() 42 br label %ready 43 44ready: 45 %suspend = call i8 @llvm.coro.suspend(token %save2, i1 true) 46 %switch = icmp ult i8 %suspend, 2 47 br i1 %switch, label %cleanup, label %coro.end 48 49cleanup: 50 %free.handle = call ptr @llvm.coro.free(token %id, ptr %vFrame) 51 %.not = icmp eq ptr %free.handle, null 52 br i1 %.not, label %coro.end, label %coro.free 53 54coro.free: 55 call void @delete(ptr nonnull %free.handle) #2 56 br label %coro.end 57 58coro.end: 59 call i1 @llvm.coro.end(ptr null, i1 false, token none) 60 ret void 61} 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) #1 69declare i1 @llvm.coro.alloc(token) #2 70declare i64 @llvm.coro.size.i64() #3 71declare ptr @llvm.coro.begin(token, ptr writeonly) #2 72declare token @llvm.coro.save(ptr) #2 73declare ptr @llvm.coro.frame() #3 74declare i8 @llvm.coro.suspend(token, i1) #2 75declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1 76declare i1 @llvm.coro.end(ptr, i1, token) #2 77declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1 78declare ptr @malloc(i64) 79declare void @delete(ptr nonnull) #2 80 81attributes #0 = { presplitcoroutine } 82attributes #1 = { argmemonly nounwind readonly } 83attributes #2 = { nounwind } 84attributes #3 = { nounwind readnone } 85