summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/Coroutines/restart-trigger.ll
diff options
context:
space:
mode:
authorGor Nishanov <GorNishanov@gmail.com>2016-08-16 18:04:14 +0000
committerGor Nishanov <GorNishanov@gmail.com>2016-08-16 18:04:14 +0000
commit74309fa0143e59344dd0fbd0637117837b01da63 (patch)
treef82b9c9643a7fa48fbca07c607887f21d90bb3b1 /llvm/test/Transforms/Coroutines/restart-trigger.ll
parent68b97c7dc94b78a1752b67106464f48819cc341e (diff)
downloadbcm5719-llvm-74309fa0143e59344dd0fbd0637117837b01da63.tar.gz
bcm5719-llvm-74309fa0143e59344dd0fbd0637117837b01da63.zip
[Coroutines] Part 7: Split coroutine into subfunctions
Summary: This patch adds simple coroutine splitting logic to CoroSplit pass. Documentation and overview is here: http://llvm.org/docs/Coroutines.html. Upstreaming sequence (rough plan) 1.Add documentation. (https://reviews.llvm.org/D22603) 2.Add coroutine intrinsics. (https://reviews.llvm.org/D22659) ... 7. Split coroutine into subfunctions <= we are here 8. Coroutine Frame Building algorithm 9. Handle coroutine with unwinds 10+. The rest of the logic Reviewers: majnemer Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D23461 llvm-svn: 278830
Diffstat (limited to 'llvm/test/Transforms/Coroutines/restart-trigger.ll')
-rw-r--r--llvm/test/Transforms/Coroutines/restart-trigger.ll37
1 files changed, 31 insertions, 6 deletions
diff --git a/llvm/test/Transforms/Coroutines/restart-trigger.ll b/llvm/test/Transforms/Coroutines/restart-trigger.ll
index 8f0559fe213..c9414d1c8a5 100644
--- a/llvm/test/Transforms/Coroutines/restart-trigger.ll
+++ b/llvm/test/Transforms/Coroutines/restart-trigger.ll
@@ -7,12 +7,37 @@
; CHECK: CoroSplit: Processing coroutine 'f' state: 0
; CHECK-NEXT: CoroSplit: Processing coroutine 'f' state: 1
-declare token @llvm.coro.id(i32, i8*, i8*)
-declare i8* @llvm.coro.begin(token, i8*)
-
-; a coroutine start function
define void @f() {
%id = call token @llvm.coro.id(i32 0, i8* null, i8* null)
- call i8* @llvm.coro.begin(token %id, i8* null)
- ret void
+ %size = call i32 @llvm.coro.size.i32()
+ %alloc = call i8* @malloc(i32 %size)
+ %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
+ call void @print(i32 0)
+ %s1 = call i8 @llvm.coro.suspend(token none, i1 false)
+ switch i8 %s1, label %suspend [i8 0, label %resume
+ i8 1, label %cleanup]
+resume:
+ call void @print(i32 1)
+ br label %cleanup
+
+cleanup:
+ %mem = call i8* @llvm.coro.free(i8* %hdl)
+ call void @free(i8* %mem)
+ br label %suspend
+suspend:
+ call void @llvm.coro.end(i8* %hdl, i1 0)
+ ret void
}
+
+declare token @llvm.coro.id(i32, i8*, i8*)
+declare i8* @llvm.coro.begin(token, i8*)
+declare i8* @llvm.coro.free(i8*)
+declare i32 @llvm.coro.size.i32()
+declare i8 @llvm.coro.suspend(token, i1)
+declare void @llvm.coro.resume(i8*)
+declare void @llvm.coro.destroy(i8*)
+declare void @llvm.coro.end(i8*, i1)
+
+declare noalias i8* @malloc(i32)
+declare void @print(i32)
+declare void @free(i8*)
OpenPOWER on IntegriCloud