<div dir="ltr"><div><div><div><div><div><div><a href="http://llvm.org/docs/Coroutines.html#llvm-coro-size-intrinsic">http://llvm.org/docs/Coroutines.html#llvm-coro-size-intrinsic</a><br></div><div><br></div>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.<br><br></div>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.<br><br></div>I am attempting to add coroutines to zig, a frontend to LLVM that:<br><br></div>1. has no hidden memory allocations, and <br></div>2. has no exceptions, but allows programmers to handle every possible error (including memory allocation failure).<br></div><div><br></div><div>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.<br></div><div><br></div><div><br></div></div>