1 ; Tests that the number elided coroutine is record correctly.
5 ; RUN: -passes='cgscc(repeat<2>(inline,function(coro-elide,dce)))' -stats 2>&1 \
7 ; RUN: opt < %s --disable-output \
8 ; RUN: -passes='cgscc(repeat<2>(inline,function(coro-elide,dce)))' \
9 ; RUN: -coro-elide-info-output-file=%t && \
11 ; RUN: | FileCheck %s --check-prefix=FILE
13 ; CHECK: 2 coro-elide - The # of coroutine get elided.
14 ; FILE: Elide f in callResume
15 ; FILE: Elide f in callResumeMultiRetDommmed
17 declare void @print(i32) nounwind
19 ; resume part of the coroutine
20 define fastcc void @f.resume(ptr dereferenceable(1)) {
21 tail call void @print(i32 0)
25 ; destroy part of the coroutine
26 define fastcc void @f.destroy(ptr) {
27 tail call void @print(i32 1)
31 ; cleanup part of the coroutine
32 define fastcc void @f.cleanup(ptr) {
33 tail call void @print(i32 2)
37 @f.resumers = internal constant [3 x ptr] [ptr @f.resume,
41 ; a coroutine start function
44 %id = call token @llvm.coro.id(i32 0, ptr null,
47 %alloc = call i1 @llvm.coro.alloc(token %id)
48 %hdl = call ptr @llvm.coro.begin(token %id, ptr null)
52 define void @callResume() {
56 %0 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 0)
57 call fastcc void %0(ptr %hdl)
59 %1 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 1)
60 call fastcc void %1(ptr %hdl)
65 define void @callResumeMultiRet(i1 %b) {
68 %0 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 0)
69 call fastcc void %0(ptr %hdl)
70 br i1 %b, label %destroy, label %ret
73 %1 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 1)
74 call fastcc void %1(ptr %hdl)
81 define void @callResumeMultiRetDommmed(i1 %b) {
84 %0 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 0)
85 call fastcc void %0(ptr %hdl)
86 %1 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 1)
87 call fastcc void %1(ptr %hdl)
88 br i1 %b, label %destroy, label %ret
97 define void @eh() personality ptr null {
101 %0 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 0)
102 invoke void %0(ptr %hdl)
103 to label %cont unwind label %ehcleanup
108 %tok = cleanuppad within none []
109 cleanupret from %tok unwind to caller
112 ; no devirtualization here, since coro.begin info parameter is null
113 define void @no_devirt_info_null() {
115 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
116 %hdl = call ptr @llvm.coro.begin(token %id, ptr null)
118 %0 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 0)
119 call fastcc void %0(ptr %hdl)
121 %1 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 1)
122 call fastcc void %1(ptr %hdl)
127 ; no devirtualization here, since coro.begin is not visible
128 define void @no_devirt_no_begin(ptr %hdl) {
131 %0 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 0)
132 call fastcc void %0(ptr %hdl)
134 %1 = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 1)
135 call fastcc void %1(ptr %hdl)
140 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
141 declare ptr @llvm.coro.begin(token, ptr)
142 declare ptr @llvm.coro.frame()
143 declare ptr @llvm.coro.subfn.addr(ptr, i8)
144 declare i1 @llvm.coro.alloc(token)