@@ -385,7 +385,7 @@ Outlined resume part of the coroutine will reside in function `f.resume`:
385
385
entry:
386
386
%inc.spill.addr = getelementptr %f.frame, ptr %frame.ptr.resume, i64 0, i32 2
387
387
%inc.spill = load i32, ptr %inc.spill.addr, align 4
388
- %inc = add i32 %n.val , 1
388
+ %inc = add i32 %inc.spill , 1
389
389
store i32 %inc, ptr %inc.spill.addr, align 4
390
390
tail call void @print(i32 %inc)
391
391
ret void
@@ -494,8 +494,13 @@ as the code in the previous section):
494
494
i8 1, label %cleanup]
495
495
496
496
In this case, the coroutine frame would include a suspend index that will
497
- indicate at which suspend point the coroutine needs to resume. The resume
498
- function will use an index to jump to an appropriate basic block and will look
497
+ indicate at which suspend point the coroutine needs to resume.
498
+
499
+ .. code-block :: llvm
500
+
501
+ %f.frame = type { ptr, ptr, i32, i32 }
502
+
503
+ The resume function will use an index to jump to an appropriate basic block and will look
499
504
as follows:
500
505
501
506
.. code-block :: llvm
@@ -507,10 +512,11 @@ as follows:
507
512
%switch = icmp eq i8 %index, 0
508
513
%n.addr = getelementptr inbounds %f.Frame, ptr %FramePtr, i64 0, i32 3
509
514
%n = load i32, ptr %n.addr, align 4
515
+
510
516
br i1 %switch, label %loop.resume, label %loop
511
517
512
518
loop.resume:
513
- %sub = xor i32 %n, -1
519
+ %sub = sub nsw i32 0, %n
514
520
call void @print(i32 %sub)
515
521
br label %suspend
516
522
loop:
@@ -586,7 +592,7 @@ correct resume point):
586
592
%save2 = call token @llvm.coro.save(ptr %hdl)
587
593
call void @async_op2(ptr %hdl)
588
594
%suspend2 = call i1 @llvm.coro.suspend(token %save2, i1 false)
589
- switch i8 %suspend1 , label %suspend [i8 0, label %resume2
595
+ switch i8 %suspend2 , label %suspend [i8 0, label %resume2
590
596
i8 1, label %cleanup]
591
597
592
598
.. _coroutine promise :
0 commit comments