[cfe-dev] why a switch statement for coroutine?
Jim Hurd via cfe-dev
cfe-dev at lists.llvm.org
Fri Dec 15 08:35:43 PST 2017
The code generation for coroutine resume is pretty much the same as a
switch statement; for a few suspend points it generates if(state==x) goto
label else..., and for many suspend points it uses a jump table.
https://godbolt.org/g/U3d1sz
I would have guessed that it would save the resume state as a call address
directly, rather than save the state as an index into a jump table. What
advantage does the switch approach have? Why not just save a new resume
address in the frame prefix after each resume?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171215/48a34ab3/attachment.html>
More information about the cfe-dev
mailing list