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 i8* @f() "coroutine.presplit"="1" {
9 %0 = alloca %"handle", align 8
10 %1 = alloca %"handle"*, align 8
11 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
12 %size = call i32 @llvm.coro.size.i32()
13 %alloc = call i8* @malloc(i32 %size)
14 %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
18 %2 = call i8* @await_suspend()
19 %3 = getelementptr inbounds %"handle", %"handle"* %0, i32 0, i32 0
20 store i8* %2, i8** %3, align 8
21 %4 = bitcast %"handle"** %1 to i8*
22 call void @llvm.lifetime.start.p0i8(i64 8, i8* %4)
23 store %"handle"* %0, %"handle"** %1, align 8
24 %5 = load %"handle"*, %"handle"** %1, align 8
25 %6 = getelementptr inbounds %"handle", %"handle"* %5, i32 0, i32 0
26 %7 = load i8*, i8** %6, align 8
27 %8 = bitcast %"handle"** %1 to i8*
28 call void @llvm.lifetime.end.p0i8(i64 8, i8* %8)
32 %sp1 = call i8 @llvm.coro.suspend(token none, i1 false)
33 switch i8 %sp1, label %suspend [i8 0, label %resume
39 %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
40 call void @free(i8* %mem)
44 call i1 @llvm.coro.end(i8* %hdl, i1 0)
48 ; CHECK: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, i1 }
51 ; CHECK-NEXT: [[TMP0:%.*]] = alloca [[HANDLE:%.*]], align 8
52 ; CHECK-NEXT: [[TMP1:%.*]] = alloca %handle*, align 8
54 ; CHECK: [[TMP2:%.*]] = call i8* @await_suspend()
55 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [[HANDLE]], %handle* [[TMP0]], i32 0, i32 0
56 ; CHECK-NEXT: store i8* [[TMP2]], i8** [[TMP3]], align 8
57 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast %handle** [[TMP1]] to i8*
58 ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[TMP4]])
59 ; CHECK-NEXT: store %handle* [[TMP0]], %handle** [[TMP1]], align 8
60 ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[TMP4]])
63 declare i8* @llvm.coro.free(token, i8*)
64 declare i32 @llvm.coro.size.i32()
65 declare i8 @llvm.coro.suspend(token, i1)
66 declare void @llvm.coro.resume(i8*)
67 declare void @llvm.coro.destroy(i8*)
69 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
70 declare i1 @llvm.coro.alloc(token)
71 declare i8* @llvm.coro.begin(token, i8*)
72 declare i1 @llvm.coro.end(i8*, i1)
74 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
75 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
77 declare i8* @await_suspend()
78 declare void @print(i32* nocapture)
79 declare noalias i8* @malloc(i32)
80 declare void @free(i8*)