@@ -303,7 +303,7 @@ The LLVM IR for this coroutine looks like this:
303
303
call void @free(ptr %mem)
304
304
br label %suspend
305
305
suspend:
306
- %unused = call i1 @llvm.coro.end(ptr %hdl, i1 false, token none)
306
+ call void @llvm.coro.end(ptr %hdl, i1 false, token none)
307
307
ret ptr %hdl
308
308
}
309
309
@@ -637,7 +637,7 @@ store the current value produced by a coroutine.
637
637
call void @free(ptr %mem)
638
638
br label %suspend
639
639
suspend:
640
- %unused = call i1 @llvm.coro.end(ptr %hdl, i1 false, token none)
640
+ call void @llvm.coro.end(ptr %hdl, i1 false, token none)
641
641
ret ptr %hdl
642
642
}
643
643
@@ -806,7 +806,7 @@ The LLVM IR for a coroutine using a Coroutine with a custom ABI looks like:
806
806
call void @free(ptr %mem)
807
807
br label %suspend
808
808
suspend:
809
- %unused = call i1 @llvm.coro.end(ptr %hdl, i1 false, token none)
809
+ call void @llvm.coro.end(ptr %hdl, i1 false, token none)
810
810
ret ptr %hdl
811
811
}
812
812
@@ -1444,7 +1444,7 @@ A frontend should emit function attribute `presplitcoroutine` for the coroutine.
1444
1444
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1445
1445
::
1446
1446
1447
- declare i1 @llvm.coro.end(ptr <handle>, i1 <unwind>, token <result.token>)
1447
+ declare void @llvm.coro.end(ptr <handle>, i1 <unwind>, token <result.token>)
1448
1448
1449
1449
Overview:
1450
1450
"""""""""
@@ -1502,8 +1502,9 @@ For landingpad based exception model, it is expected that frontend uses the
1502
1502
.. code-block :: llvm
1503
1503
1504
1504
ehcleanup:
1505
- %InResumePart = call i1 @llvm.coro.end(ptr null, i1 true, token none)
1506
- br i1 %InResumePart, label %eh.resume, label %cleanup.cont
1505
+ call void @llvm.coro.end(ptr null, i1 true, token none)
1506
+ %InRamp = call i1 @llvm.coro.is_in_ramp()
1507
+ br i1 %InRamp, label %cleanup.cont, label %eh.resume
1507
1508
1508
1509
cleanup.cont:
1509
1510
; rest of the cleanup
@@ -1515,10 +1516,10 @@ For landingpad based exception model, it is expected that frontend uses the
1515
1516
%lpad.val29 = insertvalue { ptr, i32 } %lpad.val, i32 %sel, 1
1516
1517
resume { ptr, i32 } %lpad.val29
1517
1518
1518
- The `CoroSpit ` pass replaces `coro.end ` with ``True `` in the resume functions,
1519
- thus leading to immediate unwind to the caller, whereas in start function it
1520
- is replaced with ``False ``, thus allowing to proceed to the rest of the cleanup
1521
- code that is only needed during initial invocation of the coroutine .
1519
+ The `CoroSpit ` pass replaces `coro.is_in_ramp ` with ``True `` in the ramp functions,
1520
+ thus allowing to proceed to the rest of the cleanup code that is only needed during
1521
+ initial invocation of the coroutine. Otherwise, it is replaced with ``False ``,
1522
+ thus leading to immediate unwind to the caller .
1522
1523
1523
1524
For Windows Exception handling model, a frontend should attach a funclet bundle
1524
1525
referring to an enclosing cleanuppad as follows:
@@ -1527,7 +1528,7 @@ referring to an enclosing cleanuppad as follows:
1527
1528
1528
1529
ehcleanup:
1529
1530
%tok = cleanuppad within none []
1530
- %unused = call i1 @llvm.coro.end(ptr null, i1 true, token none) [ "funclet"(token %tok) ]
1531
+ call void @llvm.coro.end(ptr null, i1 true, token none) [ "funclet"(token %tok) ]
1531
1532
cleanupret from %tok unwind label %RestOfTheCleanup
1532
1533
1533
1534
The `CoroSplit ` pass, if the funclet bundle is present, will insert
@@ -1592,7 +1593,7 @@ The number of arguments must match the return type of the continuation function:
1592
1593
1593
1594
cleanup:
1594
1595
%tok = call token (...) @llvm.coro.end.results(i8 %val)
1595
- call i1 @llvm.coro.end(ptr %hdl, i1 0, token %tok)
1596
+ call void @llvm.coro.end(ptr %hdl, i1 0, token %tok)
1596
1597
unreachable
1597
1598
1598
1599
...
@@ -1604,7 +1605,7 @@ The number of arguments must match the return type of the continuation function:
1604
1605
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1605
1606
::
1606
1607
1607
- declare i1 @llvm.coro.end.async(ptr <handle>, i1 <unwind>, ...)
1608
+ declare void @llvm.coro.end.async(ptr <handle>, i1 <unwind>, ...)
1608
1609
1609
1610
Overview:
1610
1611
"""""""""
@@ -1635,10 +1636,10 @@ the function call.
1635
1636
1636
1637
.. code-block :: llvm
1637
1638
1638
- call i1 (ptr, i1, ...) @llvm.coro.end.async(
1639
- ptr %hdl, i1 0,
1640
- ptr @must_tail_call_return,
1641
- ptr %ctxt, ptr %task, ptr %actor)
1639
+ call void (ptr, i1, ...) @llvm.coro.end.async(
1640
+ ptr %hdl, i1 0,
1641
+ ptr @must_tail_call_return,
1642
+ ptr %ctxt, ptr %task, ptr %actor)
1642
1643
unreachable
1643
1644
1644
1645
.. _coro.suspend :
@@ -2117,6 +2118,30 @@ Example:
2117
2118
%hdl.result = ... ; get address of returned coroutine handle
2118
2119
ret ptr %hdl.result
2119
2120
2121
+ 'llvm.coro.is_in_ramp' Intrinsic
2122
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2123
+ ::
2124
+
2125
+ declare i1 @llvm.coro.is_in_ramp()
2126
+
2127
+ Overview:
2128
+ """""""""
2129
+
2130
+ The '``llvm.coro.is_in_ramp ``' intrinsic returns a bool value that marks coroutine ramp
2131
+ function and resume/destroy function.
2132
+
2133
+ Arguments:
2134
+ """"""""""
2135
+
2136
+ None
2137
+
2138
+ Semantics:
2139
+ """"""""""
2140
+
2141
+ The `CoroSpit ` pass replaces `coro.is_in_ramp ` with ``True `` ramp functions.
2142
+ Otherwise, it is replaced with ``False ``, allowing the frontend to separate
2143
+ ramp function and resume/destroy function.
2144
+
2120
2145
Coroutine Transformation Passes
2121
2146
===============================
2122
2147
CoroEarly
0 commit comments