1 ; Check that we can handle spills of array allocas
2 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 declare void @consume.double.ptr(ptr)
5 declare void @consume.i32.ptr(ptr)
7 define ptr @f() presplitcoroutine {
9 %prefix = alloca double
10 %data = alloca i32, i32 4
11 %suffix = alloca double
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 call void @consume.double.ptr(ptr %prefix)
17 call void @consume.i32.ptr(ptr %data)
18 call void @consume.double.ptr(ptr %suffix)
19 %0 = call i8 @llvm.coro.suspend(token none, i1 false)
20 switch i8 %0, label %suspend [i8 0, label %resume
23 call void @consume.double.ptr(ptr %prefix)
24 call void @consume.i32.ptr(ptr %data)
25 call void @consume.double.ptr(ptr %suffix)
29 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
30 call void @free(ptr %mem)
33 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
37 ; See if the array alloca was stored as an array field.
38 ; CHECK-LABEL: %f.Frame = type { ptr, ptr, double, double, [4 x i32], i1 }
40 ; See if we used correct index to access prefix, data, suffix (@f)
42 ; CHECK: %[[PREFIX:.+]] = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 2
43 ; CHECK-NEXT: %[[DATA:.+]] = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 4
44 ; CHECK-NEXT: %[[SUFFIX:.+]] = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 3
45 ; CHECK-NEXT: call void @consume.double.ptr(ptr %[[PREFIX:.+]])
46 ; CHECK-NEXT: call void @consume.i32.ptr(ptr %[[DATA:.+]])
47 ; CHECK-NEXT: call void @consume.double.ptr(ptr %[[SUFFIX:.+]])
50 ; See if we used correct index to access prefix, data, suffix (@f.resume)
51 ; CHECK-LABEL: @f.resume(
52 ; CHECK: %[[PREFIX:.+]] = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 2
53 ; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 4
54 ; CHECK: %[[SUFFIX:.+]] = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 3
55 ; CHECK: call void @consume.double.ptr(ptr %[[PREFIX]])
56 ; CHECK-NEXT: call void @consume.i32.ptr(ptr %[[DATA]])
57 ; CHECK-NEXT: call void @consume.double.ptr(ptr %[[SUFFIX]])
59 declare ptr @llvm.coro.free(token, ptr)
60 declare i32 @llvm.coro.size.i32()
61 declare i8 @llvm.coro.suspend(token, i1)
62 declare void @llvm.coro.resume(ptr)
63 declare void @llvm.coro.destroy(ptr)
65 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
66 declare i1 @llvm.coro.alloc(token)
67 declare ptr @llvm.coro.begin(token, ptr)
68 declare i1 @llvm.coro.end(ptr, i1, token)
70 declare noalias ptr @malloc(i32)
71 declare double @print(double)
72 declare void @free(ptr)