1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs
2 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse,simplifycfg,coro-cleanup' -S | FileCheck %s
4 define ptr @f(ptr %buffer, i32 %n) presplitcoroutine {
6 %id = call token @llvm.coro.id.retcon(i32 8, i32 4, ptr %buffer, ptr @prototype, ptr @allocate, ptr @deallocate)
7 %hdl = call ptr @llvm.coro.begin(token %id, ptr null)
8 %value0 = call i32 (...) @llvm.coro.suspend.retcon.i32()
9 %sum0 = call i32 @add(i32 %n, i32 %value0)
10 %value1 = call i32 (...) @llvm.coro.suspend.retcon.i32()
11 %sum1 = call i32 @add(i32 %sum0, i32 %value0)
12 %sum2 = call i32 @add(i32 %sum1, i32 %value1)
13 %value2 = call i32 (...) @llvm.coro.suspend.retcon.i32()
14 %sum3 = call i32 @add(i32 %sum2, i32 %value0)
15 %sum4 = call i32 @add(i32 %sum3, i32 %value1)
16 %sum5 = call i32 @add(i32 %sum4, i32 %value2)
17 call void @print(i32 %sum5)
18 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
22 declare token @llvm.coro.id.retcon(i32, i32, ptr, ptr, ptr, ptr)
23 declare ptr @llvm.coro.begin(token, ptr)
24 declare i32 @llvm.coro.suspend.retcon.i32(...)
25 declare i1 @llvm.coro.end(ptr, i1, token)
26 declare ptr @llvm.coro.prepare.retcon(ptr)
28 declare ptr @prototype(ptr, i32)
30 declare noalias ptr @allocate(i32 %size)
31 declare void @deallocate(ptr %ptr)
33 declare i32 @add(i32, i32)
34 declare void @print(i32)
38 ; CHECK-NEXT: [[TMP0:%.*]] = call ptr @allocate(i32 20)
39 ; CHECK-NEXT: store ptr [[TMP0]], ptr [[BUFFER:%.*]], align 8
40 ; CHECK-NEXT: store i32 [[N:%.*]], ptr [[TMP0]], align 4
41 ; CHECK-NEXT: ret ptr @f.resume.0
44 ; CHECK-LABEL: @f.resume.0(
45 ; CHECK-NEXT: entryresume.0:
46 ; CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
47 ; CHECK-NEXT: [[VALUE0_SPILL_ADDR:%.*]] = getelementptr inbounds [[F_FRAME:%.*]], ptr [[TMP2]], i32 0, i32 1
48 ; CHECK-NEXT: store i32 [[TMP1:%.*]], ptr [[VALUE0_SPILL_ADDR]], align 4
49 ; CHECK-NEXT: [[N_RELOAD:%.*]] = load i32, ptr [[TMP2]], align 4
50 ; CHECK-NEXT: [[SUM0:%.*]] = call i32 @add(i32 [[N_RELOAD]], i32 [[TMP1]])
51 ; CHECK-NEXT: [[SUM0_SPILL_ADDR:%.*]] = getelementptr inbounds [[F_FRAME]], ptr [[TMP2]], i32 0, i32 2
52 ; CHECK-NEXT: store i32 [[SUM0]], ptr [[SUM0_SPILL_ADDR]], align 4
53 ; CHECK-NEXT: ret ptr @f.resume.1
56 ; CHECK-LABEL: @f.resume.1(
57 ; CHECK-NEXT: entryresume.1:
58 ; CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
59 ; CHECK-NEXT: [[VALUE1_SPILL_ADDR:%.*]] = getelementptr inbounds [[F_FRAME:%.*]], ptr [[TMP2]], i32 0, i32 3
60 ; CHECK-NEXT: store i32 [[TMP1:%.*]], ptr [[VALUE1_SPILL_ADDR]], align 4
61 ; CHECK-NEXT: [[SUM0_RELOAD_ADDR:%.*]] = getelementptr inbounds [[F_FRAME]], ptr [[TMP2]], i32 0, i32 2
62 ; CHECK-NEXT: [[SUM0_RELOAD:%.*]] = load i32, ptr [[SUM0_RELOAD_ADDR]], align 4
63 ; CHECK-NEXT: [[VALUE0_RELOAD_ADDR5:%.*]] = getelementptr inbounds [[F_FRAME]], ptr [[TMP2]], i32 0, i32 1
64 ; CHECK-NEXT: [[VALUE0_RELOAD6:%.*]] = load i32, ptr [[VALUE0_RELOAD_ADDR5]], align 4
65 ; CHECK-NEXT: [[SUM1:%.*]] = call i32 @add(i32 [[SUM0_RELOAD]], i32 [[VALUE0_RELOAD6]])
66 ; CHECK-NEXT: [[SUM2:%.*]] = call i32 @add(i32 [[SUM1]], i32 [[TMP1]])
67 ; CHECK-NEXT: [[SUM2_SPILL_ADDR:%.*]] = getelementptr inbounds [[F_FRAME]], ptr [[TMP2]], i32 0, i32 4
68 ; CHECK-NEXT: store i32 [[SUM2]], ptr [[SUM2_SPILL_ADDR]], align 4
69 ; CHECK-NEXT: ret ptr @f.resume.2
72 ; CHECK-LABEL: @f.resume.2(
73 ; CHECK-NEXT: entryresume.2:
74 ; CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
75 ; CHECK-NEXT: [[SUM2_RELOAD_ADDR:%.*]] = getelementptr inbounds [[F_FRAME:%.*]], ptr [[TMP2]], i32 0, i32 4
76 ; CHECK-NEXT: [[SUM2_RELOAD:%.*]] = load i32, ptr [[SUM2_RELOAD_ADDR]], align 4
77 ; CHECK-NEXT: [[VALUE1_RELOAD_ADDR:%.*]] = getelementptr inbounds [[F_FRAME]], ptr [[TMP2]], i32 0, i32 3
78 ; CHECK-NEXT: [[VALUE1_RELOAD:%.*]] = load i32, ptr [[VALUE1_RELOAD_ADDR]], align 4
79 ; CHECK-NEXT: [[VALUE0_RELOAD_ADDR:%.*]] = getelementptr inbounds [[F_FRAME]], ptr [[TMP2]], i32 0, i32 1
80 ; CHECK-NEXT: [[VALUE0_RELOAD:%.*]] = load i32, ptr [[VALUE0_RELOAD_ADDR]], align 4
81 ; CHECK-NEXT: [[SUM3:%.*]] = call i32 @add(i32 [[SUM2_RELOAD]], i32 [[VALUE0_RELOAD]])
82 ; CHECK-NEXT: [[SUM4:%.*]] = call i32 @add(i32 [[SUM3]], i32 [[VALUE1_RELOAD]])
83 ; CHECK-NEXT: [[SUM5:%.*]] = call i32 @add(i32 [[SUM4]], i32 [[TMP1:%.*]])
84 ; CHECK-NEXT: call void @print(i32 [[SUM5]])
85 ; CHECK-NEXT: call void @deallocate(ptr [[TMP2]])
86 ; CHECK-NEXT: ret ptr null