1 ; Test that in some simple cases allocas will not live on the frame even
2 ; though their pointers are stored.
3 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
7 define ptr @f() presplitcoroutine {
9 %0 = alloca %"handle", align 8
10 %1 = alloca ptr, align 8
11 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
12 %size = call i32 @llvm.coro.size.i32()
13 %alloc = call ptr @malloc(i32 %size)
14 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
18 %2 = call ptr @await_suspend()
19 store ptr %2, ptr %0, align 8
20 call void @llvm.lifetime.start.p0(i64 8, ptr %1)
21 store ptr %0, ptr %1, align 8
22 %3 = load ptr, ptr %1, align 8
23 %4 = load ptr, ptr %3, align 8
24 call void @llvm.lifetime.end.p0(i64 8, ptr %1)
28 %sp1 = call i8 @llvm.coro.suspend(token none, i1 false)
29 switch i8 %sp1, label %suspend [i8 0, label %resume
35 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
36 call void @free(ptr %mem)
40 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
44 ; CHECK: %f.Frame = type { ptr, ptr, i1 }
47 ; CHECK-NEXT: [[TMP0:%.*]] = alloca [[HANDLE:%.*]], align 8
48 ; CHECK-NEXT: [[TMP1:%.*]] = alloca ptr, align 8
50 ; CHECK: [[TMP2:%.*]] = call ptr @await_suspend()
51 ; CHECK-NEXT: store ptr [[TMP2]], ptr [[TMP0]], align 8
52 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 8, ptr [[TMP1]])
53 ; CHECK-NEXT: store ptr [[TMP0]], ptr [[TMP1]], align 8
54 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr [[TMP1]])
57 declare ptr @llvm.coro.free(token, ptr)
58 declare i32 @llvm.coro.size.i32()
59 declare i8 @llvm.coro.suspend(token, i1)
60 declare void @llvm.coro.resume(ptr)
61 declare void @llvm.coro.destroy(ptr)
63 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
64 declare i1 @llvm.coro.alloc(token)
65 declare ptr @llvm.coro.begin(token, ptr)
66 declare i1 @llvm.coro.end(ptr, i1, token)
68 declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
69 declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
71 declare ptr @await_suspend()
72 declare void @print(ptr nocapture)
73 declare noalias ptr @malloc(i32)
74 declare void @free(ptr)