1 ; Verifies that we materialize instruction across suspend points
2 ; RUN: opt < %s -coro-split -S | FileCheck %s
4 define i8* @f(i32 %n) "coroutine.presplit"="1" {
6 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
7 %size = call i32 @llvm.coro.size.i32()
8 %alloc = call i8* @malloc(i32 %size)
9 %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
12 %sp1 = call i8 @llvm.coro.suspend(token none, i1 false)
13 switch i8 %sp1, label %suspend [i8 0, label %resume1
16 %inc2 = add i32 %inc1, 1
17 %sp2 = call i8 @llvm.coro.suspend(token none, i1 false)
18 switch i8 %sp1, label %suspend [i8 0, label %resume2
22 call void @print(i32 %inc1)
23 call void @print(i32 %inc2)
27 %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
28 call void @free(i8* %mem)
31 call i1 @llvm.coro.end(i8* %hdl, i1 0)
35 ; See that we only spilled one value
36 ; CHECK: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, i1, i1, i32 }
39 declare i8* @llvm.coro.free(token, i8*)
40 declare i32 @llvm.coro.size.i32()
41 declare i8 @llvm.coro.suspend(token, i1)
42 declare void @llvm.coro.resume(i8*)
43 declare void @llvm.coro.destroy(i8*)
45 declare token @llvm.coro.id(i32, i8*, i8*, i8*)
46 declare i1 @llvm.coro.alloc(token)
47 declare i8* @llvm.coro.begin(token, i8*)
48 declare i1 @llvm.coro.end(i8*, i1)
50 declare noalias i8* @malloc(i32)
51 declare void @print(i32)
52 declare void @free(i8*)