Skip to content

coroutine allocation optimization #64193

@kelbon

Description

@kelbon

I was writing recursive generator and wanted to make a static 'empty generator'.
Because i cannot create promise by myself i create a lambda and static 'generator' which is always empty.

Unfortunately clang is not able to optimize generator allocation in such a trivial case, while 'static' means that compiler must be 100% sure its memory never dies

Example with task(co_await adds 'new' call, because compiler thinks memory for frame required):
https://godbolt.org/z/G9Mqa4zbj

So i propose to not allocate frame (through new) for static coroutines

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions