]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/Coroutines/coro-early.ll
Vendor import of llvm trunk r291012:
[FreeBSD/FreeBSD.git] / test / Transforms / Coroutines / coro-early.ll
1 ; Tests that CoroEarly pass correctly lowers coro.resume and coro.destroy
2 ; intrinsics.
3 ; RUN: opt < %s -S -coro-early | FileCheck %s
4
5 ; CHECK-LABEL: @callResume(
6 define void @callResume(i8* %hdl) {
7 ; CHECK-NEXT: entry
8 entry:
9 ; CHECK-NEXT: %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
10 ; CHECK-NEXT: %1 = bitcast i8* %0 to void (i8*)*
11 ; CHECK-NEXT: call fastcc void %1(i8* %hdl)
12   call void @llvm.coro.resume(i8* %hdl)
13
14 ; CHECK-NEXT: %2 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 1)
15 ; CHECK-NEXT: %3 = bitcast i8* %2 to void (i8*)*
16 ; CHECK-NEXT: call fastcc void %3(i8* %hdl)
17   call void @llvm.coro.destroy(i8* %hdl)
18
19   ret void
20 ; CHECK-NEXT: ret void
21 }
22
23 ; CHECK-LABEL: @eh(
24 define void @eh(i8* %hdl) personality i8* null {
25 ; CHECK-NEXT: entry
26 entry:
27 ;  CHECK-NEXT: %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
28 ;  CHECK-NEXT: %1 = bitcast i8* %0 to void (i8*)*
29 ;  CHECK-NEXT: invoke fastcc void %1(i8* %hdl)
30   invoke void @llvm.coro.resume(i8* %hdl)
31           to label %cont unwind label %ehcleanup
32 cont:
33   ret void
34
35 ehcleanup:
36   %0 = cleanuppad within none []
37   cleanupret from %0 unwind to caller
38 }
39
40 declare void @llvm.coro.resume(i8*)
41 declare void @llvm.coro.destroy(i8*)