1 ; Corresponding to coro-split-sink-lifetime-01.ll. This file tests that whether the CoroFrame
2 ; pass knows the operand of lifetime.start intrinsic may be GEP as well.
3 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse,simplifycfg' -S | FileCheck %s
5 %"struct.std::coroutine_handle" = type { ptr }
6 %"struct.std::coroutine_handle.0" = type { %"struct.std::coroutine_handle" }
7 %"struct.lean_future<int>::Awaiter" = type { i32, %"struct.std::coroutine_handle.0" }
9 declare ptr @malloc(i64)
10 declare void @print(i32)
12 %i8.array = type { [100 x i8] }
13 declare void @consume.i8.array(ptr)
15 define void @a.gep() presplitcoroutine {
17 %ref.tmp7 = alloca %"struct.lean_future<int>::Awaiter", align 8
18 %testval = alloca %i8.array
19 ; lifetime of %testval starts here, but not used until await.ready.
20 call void @llvm.lifetime.start.p0(i64 100, ptr %testval)
21 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
22 %alloc = call ptr @malloc(i64 16) #3
23 %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)
25 %save = call token @llvm.coro.save(ptr null)
26 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
27 switch i8 %suspend, label %exit [
28 i8 0, label %await.ready
32 %StrayCoroSave = call token @llvm.coro.save(ptr null)
33 %val = load i32, ptr %ref.tmp7
34 call void @consume.i8.array(ptr %testval)
35 call void @llvm.lifetime.end.p0(i64 100, ptr %testval)
36 call void @print(i32 %val)
39 call i1 @llvm.coro.end(ptr null, i1 false, token none)
42 ; CHECK-LABEL: @a.gep.resume(
43 ; CHECK: %testval = alloca %i8.array
44 ; CHECK: call void @llvm.lifetime.start.p0(i64 100, ptr %testval)
45 ; CHECK-NEXT: %val = load i32, ptr %ref.tmp7
46 ; CHECK-NEXT: call void @consume.i8.array(ptr %testval)
47 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 100, ptr %testval)
48 ; CHECK-NEXT: call void @print(i32 %val)
49 ; CHECK-NEXT: ret void
51 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)
52 declare i1 @llvm.coro.alloc(token) #3
53 declare noalias nonnull ptr @"\01??2@YAPEAX_K@Z"(i64) local_unnamed_addr
54 declare i64 @llvm.coro.size.i64() #5
55 declare ptr @llvm.coro.begin(token, ptr writeonly) #3
56 declare void @"\01?puts@@YAXZZ"(...)
57 declare token @llvm.coro.save(ptr) #3
58 declare ptr @llvm.coro.frame() #5
59 declare i8 @llvm.coro.suspend(token, i1) #3
60 declare void @"\01??3@YAXPEAX@Z"(ptr) local_unnamed_addr #10
61 declare ptr @llvm.coro.free(token, ptr nocapture readonly) #2
62 declare i1 @llvm.coro.end(ptr, i1, token) #3
63 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #4
64 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #4