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,coro-cleanup' -S | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.12.0"
6 define {i8*, i32*} @f(i8* %buffer, i32* %ptr) "coroutine.presplit"="1" {
8 %temp = alloca i32, align 4
9 %id = call token @llvm.coro.id.retcon.once(i32 8, i32 8, i8* %buffer, i8* bitcast (void (i8*, i1)* @prototype to i8*), i8* bitcast (i8* (i32)* @allocate to i8*), i8* bitcast (void (i8*)* @deallocate to i8*))
10 %hdl = call i8* @llvm.coro.begin(token %id, i8* null)
11 %oldvalue = load i32, i32* %ptr
12 store i32 %oldvalue, i32* %temp
13 %unwind = call i1 (...) @llvm.coro.suspend.retcon.i1(i32* %temp)
14 br i1 %unwind, label %cleanup, label %cont
17 %newvalue = load i32, i32* %temp
18 store i32 %newvalue, i32* %ptr
22 call i1 @llvm.coro.end(i8* %hdl, i1 0)
28 declare token @llvm.coro.id.retcon.once(i32, i32, i8*, i8*, i8*, i8*)
29 declare i8* @llvm.coro.begin(token, i8*)
30 declare i1 @llvm.coro.suspend.retcon.i1(...)
31 declare i1 @llvm.coro.end(i8*, i1)
33 declare void @prototype(i8*, i1 zeroext)
35 declare noalias i8* @allocate(i32 %size)
36 declare fastcc void @deallocate(i8* %ptr)
38 declare void @print(i32)
41 ; CHECK-NEXT: [[TMP0:%.*]] = call i8* @allocate(i32 16)
42 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[BUFFER:%.*]] to i8**
43 ; CHECK-NEXT: store i8* [[TMP0]], i8** [[TMP1]], align 8
44 ; CHECK-NEXT: [[FRAMEPTR:%.*]] = bitcast i8* [[TMP0]] to %f.Frame*
45 ; CHECK-NEXT: [[TEMP:%.*]] = getelementptr inbounds [[F_FRAME:%.*]], %f.Frame* [[FRAMEPTR]], i32 0, i32 1
46 ; CHECK-NEXT: [[PTR_SPILL_ADDR:%.*]] = getelementptr inbounds [[F_FRAME]], %f.Frame* [[FRAMEPTR]], i32 0, i32 0
47 ; CHECK-NEXT: store i32* [[PTR:%.*]], i32** [[PTR_SPILL_ADDR]], align 8
48 ; CHECK-NEXT: [[OLDVALUE:%.*]] = load i32, i32* [[PTR]], align 4
49 ; CHECK-NEXT: store i32 [[OLDVALUE]], i32* [[TEMP]], align 4
50 ; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { i8*, i32* } { i8* bitcast (void (i8*, i1)* @f.resume.0 to i8*), i32* undef }, i32* [[TEMP]], 1
51 ; CHECK-NEXT: ret { i8*, i32* } [[TMP2]]
54 ; CHECK-LABEL: @f.resume.0(
55 ; CHECK-NEXT: entryresume.0:
56 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP0:%.*]] to %f.Frame**
57 ; CHECK-NEXT: [[FRAMEPTR:%.*]] = load %f.Frame*, %f.Frame** [[TMP2]], align 8
58 ; CHECK-NEXT: [[TEMP:%.*]] = getelementptr inbounds [[F_FRAME:%.*]], %f.Frame* [[FRAMEPTR]], i32 0, i32 1
59 ; CHECK-NEXT: br i1 [[TMP1:%.*]], label [[COROEND:%.*]], label [[CONT:%.*]]
61 ; CHECK-NEXT: [[PTR_RELOAD_ADDR:%.*]] = getelementptr inbounds [[F_FRAME]], %f.Frame* [[FRAMEPTR]], i32 0, i32 0
62 ; CHECK-NEXT: [[PTR_RELOAD:%.*]] = load i32*, i32** [[PTR_RELOAD_ADDR]], align 8
63 ; CHECK-NEXT: [[NEWVALUE:%.*]] = load i32, i32* [[TEMP]], align 4
64 ; CHECK-NEXT: store i32 [[NEWVALUE]], i32* [[PTR_RELOAD]], align 4
65 ; CHECK-NEXT: br label [[COROEND]]
67 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast %f.Frame* [[FRAMEPTR]] to i8*
68 ; CHECK-NEXT: call fastcc void @deallocate(i8* [[TMP3]])
69 ; CHECK-NEXT: ret void