1; RUN: opt -passes='module(coro-early),cgscc(coro-split)' -opaque-pointers=0 -S < %s | FileCheck %s
2; RUN: opt -passes='module(coro-early),cgscc(coro-split)' -opaque-pointers=1 -S < %s | FileCheck %s
3
4declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*)
5
6declare i8* @llvm.coro.begin(token, i8* writeonly)
7
8declare token @llvm.coro.save(i8*)
9
10declare i8 @llvm.coro.suspend(token, i1)
11
12; CHECK-LABEL: define void @foo()
13; CHECK-LABEL: define {{.*}}void @foo.resume(
14; CHECK: call void @foo()
15; CHECK-LABEL: define {{.*}}void @foo.destroy(
16
17define void @foo() presplitcoroutine {
18entry:
19  %__promise = alloca i32, align 8
20  %0 = bitcast i32* %__promise to i8*
21  %1 = call token @llvm.coro.id(i32 16, i8* %0, i8* null, i8* null)
22  %2 = call i8* @llvm.coro.begin(token %1, i8* null)
23  br i1 undef, label %if.then154, label %init.suspend
24
25init.suspend:                                     ; preds = %entry
26  %save = call token @llvm.coro.save(i8* null)
27  %3 = call i8 @llvm.coro.suspend(token %save, i1 false)
28  %cond = icmp eq i8 %3, 0
29  br i1 %cond, label %if.then154, label %invoke.cont163
30
31if.then154:                                       ; preds = %init.suspend, %entry
32  call void @foo()
33  br label %invoke.cont163
34
35invoke.cont163:                                   ; preds = %if.then154, %init.suspend
36  ret void
37}
38