@@ -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 (ptr, i1, ...) @llvm.coro.end(ptr %hdl, i1 false)
306
+ %unused = call i1 @llvm.coro.end(ptr %hdl, i1 false, token none )
307
307
ret ptr %hdl
308
308
}
309
309
@@ -630,7 +630,7 @@ store the current value produced by a coroutine.
630
630
call void @free(ptr %mem)
631
631
br label %suspend
632
632
suspend:
633
- %unused = call i1 (ptr, i1, ...) @llvm.coro.end(ptr %hdl, i1 false)
633
+ %unused = call i1 @llvm.coro.end(ptr %hdl, i1 false, token none )
634
634
ret ptr %hdl
635
635
}
636
636
@@ -1326,7 +1326,7 @@ A frontend should emit function attribute `presplitcoroutine` for the coroutine.
1326
1326
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1327
1327
::
1328
1328
1329
- declare i1 @llvm.coro.end(ptr <handle>, i1 <unwind>, ... )
1329
+ declare i1 @llvm.coro.end(ptr <handle>, i1 <unwind>, token <result.token> )
1330
1330
1331
1331
Overview:
1332
1332
"""""""""
@@ -1347,20 +1347,11 @@ The second argument should be `true` if this coro.end is in the block that is
1347
1347
part of the unwind sequence leaving the coroutine body due to an exception and
1348
1348
`false ` otherwise.
1349
1349
1350
- Other arguments can only be specified for unique-suspend returned-continuation
1351
- coroutines where they will be normal returns of a coroutine continuation
1352
- function. The number of arguments must match the return type of the continuation
1353
- function:
1350
+ Non-trivial (non-none) token argument can only be specified for unique-suspend
1351
+ returned-continuation coroutines where it must be a token value produced by
1352
+ '``llvm.coro.end.results ``' intrinsic.
1354
1353
1355
- - if the return type of the continuation function is ``void `` there must be no
1356
- extra argumets
1357
-
1358
- - if the return type of the continuation function is a ``struct ``, the arguments
1359
- will be element types of that ``struct `` in order;
1360
-
1361
- - otherwise, it is just the return value of the continuation function.
1362
-
1363
- No extra arguments are allowed for coro.end calls in unwind sections
1354
+ Only none token is allowed for coro.end calls in unwind sections
1364
1355
1365
1356
Semantics:
1366
1357
""""""""""
@@ -1393,7 +1384,7 @@ For landingpad based exception model, it is expected that frontend uses the
1393
1384
.. code-block :: llvm
1394
1385
1395
1386
ehcleanup:
1396
- %InResumePart = call i1 (ptr, i1, ...) @llvm.coro.end(ptr null, i1 true)
1387
+ %InResumePart = call i1 @llvm.coro.end(ptr null, i1 true, token none )
1397
1388
br i1 %InResumePart, label %eh.resume, label %cleanup.cont
1398
1389
1399
1390
cleanup.cont:
@@ -1418,7 +1409,7 @@ referring to an enclosing cleanuppad as follows:
1418
1409
1419
1410
ehcleanup:
1420
1411
%tok = cleanuppad within none []
1421
- %unused = call i1 (ptr, i1, ...) @llvm.coro.end(ptr null, i1 true) [ "funclet"(token %tok) ]
1412
+ %unused = call i1 @llvm.coro.end(ptr null, i1 true, token none ) [ "funclet"(token %tok) ]
1422
1413
cleanupret from %tok unwind label %RestOfTheCleanup
1423
1414
1424
1415
The `CoroSplit ` pass, if the funclet bundle is present, will insert
@@ -1443,6 +1434,53 @@ The following table summarizes the handling of `coro.end`_ intrinsic.
1443
1434
| | Landingpad | mark coroutine as done | mark coroutine done |
1444
1435
+------------+-------------+------------------------+---------------------------------+
1445
1436
1437
+ .. _coro.end.results :
1438
+
1439
+ 'llvm.coro.end.results' Intrinsic
1440
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1441
+ ::
1442
+
1443
+ declare token @llvm.coro.end.results(...)
1444
+
1445
+ Overview:
1446
+ """""""""
1447
+
1448
+ The '``llvm.coro.end.results ``' intrinsic captures values to be returned from
1449
+ unique-suspend returned-continuation coroutines.
1450
+
1451
+ Arguments:
1452
+ """"""""""
1453
+
1454
+ The number of arguments must match the return type of the continuation function:
1455
+
1456
+ - if the return type of the continuation function is ``void `` there must be no
1457
+ arguments
1458
+
1459
+ - if the return type of the continuation function is a ``struct ``, the arguments
1460
+ will be of element types of that ``struct `` in order;
1461
+
1462
+ - otherwise, it is just the return value of the continuation function.
1463
+
1464
+ .. code-block :: llvm
1465
+
1466
+ define {ptr, ptr} @g(ptr %buffer, ptr %ptr, i8 %val) presplitcoroutine {
1467
+ entry:
1468
+ %id = call token @llvm.coro.id.retcon.once(i32 8, i32 8, ptr %buffer,
1469
+ ptr @prototype,
1470
+ ptr @allocate, ptr @deallocate)
1471
+ %hdl = call ptr @llvm.coro.begin(token %id, ptr null)
1472
+
1473
+ ...
1474
+
1475
+ cleanup:
1476
+ %tok = call token (...) @llvm.coro.end.results(i8 %val)
1477
+ call i1 @llvm.coro.end(ptr %hdl, i1 0, token %tok)
1478
+ unreachable
1479
+
1480
+ ...
1481
+
1482
+ declare i8 @prototype(ptr, i1 zeroext)
1483
+
1446
1484
1447
1485
'llvm.coro.end.async' Intrinsic
1448
1486
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments