1 ; Tests that the coro.align intrinsic could be lowered to correct alignment
2 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 define ptr @f() presplitcoroutine {
6 %x = alloca i64, align 16
7 %y = alloca i32, align 32
8 %z = alloca i32, align 16
9 %alpha = alloca i1, align 8
10 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
11 %size = call i32 @llvm.coro.size.i32()
12 %align = call i32 @llvm.coro.align.i32()
13 %alloc = call ptr @aligned_alloc(i32 %align, i32 %size)
14 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
15 %sp1 = call i8 @llvm.coro.suspend(token none, i1 false)
16 switch i8 %sp1, label %suspend [i8 0, label %resume
19 call void @capture_call(ptr %x)
20 call void @capture_call(ptr %y)
21 call void @capture_call(ptr %z)
22 call void @capture_call(ptr %alpha)
26 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
27 call void @free(ptr %mem)
31 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
35 ; %x needs to go to the frame since it's escaped; %y will stay as local since it doesn't escape.
36 ; CHECK: %f.Frame = type { ptr, ptr, i64, i1, i1, [6 x i8], i32, [12 x i8], i32 }
37 ; CHECK-LABEL: define ptr @f()
38 ; CHECK: %[[ALLOC:.+]] = call ptr @aligned_alloc(i32 32, i32 56)
39 ; CHECK-NEXT: call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %[[ALLOC]])
41 declare ptr @llvm.coro.free(token, ptr)
42 declare i32 @llvm.coro.size.i32()
43 declare i32 @llvm.coro.align.i32()
44 declare i8 @llvm.coro.suspend(token, i1)
45 declare void @llvm.coro.resume(ptr)
46 declare void @llvm.coro.destroy(ptr)
48 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
49 declare i1 @llvm.coro.alloc(token)
50 declare ptr @llvm.coro.begin(token, ptr)
51 declare i1 @llvm.coro.end(ptr, i1, token)
53 declare void @capture_call(ptr)
54 declare void @nocapture_call(ptr nocapture)
55 declare noalias ptr @aligned_alloc(i32, i32)
56 declare void @free(ptr)