75 lines · plain
1; Tests that variables of different type in a Corotuine whose lifetime range is not overlapping each other2; re-use the same slot in Coroutine frame.3; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s4%"struct.task::promise_type" = type { i8 }5%struct.awaitable = type { i8 }6%struct.big_structure = type { [500 x i8] }7%struct.big_structure.2 = type { [300 x i8] }8declare ptr @malloc(i64)9declare void @consume(ptr)10declare void @consume.2(ptr)11define void @a(i1 zeroext %cond) presplitcoroutine {12entry:13 %__promise = alloca %"struct.task::promise_type", align 114 %a = alloca %struct.big_structure, align 115 %ref.tmp7 = alloca %struct.awaitable, align 116 %b = alloca %struct.big_structure.2, align 117 %ref.tmp18 = alloca %struct.awaitable, align 118 %0 = call token @llvm.coro.id(i32 16, ptr nonnull %__promise, ptr @a, ptr null)19 br label %init.ready20init.ready:21 %1 = call noalias nonnull ptr @llvm.coro.begin(token %0, ptr null)22 call void @llvm.lifetime.start.p0(ptr nonnull %__promise)23 br i1 %cond, label %if.then, label %if.else24if.then:25 call void @llvm.lifetime.start.p0(ptr nonnull %a)26 call void @consume(ptr nonnull %a)27 %save = call token @llvm.coro.save(ptr null)28 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)29 switch i8 %suspend, label %coro.ret [30 i8 0, label %await.ready31 i8 1, label %cleanup132 ]33await.ready:34 call void @llvm.lifetime.end.p0(ptr nonnull %a)35 br label %cleanup136if.else:37 call void @llvm.lifetime.start.p0(ptr nonnull %b)38 call void @consume.2(ptr nonnull %b)39 %save2 = call token @llvm.coro.save(ptr null)40 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)41 switch i8 %suspend2, label %coro.ret [42 i8 0, label %await2.ready43 i8 1, label %cleanup244 ]45await2.ready:46 call void @llvm.lifetime.end.p0(ptr nonnull %b)47 br label %cleanup248cleanup1:49 call void @llvm.lifetime.end.p0(ptr nonnull %a)50 br label %cleanup51cleanup2:52 call void @llvm.lifetime.end.p0(ptr nonnull %b)53 br label %cleanup54cleanup:55 call ptr @llvm.coro.free(token %0, ptr %1)56 br label %coro.ret57coro.ret:58 call void @llvm.coro.end(ptr null, i1 false, token none)59 ret void60}61; CHECK: %a.Frame = type { ptr, ptr, %"struct.task::promise_type", %struct.big_structure, i1 }62; CHECK-LABEL: @a.resume(63 64declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)65declare i1 @llvm.coro.alloc(token) #366declare i64 @llvm.coro.size.i64() #567declare ptr @llvm.coro.begin(token, ptr writeonly) #368declare token @llvm.coro.save(ptr) #369declare ptr @llvm.coro.frame() #570declare i8 @llvm.coro.suspend(token, i1) #371declare ptr @llvm.coro.free(token, ptr nocapture readonly) #272declare void @llvm.coro.end(ptr, i1, token) #373declare void @llvm.lifetime.start.p0(ptr nocapture) #474declare void @llvm.lifetime.end.p0(ptr nocapture) #475