]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++, coroutines: Separate the analysis, ramp and outlined function synthesis.
authorIain Sandoe <iain@sandoe.co.uk>
Wed, 14 Aug 2024 16:18:32 +0000 (17:18 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Sat, 24 Aug 2024 18:40:08 +0000 (19:40 +0100)
commit6303cd7e41546e95c436bd274cc972674230fe1c
tree043492d4c4477e35c414b4eb8a89843b776e1623
parentd5da5f00d91a8344fdb366c317366bd8e93ad1b8
c++, coroutines: Separate the analysis, ramp and outlined function synthesis.

This change is preparation for fixes to the ramp and codegen to follow.

The primary motivation is that we have thee activities; analysis, ramp
synthesis and outlined coroutine body synthesis.  These are currently
carried out in sequence in the 'morph_fn_to_coro' code, which means that
we are nesting the synthesis of the outlined coroutine body inside the
finish_function call for the original function (which becomes the ramp).

The revised code splits the three interests so that the analysis can be
used independently by the ramp and body synthesis.  This avoids some issues
seen with global state that start/finish function use and allows us to
use more of the high-level APIs in fixing bugs.

The resultant implementation is more self-contained, and has less impact
on finish_function.

gcc/cp/ChangeLog:

* coroutines.cc (struct suspend_point_info, struct param_info,
struct local_var_info, struct susp_frame_data,
struct local_vars_frame_data): Move to coroutines.h.
(build_actor_fn): Use start/finish function APIs.
(build_destroy_fn): Likewise.
(coro_build_actor_or_destroy_function): No longer mark the
actor / destroyer as DECL_COROUTINE_P.
(coro_rewrite_function_body): Use class members.
(cp_coroutine_transform::wrap_original_function_body): Likewise.
(build_ramp_function): Replace by...
(cp_coroutine_transform::complete_ramp_function): ...this.
(cp_coroutine_transform::cp_coroutine_transform): New.
(cp_coroutine_transform::~cp_coroutine_transform): New
(morph_fn_to_coro): Replace by...
(cp_coroutine_transform::apply_transforms): ...this.
(cp_coroutine_transform::finish_transforms): New.
* cp-tree.h (morph_fn_to_coro): Remove.
* decl.cc (emit_coro_helper): Remove.
(finish_function): Revise handling of coroutine transforms.
* coroutines.h: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Arsen Arsenović <arsen@aarsen.me>
gcc/cp/coroutines.cc
gcc/cp/coroutines.h [new file with mode: 0644]
gcc/cp/cp-tree.h
gcc/cp/decl.cc