1 ; Check that we can handle the case when both alloc function and
2 ; the user body consume the same argument.
3 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
5 ; using copy of this (as it would happen under -O0)
6 define ptr @f_copy(i64 %this_arg) presplitcoroutine {
8 %this.addr = alloca i64
9 store i64 %this_arg, ptr %this.addr
10 %this = load i64, ptr %this.addr
11 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
12 %size = call i32 @llvm.coro.size.i32()
13 %alloc = call ptr @myAlloc(i64 %this, i32 %size)
14 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
15 %0 = call i8 @llvm.coro.suspend(token none, i1 false)
16 switch i8 %0, label %suspend [i8 0, label %resume
19 call void @print2(i64 %this)
23 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
24 call void @free(ptr %mem)
27 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
31 ; See if %this was added to the frame
32 ; CHECK: %f_copy.Frame = type { ptr, ptr, i64, i1 }
34 ; See that %this is spilled into the frame
35 ; CHECK-LABEL: define ptr @f_copy(i64 %this_arg)
36 ; CHECK: %this.addr = alloca i64, align 8
37 ; CHECK: store i64 %this_arg, ptr %this.addr, align 4
38 ; CHECK: %this.spill.addr = getelementptr inbounds %f_copy.Frame, ptr %hdl, i32 0, i32 2
39 ; CHECK: store i64 %this_arg, ptr %this.spill.addr
42 ; See that %this was loaded from the frame
43 ; CHECK-LABEL: @f_copy.resume(
44 ; CHECK: %this.reload = load i64, ptr %this.reload.addr
45 ; CHECK: call void @print2(i64 %this.reload)
48 declare ptr @llvm.coro.free(token, ptr)
49 declare i32 @llvm.coro.size.i32()
50 declare i8 @llvm.coro.suspend(token, i1)
51 declare void @llvm.coro.resume(ptr)
52 declare void @llvm.coro.destroy(ptr)
54 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
55 declare i1 @llvm.coro.alloc(token)
56 declare ptr @llvm.coro.begin(token, ptr)
57 declare i1 @llvm.coro.end(ptr, i1, token)
59 declare noalias ptr @myAlloc(i64, i32)
60 declare double @print(double)
61 declare void @print2(i64)
62 declare void @free(ptr)