|
| 1 | +; RUN: opt < %s -passes='module(coro-early),cgscc(coro-split)' -S | FileCheck %s |
| 2 | + |
| 3 | +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" |
| 4 | +target triple = "arm64-apple-macos99.99" |
| 5 | + |
| 6 | + |
| 7 | +@func_cfp = constant <{ i32, i32 }> |
| 8 | + <{ i32 trunc ( |
| 9 | + i64 sub ( |
| 10 | + i64 ptrtoint (ptr @func to i64), |
| 11 | + i64 ptrtoint (ptr getelementptr inbounds (<{ i32, i32 }>, ptr @func_cfp, i32 0, i32 1) to i64) |
| 12 | + ) |
| 13 | + to i32), |
| 14 | + i32 64 |
| 15 | +}> |
| 16 | + |
| 17 | + |
| 18 | +%func_int = type <{ i64 }> |
| 19 | +%func_obj = type <{ %func_int, ptr }> |
| 20 | +%func_guts = type <{ %func_obj }> |
| 21 | +%func_impl = type <{ %func_guts }> |
| 22 | +%func_self = type <{ %func_impl }> |
| 23 | + |
| 24 | +declare swiftcorocc void @func_continuation_prototype(ptr noalias, ptr) |
| 25 | + |
| 26 | +; CHECK-LABEL: @func.resume.0( |
| 27 | +; CHECK-SAME: ptr noalias %0, |
| 28 | +; CHECK-SAME: ptr %1 |
| 29 | +; CHECK-SAME: ) { |
| 30 | +; CHECK: coro.return.popless: |
| 31 | +; CHECK-NEXT: unreachable |
| 32 | +; CHECK: coro.return.normal: |
| 33 | +; CHECK-NEXT: unreachable |
| 34 | +; CHECK: } |
| 35 | + |
| 36 | +define swiftcorocc { ptr, ptr } @func(ptr noalias %buffer, ptr %allocator, ptr nocapture swiftself dereferenceable(16) %2) { |
| 37 | +entry: |
| 38 | + %3 = call token @llvm.coro.id.retcon.once.dynamic( |
| 39 | + i32 -1, |
| 40 | + i32 16, |
| 41 | + ptr @func_cfp, |
| 42 | + ptr %allocator, |
| 43 | + ptr %buffer, |
| 44 | + ptr @func_continuation_prototype, |
| 45 | + ptr @allocate, |
| 46 | + ptr @deallocate |
| 47 | + ) |
| 48 | + %handle = call ptr @llvm.coro.begin(token %3, ptr null) |
| 49 | + %yielded = getelementptr inbounds %func_self, ptr %2, i32 0, i32 0 |
| 50 | + call ptr (...) @llvm.coro.suspend.retcon.p0(ptr %yielded) |
| 51 | + br i1 false, label %unwind, label %normal |
| 52 | + |
| 53 | +normal: |
| 54 | + br label %coro.end |
| 55 | + |
| 56 | +unwind: |
| 57 | + br label %coro.end |
| 58 | + |
| 59 | +coro.end: |
| 60 | + %8 = call i1 @llvm.coro.end(ptr %handle, i1 false, token none) |
| 61 | + unreachable |
| 62 | +} |
| 63 | + |
| 64 | +declare swiftcorocc noalias ptr @allocate(i32 %size) |
| 65 | +declare void @deallocate(ptr %ptr) |
0 commit comments