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(double*)
5 declare void @consume.i32.ptr(i32*)
7 define i8* @f() "coroutine.presplit"="1" {
9 %prefix = alloca double
10 %data = alloca i32, i32 4
11 %suffix = alloca double
12 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
13 %size = call i32 @llvm.coro.size.i32()
14 %alloc = call i8* @malloc(i32 %size)
15 %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
16 call void @consume.double.ptr(double* %prefix)
17 call void @consume.i32.ptr(i32* %data)
18 call void @consume.double.ptr(double* %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(double* %prefix)
24 call void @consume.i32.ptr(i32* %data)
25 call void @consume.double.ptr(double* %suffix)
29 %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
30 call void @free(i8* %mem)
33 call i1 @llvm.coro.end(i8* %hdl, i1 0)
37 ; See if the array alloca was stored as an array field.
38 ; CHECK-LABEL: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, 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, %f.Frame* %FramePtr, i32 0, i32 2
43 ; CHECK-NEXT: %[[DATA:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 4
44 ; CHECK-NEXT: %[[SUFFIX:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 3
45 ; CHECK-NEXT: call void @consume.double.ptr(double* %[[PREFIX:.+]])
46 ; CHECK-NEXT: call void @consume.i32.ptr(i32* %[[DATA:.+]])
47 ; CHECK-NEXT: call void @consume.double.ptr(double* %[[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, %f.Frame* %FramePtr, i32 0, i32 2
53 ; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 4
54 ; CHECK: %[[SUFFIX:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 3
55 ; CHECK: call void @consume.double.ptr(double* %[[PREFIX]])
56 ; CHECK-NEXT: call void @consume.i32.ptr(i32* %[[DATA]])
57 ; CHECK-NEXT: call void @consume.double.ptr(double* %[[SUFFIX]])
59 declare i8* @llvm.coro.free(token, i8*)
60 declare i32 @llvm.coro.size.i32()
61 declare i8 @llvm.coro.suspend(token, i1)
62 declare void @llvm.coro.resume(i8*)
63 declare void @llvm.coro.destroy(i8*)
65 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
66 declare i1 @llvm.coro.alloc(token)
67 declare i8* @llvm.coro.begin(token, i8*)
68 declare i1 @llvm.coro.end(i8*, i1)
70 declare noalias i8* @malloc(i32)
71 declare double @print(double)
72 declare void @free(i8*)