[llvm-dev] llvm.coro.size - why can't we call it from outside the coroutine?

Andrew Kelley via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 7 20:08:13 PST 2018


The @llvm.coro.size intrinsic returns a value which lowers to a constant
representing the number of bytes needed for the coroutine frame of the
current function.

This would presumably be used to call malloc with the return value. I
noticed, however, that the example code does not check for the return value
of malloc being NULL. It is unclear how to return this error condition,
especially in a frontend that does not utilize exceptions.

I am attempting to add coroutines to zig, a frontend to LLVM that:

1. has no hidden memory allocations, and
2. has no exceptions, but allows programmers to handle every possible error
(including memory allocation failure).

Given these restrictions, it would be a more flexible API if we could
measure the size of a coroutine from outside its body, allocating the
memory for the coroutine frame before calling it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180207/eb11c619/attachment.html>

More information about the llvm-dev mailing list