1 ; Tests that variables of different type with incompatible alignment in a Corotuine whose
2 ; lifetime range is not overlapping each other re-use the same slot in CorotuineFrame.
3 ; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
4 %"struct.task::promise_type" = type { i8 }
5 %struct.awaitable = type { i8 }
6 %struct.big_structure = type { [500 x i8] }
7 %struct.big_structure.2 = type { [400 x i8] }
8 declare ptr @malloc(i64)
9 declare void @consume(ptr)
10 declare void @consume.2(ptr)
11 define void @a(i1 zeroext %cond) presplitcoroutine {
13 %__promise = alloca %"struct.task::promise_type", align 1
14 %a = alloca %struct.big_structure, align 32
15 %ref.tmp7 = alloca %struct.awaitable, align 1
16 %b = alloca %struct.big_structure.2, align 16
17 %ref.tmp18 = alloca %struct.awaitable, align 1
18 %0 = call token @llvm.coro.id(i32 16, ptr nonnull %__promise, ptr @a, ptr null)
21 %1 = call noalias nonnull ptr @llvm.coro.begin(token %0, ptr null)
22 call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %__promise)
23 br i1 %cond, label %if.then, label %if.else
25 call void @llvm.lifetime.start.p0(i64 500, ptr nonnull %a)
26 call void @consume(ptr nonnull %a)
27 %save = call token @llvm.coro.save(ptr null)
28 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
29 switch i8 %suspend, label %coro.ret [
30 i8 0, label %await.ready
34 call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %a)
37 call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %b)
38 call void @consume.2(ptr nonnull %b)
39 %save2 = call token @llvm.coro.save(ptr null)
40 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
41 switch i8 %suspend2, label %coro.ret [
42 i8 0, label %await2.ready
46 call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %b)
49 call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %a)
52 call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %b)
55 call ptr @llvm.coro.free(token %0, ptr %1)
58 call i1 @llvm.coro.end(ptr null, i1 false, token none)
61 ; CHECK: %a.Frame = type { ptr, ptr, %"struct.task::promise_type", i1, [14 x i8], %struct.big_structure }
62 ; CHECK-LABEL: @a.resume(
64 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)
65 declare i1 @llvm.coro.alloc(token) #3
66 declare i64 @llvm.coro.size.i64() #5
67 declare ptr @llvm.coro.begin(token, ptr writeonly) #3
68 declare token @llvm.coro.save(ptr) #3
69 declare ptr @llvm.coro.frame() #5
70 declare i8 @llvm.coro.suspend(token, i1) #3
71 declare ptr @llvm.coro.free(token, ptr nocapture readonly) #2
72 declare i1 @llvm.coro.end(ptr, i1, token) #3
73 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #4
74 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #4