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
5 declare void @fakeresume1(ptr)
8 define void @f(i1 %cond) #0 {
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)
14 %save = call token @llvm.coro.save(ptr null)
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
22 %save2 = call token @llvm.coro.save(ptr null)
23 br i1 %cond, label %then, label %else
26 call fastcc void @fakeresume1(ptr align 8 null)
33 %v0 = phi i1 [0, %then], [1, %else]
37 %cond.cmp = icmp eq i1 %v0, 0
38 br i1 %cond.cmp, label %ready, label %prepare
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
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
55 call void @delete(ptr nonnull %free.handle) #2
59 call i1 @llvm.coro.end(ptr null, i1 false, token none)
63 ; CHECK-LABEL: @f.resume(
65 ; CHECK: call void @print()
68 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1
69 declare i1 @llvm.coro.alloc(token) #2
70 declare i64 @llvm.coro.size.i64() #3
71 declare ptr @llvm.coro.begin(token, ptr writeonly) #2
72 declare token @llvm.coro.save(ptr) #2
73 declare ptr @llvm.coro.frame() #3
74 declare i8 @llvm.coro.suspend(token, i1) #2
75 declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1
76 declare i1 @llvm.coro.end(ptr, i1, token) #2
77 declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1
78 declare ptr @malloc(i64)
79 declare void @delete(ptr nonnull) #2
81 attributes #0 = { presplitcoroutine }
82 attributes #1 = { argmemonly nounwind readonly }
83 attributes #2 = { nounwind }
84 attributes #3 = { nounwind readnone }