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(i8*) {
21 tail call void @print(i32 0)
25 ; destroy part of the coroutine
26 define fastcc void @f.destroy(i8*) {
27 tail call void @print(i32 1)
31 ; cleanup part of the coroutine
32 define fastcc void @f.cleanup(i8*) {
33 tail call void @print(i32 2)
37 @f.resumers = internal constant [3 x void (i8*)*] [void (i8*)* @f.resume,
38 void (i8*)* @f.destroy,
39 void (i8*)* @f.cleanup]
41 ; a coroutine start function
44 %id = call token @llvm.coro.id(i32 0, i8* null,
45 i8* bitcast (i8*()* @f to i8*),
46 i8* bitcast ([3 x void (i8*)*]* @f.resumers to i8*))
47 %alloc = call i1 @llvm.coro.alloc(token %id)
48 %hdl = call i8* @llvm.coro.begin(token %id, i8* null)
52 define void @callResume() {
56 %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
57 %1 = bitcast i8* %0 to void (i8*)*
58 call fastcc void %1(i8* %hdl)
60 %2 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 1)
61 %3 = bitcast i8* %2 to void (i8*)*
62 call fastcc void %3(i8* %hdl)
67 define void @callResumeMultiRet(i1 %b) {
70 %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
71 %1 = bitcast i8* %0 to void (i8*)*
72 call fastcc void %1(i8* %hdl)
73 br i1 %b, label %destroy, label %ret
76 %2 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 1)
77 %3 = bitcast i8* %2 to void (i8*)*
78 call fastcc void %3(i8* %hdl)
85 define void @callResumeMultiRetDommmed(i1 %b) {
88 %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
89 %1 = bitcast i8* %0 to void (i8*)*
90 call fastcc void %1(i8* %hdl)
91 %2 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 1)
92 %3 = bitcast i8* %2 to void (i8*)*
93 call fastcc void %3(i8* %hdl)
94 br i1 %b, label %destroy, label %ret
103 define void @eh() personality i8* null {
107 %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
108 %1 = bitcast i8* %0 to void (i8*)*
109 invoke void %1(i8* %hdl)
110 to label %cont unwind label %ehcleanup
115 %tok = cleanuppad within none []
116 cleanupret from %tok unwind to caller
119 ; no devirtualization here, since coro.begin info parameter is null
120 define void @no_devirt_info_null() {
122 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
123 %hdl = call i8* @llvm.coro.begin(token %id, i8* null)
125 %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
126 %1 = bitcast i8* %0 to void (i8*)*
127 call fastcc void %1(i8* %hdl)
129 %2 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 1)
130 %3 = bitcast i8* %2 to void (i8*)*
131 call fastcc void %3(i8* %hdl)
136 ; no devirtualization here, since coro.begin is not visible
137 define void @no_devirt_no_begin(i8* %hdl) {
140 %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
141 %1 = bitcast i8* %0 to void (i8*)*
142 call fastcc void %1(i8* %hdl)
144 %2 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 1)
145 %3 = bitcast i8* %2 to void (i8*)*
146 call fastcc void %3(i8* %hdl)
151 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
152 declare i8* @llvm.coro.begin(token, i8*)
153 declare i8* @llvm.coro.frame()
154 declare i8* @llvm.coro.subfn.addr(i8*, i8)
155 declare i1 @llvm.coro.alloc(token)