1 ; RUN: opt < %s -O0 -S | FileCheck --check-prefixes=CHECK %s
3 %swift.async_func_pointer = type <{ i32, i32 }>
4 %swift.context = type { ptr, ptr, i64 }
5 %T10RR13AC = type <{ %swift.refcounted, %swift.defaultactor }>
6 %swift.refcounted = type { ptr, i64 }
7 %swift.type = type { i64 }
8 %swift.defaultactor = type { [10 x ptr] }
9 %swift.bridge = type opaque
10 %swift.error = type opaque
11 %swift.executor = type {}
13 @repoTU = hidden global %swift.async_func_pointer <{ i32 trunc (i64 sub (i64 ptrtoint (ptr @repo to i64), i64 ptrtoint (ptr @repoTU to i64)) to i32), i32 20 }>, section "__TEXT,__const", align 8
15 declare void @use(ptr)
19 define hidden swifttailcc void @repo(ptr swiftasync %arg, i64 %arg1, i64 %arg2, ptr swiftself %arg3) #0 {
21 %i = alloca ptr, align 8
22 %i11 = call token @llvm.coro.id.async(i32 20, i32 16, i32 0, ptr @repoTU)
23 %i12 = call ptr @llvm.coro.begin(token %i11, ptr null)
24 %i18 = call ptr @llvm.coro.async.resume()
25 call void @use(ptr %i18)
26 %i21 = call { ptr } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0i8s(i32 0, ptr %i18, ptr @__swift_async_resume_get_context, ptr @__swift_suspend_point, ptr %i18, ptr null, ptr null)
27 %i22 = extractvalue { ptr } %i21, 0
28 %i23 = call ptr @__swift_async_resume_get_context(ptr %i22)
29 %i28 = icmp eq i64 %arg2, 0
30 br i1 %i28, label %bb126, label %bb
33 %i29 = inttoptr i64 %arg2 to ptr
37 %i31 = phi i64 [ %arg1, %bb ]
38 %i32 = phi ptr [ %i29, %bb ]
39 %i35 = ptrtoint ptr %i32 to i64
40 %i37 = load ptr, ptr %arg3, align 8
41 %i39 = getelementptr inbounds ptr, ptr %i37, i64 11
42 %i40 = load ptr, ptr %i39, align 8
43 %i43 = load i32, ptr %i40, align 8
44 %i44 = sext i32 %i43 to i64
45 %i45 = ptrtoint ptr %i40 to i64
46 %i46 = add i64 %i45, %i44
47 %i47 = inttoptr i64 %i46 to ptr
48 %i52 = call swiftcc ptr @swift_task_alloc(i64 24) #1
49 %i54 = load ptr, ptr %i, align 8
50 %i55 = getelementptr inbounds <{ ptr, ptr, i32 }>, <{ ptr, ptr, i32 }>* %i52, i32 0, i32 0
51 store ptr %i54, ptr %i55, align 8
52 %i56 = call ptr @llvm.coro.async.resume()
53 call void @use(ptr %i56)
54 %i58 = getelementptr inbounds <{ ptr, ptr, i32 }>, <{ ptr, ptr, i32 }>* %i52, i32 0, i32 1
55 store ptr %i56, ptr %i58, align 8
56 %i61 = call { ptr, ptr } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0i8p0s_swift.errorss(i32 256, ptr %i56, ptr @__swift_async_resume_project_context, ptr @__swift_suspend_dispatch_4, ptr %i47, ptr %i52, i64 %i31, i64 0, ptr %arg3)
57 %i62 = extractvalue { ptr, ptr } %i61, 0
58 %i63 = call ptr @__swift_async_resume_project_context(ptr %i62)
59 store ptr %i63, ptr %i, align 8
60 %i65 = extractvalue { ptr, ptr } %i61, 1
61 call swiftcc void @swift_task_dealloc(ptr %i52) #1
62 br i1 %i28, label %bb126, label %bb68
65 %i69 = call ptr @llvm.coro.async.resume()
66 call void @use(ptr %i69)
67 %i70 = load ptr, ptr %i, align 8
68 %i71 = call { ptr } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0i8s(i32 0, ptr %i69, ptr @__swift_async_resume_get_context, ptr @__swift_suspend_point, ptr %i69, ptr null, ptr %i70)
69 %i77 = ptrtoint ptr %i32 to i64
70 %i79 = load ptr, ptr %arg3, align 8
71 %i81 = getelementptr inbounds ptr, ptr %i79, i64 11
72 %i82 = load ptr, ptr %i81, align 8
73 %i85 = load i32, ptr %i82, align 8
74 %i86 = sext i32 %i85 to i64
75 %i87 = ptrtoint ptr %i82 to i64
76 %i88 = add i64 %i87, %i86
77 %i89 = inttoptr i64 %i88 to ptr
78 %i94 = call swiftcc ptr @swift_task_alloc(i64 24) #1
79 %i98 = call ptr @llvm.coro.async.resume()
80 call void @use(ptr %i98)
81 %i103 = call { ptr, ptr } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0i8p0s_swift.errorss(i32 256, ptr %i98, ptr @__swift_async_resume_project_context, ptr @__swift_suspend_dispatch_4.1, ptr %i89, ptr null, i64 %i31, i64 0, ptr %arg3)
82 call swiftcc void @swift_task_dealloc(ptr %i94) #1
86 %i162 = call i1 (ptr, i1, ...) @llvm.coro.end.async(ptr %i12, i1 false, ptr @__swift_suspend_dispatch_2, ptr @doIt, ptr null, ptr null)
90 ; Function Attrs: nounwind
91 declare token @llvm.coro.id.async(i32, i32, i32, ptr) #1
93 ; Function Attrs: nounwind
94 declare ptr @llvm.coro.begin(token, ptr writeonly) #1
96 ; Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
97 declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3
99 ; Function Attrs: nounwind
100 declare ptr @llvm.coro.async.resume() #1
102 ; Function Attrs: noinline
103 define linkonce_odr hidden ptr @__swift_async_resume_get_context(ptr %arg) #4 {
108 ; Function Attrs: nounwind
109 declare extern_weak swifttailcc void @swift_task_switch(ptr, ptr, ptr) #1
111 ; Function Attrs: nounwind
112 define internal swifttailcc void @__swift_suspend_point(ptr %arg, ptr %arg1, ptr %arg2) #1 {
114 musttail call swifttailcc void @swift_task_switch(ptr swiftasync %arg2, ptr %arg, ptr %arg1) #1
118 ; Function Attrs: nounwind
119 declare { ptr } @llvm.coro.suspend.async.sl_p0i8s(i32, ptr, ptr, ...) #1
121 ; Function Attrs: nounwind
122 declare i1 @llvm.coro.end.async(ptr, i1, ...) #1
124 ; Function Attrs: argmemonly nounwind
125 declare extern_weak swiftcc ptr @swift_task_alloc(i64) #5
127 ; Function Attrs: nounwind readnone
128 declare ptr @llvm.swift.async.context.addr() #6
130 ; Function Attrs: alwaysinline nounwind
131 define linkonce_odr hidden ptr @__swift_async_resume_project_context(ptr %arg) #7 {
133 %i1 = load ptr, ptr %arg, align 8
134 %i2 = call ptr @llvm.swift.async.context.addr()
135 store ptr %i1, ptr %i2, align 8
139 ; Function Attrs: nounwind
140 declare { ptr, ptr } @llvm.coro.suspend.async.sl_p0i8p0s_swift.errorss(i32, ptr, ptr, ...) #1
142 ; Function Attrs: argmemonly nounwind
143 declare extern_weak swiftcc void @swift_task_dealloc(ptr) #5
145 ; Function Attrs: nounwind
146 define internal swifttailcc void @__swift_suspend_dispatch_4(ptr %arg, ptr %arg1, i64 %arg2, i64 %arg3, ptr %arg4) #1 {
148 musttail call swifttailcc void %arg(ptr swiftasync %arg1, i64 %arg2, i64 %arg3, ptr swiftself %arg4)
152 declare swifttailcc void @doIt(ptr swiftasync %arg1, ptr swiftself %arg2)
154 ; Function Attrs: nounwind
155 define internal swifttailcc void @__swift_suspend_dispatch_2(ptr %arg, ptr %arg1, ptr %arg2) #1 {
157 musttail call swifttailcc void %arg(ptr swiftasync %arg1, ptr swiftself %arg2)
161 ; Function Attrs: nounwind
162 define internal swifttailcc void @__swift_suspend_dispatch_4.1(ptr %arg, ptr %arg1, i64 %arg2, i64 %arg3, ptr %arg4) #1 {
164 musttail call swifttailcc void %arg(ptr swiftasync %arg1, i64 %arg2, i64 %arg3, ptr swiftself %arg4)
168 attributes #0 = { "frame-pointer"="all" }
169 attributes #1 = { nounwind }
170 attributes #2 = { argmemonly nofree nosync nounwind willreturn }
171 attributes #3 = { argmemonly nofree nosync nounwind willreturn writeonly }
172 attributes #4 = { noinline "frame-pointer"="all" }
173 attributes #5 = { argmemonly nounwind }
174 attributes #6 = { nounwind readnone }
175 attributes #7 = { alwaysinline nounwind "frame-pointer"="all" }