1 ; Check that we will insert the correct padding if natural alignment of the
2 ; spilled data does not match the alignment specified in alloca instruction.
3 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
5 %PackedStruct = type <{ i64 }>
7 declare void @consume(%PackedStruct*)
9 define i8* @f() "coroutine.presplit"="1" {
11 %data = alloca %PackedStruct, align 32
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(%PackedStruct* %data)
17 %0 = call i8 @llvm.coro.suspend(token none, i1 false)
18 switch i8 %0, label %suspend [i8 0, label %resume
21 call void @consume(%PackedStruct* %data)
25 %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
26 call void @free(i8* %mem)
29 call i1 @llvm.coro.end(i8* %hdl, i1 0)
33 ; See if the padding was inserted before PackedStruct
34 ; CHECK-LABEL: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, i1, [15 x i8], %PackedStruct }
36 ; See if we used correct index to access packed struct (padding is field 3)
38 ; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 4
39 ; CHECK-NEXT: call void @consume(%PackedStruct* %[[DATA]])
42 ; See if we used correct index to access packed struct (padding is field 3)
43 ; CHECK-LABEL: @f.resume(
44 ; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 4
45 ; CHECK-NEXT: call void @consume(%PackedStruct* %[[DATA]])
48 declare i8* @llvm.coro.free(token, i8*)
49 declare i32 @llvm.coro.size.i32()
50 declare i8 @llvm.coro.suspend(token, i1)
51 declare void @llvm.coro.resume(i8*)
52 declare void @llvm.coro.destroy(i8*)
54 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
55 declare i1 @llvm.coro.alloc(token)
56 declare i8* @llvm.coro.begin(token, i8*)
57 declare i1 @llvm.coro.end(i8*, i1)
59 declare noalias i8* @malloc(i32)
60 declare double @print(double)
61 declare void @free(i8*)