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 i8* @f(i64 %this) "coroutine.presplit"="1" personality i32 0 {
6 %this.addr = alloca i64
7 store i64 %this, i64* %this.addr
8 %this1 = load i64, i64* %this.addr
9 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
10 %size = call i32 @llvm.coro.size.i32()
11 %alloc = call i8* @malloc(i32 %size)
12 %hdl = call i8* @llvm.coro.begin(token %id, i8* %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 i8* @llvm.coro.free(token %id, i8* %hdl)
26 call void @free(i8* %mem)
29 call i1 @llvm.coro.end(i8* %hdl, i1 0)
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 { void (%f.Frame*)*, void (%f.Frame*)*, 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, %f.Frame* %FramePtr, i32 0, i32 2
43 ; CHECK: store double %r, double* %r.spill.addr
46 ; See if the float was loaded from the frame
47 ; CHECK-LABEL: @f.resume(%f.Frame* noalias nonnull align 8
48 ; CHECK: %r.reload = load double, double* %r.reload.addr
49 ; CHECK: call double @print(double %r.reload)
52 declare i8* @llvm.coro.free(token, i8*)
53 declare i32 @llvm.coro.size.i32()
54 declare i8 @llvm.coro.suspend(token, i1)
55 declare void @llvm.coro.resume(i8*)
56 declare void @llvm.coro.destroy(i8*)
58 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
59 declare i1 @llvm.coro.alloc(token)
60 declare i8* @llvm.coro.begin(token, i8*)
61 declare i1 @llvm.coro.end(i8*, i1)
63 declare noalias i8* @malloc(i32)
64 declare double @print(double)
65 declare void @print2(i64)
66 declare void @free(i8*)