1 ; Check that we can handle spills of the result of the invoke instruction
2 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 define ptr @f(i64 %this) presplitcoroutine personality i32 0 {
6 %this.addr = alloca i64
7 store i64 %this, ptr %this.addr
8 %this1 = load i64, ptr %this.addr
9 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
10 %size = call i32 @llvm.coro.size.i32()
11 %alloc = call ptr @malloc(i32 %size)
12 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
13 %r = invoke double @print(double 0.0) to label %cont unwind label %pad
16 %0 = call i8 @llvm.coro.suspend(token none, i1 false)
17 switch i8 %0, label %suspend [i8 0, label %resume
20 call double @print(double %r)
21 call void @print2(i64 %this1)
25 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
26 call void @free(ptr %mem)
29 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
32 %tok = cleanuppad within none []
33 cleanupret from %tok unwind to caller
36 ; See if the float was added to the frame
37 ; CHECK-LABEL: %f.Frame = type { ptr, ptr, double, i64, i1 }
39 ; See if the float was spilled into the frame
41 ; CHECK: %r = call double @print(
42 ; CHECK: %r.spill.addr = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 2
43 ; CHECK: store double %r, ptr %r.spill.addr
46 ; See if the float was loaded from the frame
47 ; CHECK-LABEL: @f.resume(ptr noundef nonnull align 8
48 ; CHECK: %r.reload = load double, ptr %r.reload.addr
49 ; CHECK: call double @print(double %r.reload)
52 declare ptr @llvm.coro.free(token, ptr)
53 declare i32 @llvm.coro.size.i32()
54 declare i8 @llvm.coro.suspend(token, i1)
55 declare void @llvm.coro.resume(ptr)
56 declare void @llvm.coro.destroy(ptr)
58 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
59 declare i1 @llvm.coro.alloc(token)
60 declare ptr @llvm.coro.begin(token, ptr)
61 declare i1 @llvm.coro.end(ptr, i1, token)
63 declare noalias ptr @malloc(i32)
64 declare double @print(double)
65 declare void @print2(i64)
66 declare void @free(ptr)