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