1 ; Tests that coro-split passes initialized values to coroutine frame allocator.
2 ; RUN: opt < %s -coro-split -S | FileCheck %s
4 define i8* @f(i32 %argument) "coroutine.presplit"="1" {
6 %argument.addr = alloca i32, align 4
7 %incremented = add i32 %argument, 1
8 store i32 %incremented, i32* %argument.addr, align 4
9 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
10 %need.alloc = call i1 @llvm.coro.alloc(token %id)
11 br i1 %need.alloc, label %dyn.alloc, label %begin
14 %size = call i32 @llvm.coro.size.i32()
15 %allocator_argument = load i32, i32* %argument.addr, align 4
16 %alloc = call i8* @custom_alloctor(i32 %size, i32 %allocator_argument)
20 %phi = phi i8* [ null, %entry ], [ %alloc, %dyn.alloc ]
21 %hdl = call i8* @llvm.coro.begin(token %id, i8* %phi)
22 %print_argument = load i32, i32* %argument.addr, align 4
23 call void @print(i32 %print_argument)
24 %0 = call i8 @llvm.coro.suspend(token none, i1 false)
25 switch i8 %0, label %suspend [i8 0, label %resume
28 call void @print(i32 1)
32 %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
33 call void @free(i8* %mem)
36 call i1 @llvm.coro.end(i8* %hdl, i1 0)
41 ; CHECK: %argument.addr = alloca i32
42 ; CHECK: %incremented = add i32 %argument, 1
43 ; CHECK-NEXT: store i32 %incremented, i32* %argument.addr
44 ; CHECK-LABEL: dyn.alloc:
45 ; CHECK: %allocator_argument = load i32, i32* %argument.addr
46 ; CHECK: %alloc = call i8* @custom_alloctor(i32 24, i32 %allocator_argument)
48 ; CHECK: %print_argument = load i32, i32* %argument.addr
49 ; CHECK: call void @print(i32 %print_argument)
51 declare i8* @llvm.coro.free(token, i8*)
52 declare i32 @llvm.coro.size.i32()
53 declare i8 @llvm.coro.suspend(token, i1)
54 declare void @llvm.coro.resume(i8*)
55 declare void @llvm.coro.destroy(i8*)
57 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
58 declare i1 @llvm.coro.alloc(token)
59 declare i8* @llvm.coro.begin(token, i8*)
60 declare i1 @llvm.coro.end(i8*, i1)
62 declare noalias i8* @custom_alloctor(i32, i32)
63 declare void @print(i32)
64 declare void @free(i8*)