1 ; Tests that allocas escaped through function calls will live on the frame.
2 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 define i8* @f() "coroutine.presplit"="1" {
8 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
9 %size = call i32 @llvm.coro.size.i32()
10 %alloc = call i8* @malloc(i32 %size)
11 %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
12 %x.alias = bitcast i64* %x to i32*
13 call void @capture_call(i32* %x.alias)
14 %y.alias = bitcast i64* %y to i32*
15 call void @nocapture_call(i32* %y.alias)
16 %sp1 = call i8 @llvm.coro.suspend(token none, i1 false)
17 switch i8 %sp1, label %suspend [i8 0, label %resume
23 %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
24 call void @free(i8* %mem)
28 call i1 @llvm.coro.end(i8* %hdl, i1 0)
32 ; %x needs to go to the frame since it's escaped; %y will stay as local since it doesn't escape.
33 ; CHECK: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, i64, i1 }
34 ; CHECK-LABEL: define i8* @f()
35 ; CHECK: %y = alloca i64, align 8
36 ; CHECK: %x.reload.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 2
37 ; CHECK: %x.alias = bitcast i64* %x.reload.addr to i32*
38 ; CHECK: call void @capture_call(i32* %x.alias)
39 ; CHECK: %y.alias = bitcast i64* %y to i32*
40 ; CHECK: call void @nocapture_call(i32* %y.alias)
42 declare i8* @llvm.coro.free(token, i8*)
43 declare i32 @llvm.coro.size.i32()
44 declare i8 @llvm.coro.suspend(token, i1)
45 declare void @llvm.coro.resume(i8*)
46 declare void @llvm.coro.destroy(i8*)
48 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
49 declare i1 @llvm.coro.alloc(token)
50 declare i8* @llvm.coro.begin(token, i8*)
51 declare i1 @llvm.coro.end(i8*, i1)
53 declare void @capture_call(i32*)
54 declare void @nocapture_call(i32* nocapture)
55 declare noalias i8* @malloc(i32)
56 declare void @free(i8*)