1 ; Tests that allocas after coro.begin are properly that do not need to
2 ; live on the frame are properly moved to the .resume function.
3 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
5 define i8* @f() "coroutine.presplit"="1" {
7 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
8 %size = call i32 @llvm.coro.size.i32()
9 %alloc = call i8* @malloc(i32 %size)
10 %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
12 %sp1 = call i8 @llvm.coro.suspend(token none, i1 false)
13 switch i8 %sp1, label %suspend [i8 0, label %resume
16 %x.value = load i32, i32* %x
17 call void @print(i32 %x.value)
21 %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
22 call void @free(i8* %mem)
26 call i1 @llvm.coro.end(i8* %hdl, i1 0)
30 ; CHECK-LABEL: @f.resume(
31 ; CHECK-NEXT: entry.resume:
32 ; CHECK-NEXT: [[VFRAME:%.*]] = bitcast %f.Frame* [[FRAMEPTR:%.*]] to i8*
33 ; CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
34 ; CHECK: [[X_VALUE:%.*]] = load i32, i32* [[X]], align 4
35 ; CHECK-NEXT: call void @print(i32 [[X_VALUE]])
36 ; CHECK: call void @free(i8* [[VFRAME]])
39 declare i8* @llvm.coro.free(token, i8*)
40 declare i32 @llvm.coro.size.i32()
41 declare i8 @llvm.coro.suspend(token, i1)
42 declare void @llvm.coro.resume(i8*)
43 declare void @llvm.coro.destroy(i8*)
45 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
46 declare i1 @llvm.coro.alloc(token)
47 declare i8* @llvm.coro.begin(token, i8*)
48 declare i1 @llvm.coro.end(i8*, i1)
50 declare void @print(i32)
51 declare noalias i8* @malloc(i32)
52 declare void @free(i8*)