@@ -303,7 +303,7 @@ The LLVM IR for this coroutine looks like this:
303303 call void @free(ptr %mem)
304304 br label %suspend
305305 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)
307307 ret ptr %hdl
308308 }
309309
@@ -637,7 +637,7 @@ store the current value produced by a coroutine.
637637 call void @free(ptr %mem)
638638 br label %suspend
639639 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)
641641 ret ptr %hdl
642642 }
643643
@@ -806,7 +806,7 @@ The LLVM IR for a coroutine using a Coroutine with a custom ABI looks like:
806806 call void @free(ptr %mem)
807807 br label %suspend
808808 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)
810810 ret ptr %hdl
811811 }
812812
@@ -1444,7 +1444,7 @@ A frontend should emit function attribute `presplitcoroutine` for the coroutine.
14441444^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14451445::
14461446
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>)
14481448
14491449Overview:
14501450"""""""""
@@ -1502,8 +1502,9 @@ For landingpad based exception model, it is expected that frontend uses the
15021502.. code-block :: llvm
15031503
15041504 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
15071508
15081509 cleanup.cont:
15091510 ; rest of the cleanup
@@ -1515,10 +1516,10 @@ For landingpad based exception model, it is expected that frontend uses the
15151516 %lpad.val29 = insertvalue { ptr, i32 } %lpad.val, i32 %sel, 1
15161517 resume { ptr, i32 } %lpad.val29
15171518
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 .
15221523
15231524For Windows Exception handling model, a frontend should attach a funclet bundle
15241525referring to an enclosing cleanuppad as follows:
@@ -1527,7 +1528,7 @@ referring to an enclosing cleanuppad as follows:
15271528
15281529 ehcleanup:
15291530 %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) ]
15311532 cleanupret from %tok unwind label %RestOfTheCleanup
15321533
15331534 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:
15921593
15931594 cleanup:
15941595 %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)
15961597 unreachable
15971598
15981599 ...
@@ -1604,7 +1605,7 @@ The number of arguments must match the return type of the continuation function:
16041605^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16051606::
16061607
1607- declare i1 @llvm.coro.end.async(ptr <handle>, i1 <unwind>, ...)
1608+ declare void @llvm.coro.end.async(ptr <handle>, i1 <unwind>, ...)
16081609
16091610Overview:
16101611"""""""""
@@ -1635,10 +1636,10 @@ the function call.
16351636
16361637.. code-block :: llvm
16371638
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)
16421643 unreachable
16431644
16441645 .. _coro.suspend :
@@ -2117,6 +2118,30 @@ Example:
21172118 %hdl.result = ... ; get address of returned coroutine handle
21182119 ret ptr %hdl.result
21192120
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+
21202145Coroutine Transformation Passes
21212146===============================
21222147CoroEarly
0 commit comments