1 ; Check that promise object is reloaded from the correct index of the coro frame.
2 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 %"class.task::promise_type" = type { [64 x i8] }
6 declare void @consume(ptr)
7 declare void @consume2(ptr)
9 define ptr @f() presplitcoroutine {
11 %data = alloca i32, align 4
12 %__promise = alloca %"class.task::promise_type", align 64
13 %id = call token @llvm.coro.id(i32 0, ptr %__promise, ptr null, ptr null)
14 %size = call i32 @llvm.coro.size.i32()
15 %alloc = call ptr @malloc(i32 %size)
16 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
17 call void @consume(ptr %data)
18 %0 = call i8 @llvm.coro.suspend(token none, i1 false)
19 switch i8 %0, label %suspend [i8 0, label %resume
22 call void @consume(ptr %data)
23 call void @consume2(ptr %__promise)
27 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
28 call void @free(ptr %mem)
31 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
35 ; CHECK-LABEL: %f.Frame = type { ptr, ptr, i32, i1, [43 x i8], %"class.task::promise_type" }
37 ; CHECK-LABEL: @f.resume(
38 ; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 5
39 ; CHECK: call void @consume2(ptr %[[DATA]])
42 declare ptr @llvm.coro.free(token, ptr)
43 declare i32 @llvm.coro.size.i32()
44 declare i8 @llvm.coro.suspend(token, i1)
45 declare void @llvm.coro.resume(ptr)
46 declare void @llvm.coro.destroy(ptr)
48 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
49 declare i1 @llvm.coro.alloc(token)
50 declare ptr @llvm.coro.begin(token, ptr)
51 declare i1 @llvm.coro.end(ptr, i1, token)
53 declare noalias ptr @malloc(i32)
54 declare double @print(double)
55 declare void @free(ptr)