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 this directly (as it would happen under -O2)
6 define ptr @f_direct(i64 %this) presplitcoroutine {
8 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
9 %size = call i32 @llvm.coro.size.i32()
10 %alloc = call ptr @myAlloc(i64 %this, i32 %size)
11 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
12 %0 = call i8 @llvm.coro.suspend(token none, i1 false)
13 switch i8 %0, label %suspend [i8 0, label %resume
16 call void @print2(i64 %this)
20 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
21 call void @free(ptr %mem)
24 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
28 ; See if %this was added to the frame
29 ; CHECK: %f_direct.Frame = type { ptr, ptr, i64, i1 }
31 ; See that %this is spilled into the frame
32 ; CHECK-LABEL: define ptr @f_direct(i64 %this)
33 ; CHECK: %this.spill.addr = getelementptr inbounds %f_direct.Frame, ptr %hdl, i32 0, i32 2
34 ; CHECK: store i64 %this, ptr %this.spill.addr
37 ; See that %this was loaded from the frame
38 ; CHECK-LABEL: @f_direct.resume(
39 ; CHECK: %this.reload = load i64, ptr %this.reload.addr
40 ; CHECK: call void @print2(i64 %this.reload)
43 declare ptr @llvm.coro.free(token, ptr)
44 declare i32 @llvm.coro.size.i32()
45 declare i8 @llvm.coro.suspend(token, i1)
46 declare void @llvm.coro.resume(ptr)
47 declare void @llvm.coro.destroy(ptr)
49 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
50 declare i1 @llvm.coro.alloc(token)
51 declare ptr @llvm.coro.begin(token, ptr)
52 declare i1 @llvm.coro.end(ptr, i1, token)
54 declare noalias ptr @myAlloc(i64, i32)
55 declare double @print(double)
56 declare void @print2(i64)
57 declare void @free(ptr)