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(i32*)
7 declare void @consume2(%"class.task::promise_type"*)
9 define i8* @f() "coroutine.presplit"="1" {
11 %data = alloca i32, align 4
12 %__promise = alloca %"class.task::promise_type", align 64
13 %pv = bitcast %"class.task::promise_type"* %__promise to i8*
14 %id = call token @llvm.coro.id(i32 0, i8* %pv, i8* null, i8* null)
15 %size = call i32 @llvm.coro.size.i32()
16 %alloc = call i8* @malloc(i32 %size)
17 %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
18 call void @consume(i32* %data)
19 %0 = call i8 @llvm.coro.suspend(token none, i1 false)
20 switch i8 %0, label %suspend [i8 0, label %resume
23 call void @consume(i32* %data)
24 call void @consume2(%"class.task::promise_type"* %__promise)
28 %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
29 call void @free(i8* %mem)
32 call i1 @llvm.coro.end(i8* %hdl, i1 0)
36 ; CHECK-LABEL: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, i32, i1, [43 x i8], %"class.task::promise_type" }
38 ; CHECK-LABEL: @f.resume(
39 ; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 5
40 ; CHECK: call void @consume2(%"class.task::promise_type"* %[[DATA]])
43 declare i8* @llvm.coro.free(token, i8*)
44 declare i32 @llvm.coro.size.i32()
45 declare i8 @llvm.coro.suspend(token, i1)
46 declare void @llvm.coro.resume(i8*)
47 declare void @llvm.coro.destroy(i8*)
49 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
50 declare i1 @llvm.coro.alloc(token)
51 declare i8* @llvm.coro.begin(token, i8*)
52 declare i1 @llvm.coro.end(i8*, i1)
54 declare noalias i8* @malloc(i32)
55 declare double @print(double)
56 declare void @free(i8*)