1 ; Tests that if an alloca is escaped through storing the address,
2 ; the alloac will be put on the frame.
3 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
5 define i8* @f() presplitcoroutine {
9 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
10 %size = call i32 @llvm.coro.size.i32()
11 %alloc = call i8* @malloc(i32 %size)
12 %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
13 %x.alias = bitcast i64* %x to i32*
14 store i32* %x.alias, i32** %y
15 %sp1 = call i8 @llvm.coro.suspend(token none, i1 false)
16 switch i8 %sp1, label %suspend [i8 0, label %resume
19 %x1 = load i32*, i32** %y
20 call void @print(i32* %x1)
24 %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
25 call void @free(i8* %mem)
29 call i1 @llvm.coro.end(i8* %hdl, i1 0)
33 ; CHECK: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, i64, i32*, i1 }
34 ; CHECK-LABEL: define i8* @f()
35 ; CHECK: %x.reload.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 2
36 ; CHECK: %y.reload.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 3
37 ; CHECK: %x.alias = bitcast i64* %x.reload.addr to i32*
38 ; CHECK: store i32* %x.alias, i32** %y.reload.addr, align 8
40 declare i8* @llvm.coro.free(token, i8*)
41 declare i32 @llvm.coro.size.i32()
42 declare i8 @llvm.coro.suspend(token, i1)
43 declare void @llvm.coro.resume(i8*)
44 declare void @llvm.coro.destroy(i8*)
46 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
47 declare i1 @llvm.coro.alloc(token)
48 declare i8* @llvm.coro.begin(token, i8*)
49 declare i1 @llvm.coro.end(i8*, i1)
51 declare void @print(i32*)
52 declare noalias i8* @malloc(i32)
53 declare void @free(i8*)