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 4 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" } 8 9declare ptr @malloc(i64) 10declare void @print(i32) 11 12%i8.array = type { [100 x i8] } 13declare void @consume.i8.array(ptr) 14 15define void @a.gep() presplitcoroutine { 16entry: 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) 24 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 29 i8 1, label %exit 30 ] 31await.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) 37 br label %exit 38exit: 39 call i1 @llvm.coro.end(ptr null, i1 false, token none) 40 ret void 41} 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 50 51declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) 52declare i1 @llvm.coro.alloc(token) #3 53declare noalias nonnull ptr @"\01??2@YAPEAX_K@Z"(i64) local_unnamed_addr 54declare i64 @llvm.coro.size.i64() #5 55declare ptr @llvm.coro.begin(token, ptr writeonly) #3 56declare void @"\01?puts@@YAXZZ"(...) 57declare token @llvm.coro.save(ptr) #3 58declare ptr @llvm.coro.frame() #5 59declare i8 @llvm.coro.suspend(token, i1) #3 60declare void @"\01??3@YAXPEAX@Z"(ptr) local_unnamed_addr #10 61declare ptr @llvm.coro.free(token, ptr nocapture readonly) #2 62declare i1 @llvm.coro.end(ptr, i1, token) #3 63declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #4 64declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #4 65