|
90 | 90 | return %ret : $()
|
91 | 91 | }
|
92 | 92 |
|
| 93 | +sil @yields_pair : $@yield_once @convention(thin) () -> (@yields Builtin.Int32, @yields Builtin.Int32) |
| 94 | + |
| 95 | +// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @test_yields_pair() |
| 96 | +sil @test_yields_pair : $() -> () { |
| 97 | +entry: |
| 98 | + %marker = function_ref @marker : $@convention(thin) (Builtin.Int32) -> () |
| 99 | + |
| 100 | + // Allocate the buffer. |
| 101 | + // CHECK: [[T0:%.*]] = alloca {{\[}}[[BUFFER_SIZE]] x i8], align [[BUFFER_ALIGN]] |
| 102 | + // CHECK-NEXT: [[BUFFER:%.*]] = getelementptr inbounds {{\[}}[[BUFFER_SIZE]] x i8], {{\[}}[[BUFFER_SIZE]] x i8]* [[T0]], i32 0, i32 0 |
| 103 | + // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 [[BUFFER_SIZE]], i8* [[BUFFER]]) |
| 104 | + |
| 105 | + // Prepare the continuation function pointer to block analysis. |
| 106 | + // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.coro.prepare.retcon(i8* bitcast ({ i8*, i32, i32 } (i8*)* @yields_pair to i8*)) |
| 107 | + // CHECK-NEXT: [[PREPARE:%.*]] = bitcast i8* [[T0]] to { i8*, i32, i32 } (i8*)* |
| 108 | + // Call the function pointer. |
| 109 | + // CHECK-NEXT: [[PACKED:%.*]] = call swiftcc { i8*, i32, i32 } [[PREPARE]](i8* noalias dereferenceable([[BUFFER_SIZE]]) [[BUFFER]]) |
| 110 | + // CHECK-NEXT: [[CONTINUATION:%.*]] = extractvalue { i8*, i32, i32 } [[PACKED]], 0 |
| 111 | + // CHECK-NEXT: [[FIRST:%.*]] = extractvalue { i8*, i32, i32 } [[PACKED]], 1 |
| 112 | + // CHECK-NEXT: [[SECOND:%.*]] = extractvalue { i8*, i32, i32 } [[PACKED]], 2 |
| 113 | + %coro = function_ref @yields_pair : $@yield_once @convention(thin) () -> (@yields Builtin.Int32, @yields Builtin.Int32) |
| 114 | + (%first, %second, %token) = begin_apply %coro() : $@yield_once @convention(thin) () -> (@yields Builtin.Int32, @yields Builtin.Int32) |
| 115 | + |
| 116 | + // CHECK-NEXT: call swiftcc void @marker(i32 [[FIRST]]) |
| 117 | + apply %marker(%first) : $@convention(thin) (Builtin.Int32) -> () |
| 118 | + |
| 119 | + // CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[CONTINUATION]] to void (i8*, i1)* |
| 120 | + // CHECK-NEXT: call swiftcc void [[T0]](i8* noalias dereferenceable([[BUFFER_SIZE]]) [[BUFFER]], i1 false) |
| 121 | + // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 [[BUFFER_SIZE]], i8* [[BUFFER]]) |
| 122 | + end_apply %token |
| 123 | + |
| 124 | + // CHECK-NEXT: call swiftcc void @marker(i32 [[SECOND]]) |
| 125 | + apply %marker(%second) : $@convention(thin) (Builtin.Int32) -> () |
| 126 | + |
| 127 | + // CHECK-NEXT: ret void |
| 128 | + %ret = tuple () |
| 129 | + return %ret : $() |
| 130 | +} |
| 131 | + |
| 132 | + |
93 | 133 | // CHECK: attributes [[CORO_ATTRIBUTES]] =
|
94 | 134 | // CHECK-SAME: noinline
|
0 commit comments