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 ptr @f() presplitcoroutine {
7 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
8 %size = call i32 @llvm.coro.size.i32()
9 %alloc = call ptr @malloc(i32 %size)
10 %hdl = call ptr @llvm.coro.begin(token %id, ptr %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, ptr %x
17 call void @print(i32 %x.value)
21 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
22 call void @free(ptr %mem)
26 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
30 ; CHECK-LABEL: @f.resume(
31 ; CHECK-NEXT: entry.resume:
32 ; CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
33 ; CHECK: [[X_VALUE:%.*]] = load i32, ptr [[X]], align 4
34 ; CHECK-NEXT: call void @print(i32 [[X_VALUE]])
35 ; CHECK: call void @free(ptr [[FRAMEPTR:%.*]])
38 declare ptr @llvm.coro.free(token, ptr)
39 declare i32 @llvm.coro.size.i32()
40 declare i8 @llvm.coro.suspend(token, i1)
41 declare void @llvm.coro.resume(ptr)
42 declare void @llvm.coro.destroy(ptr)
44 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
45 declare i1 @llvm.coro.alloc(token)
46 declare ptr @llvm.coro.begin(token, ptr)
47 declare i1 @llvm.coro.end(ptr, i1, token)
49 declare void @print(i32)
50 declare noalias ptr @malloc(i32)
51 declare void @free(ptr)