1 ; Check that we can handle spills of array allocas
2 ; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
4 %struct.big_structure = type { [500 x i8] }
5 declare void @consume(ptr)
7 ; Function Attrs: noinline optnone uwtable
8 define ptr @f(i1 %cond) presplitcoroutine {
10 %data = alloca %struct.big_structure, align 1
11 %data2 = alloca %struct.big_structure, align 1
12 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
13 %size = call i32 @llvm.coro.size.i32()
14 %alloc = call ptr @malloc(i32 %size)
15 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
16 br i1 %cond, label %then, label %else
19 call void @llvm.lifetime.start.p0(i64 500, ptr nonnull %data)
20 call void @consume(ptr %data)
21 %suspend.value = call i8 @llvm.coro.suspend(token none, i1 false)
22 switch i8 %suspend.value, label %coro.ret [i8 0, label %resume
23 i8 1, label %cleanup1]
26 call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %data)
30 call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %data)
34 call void @llvm.lifetime.start.p0(i64 500, ptr nonnull %data2)
35 call void @consume(ptr %data2)
36 %suspend.value2 = call i8 @llvm.coro.suspend(token none, i1 false)
37 switch i8 %suspend.value2, label %coro.ret [i8 0, label %resume2
38 i8 1, label %cleanup2]
41 call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %data2)
45 call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %data2)
49 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
50 call void @free(ptr %mem)
53 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
58 ; CHECK: call ptr @malloc(i32 520)
60 declare ptr @llvm.coro.free(token, ptr)
61 declare i32 @llvm.coro.size.i32()
62 declare i8 @llvm.coro.suspend(token, i1)
63 declare void @llvm.coro.resume(ptr)
64 declare void @llvm.coro.destroy(ptr)
66 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
67 declare i1 @llvm.coro.alloc(token)
68 declare ptr @llvm.coro.begin(token, ptr)
69 declare i1 @llvm.coro.end(ptr, i1, token)
71 declare noalias ptr @malloc(i32)
72 declare double @print(double)
73 declare void @free(ptr)
75 declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
76 declare void @llvm.lifetime.end.p0(i64, ptr nocapture)