c++-coroutines - Simplify the conditional for freeing the coro frame.

The existing scheme avoided messing with scopes, which had merit at the
time, but now we have a mechanism to use most of the machinery to build
if statements - so do that.

2019-06-08  Iain Sandoe  <iain@sandoe.co.uk>

	* coroutines.cc (build_actor_fn): Simplify the conditional call to
	free the coroutine frame.

From-SVN: r272080
This commit is contained in:
Iain Sandoe
2019-06-08 13:26:35 +00:00
committed by Iain Sandoe
parent 7bd6259fd7
commit 28bc74bbad
2 changed files with 15 additions and 9 deletions

View File

@@ -1,3 +1,8 @@
2019-06-08 Iain Sandoe <iain@sandoe.co.uk>
* coroutines.cc (build_actor_fn): Simplify the conditional call to
free the coroutine frame.
2019-06-08 Iain Sandoe <iain@sandoe.co.uk>
* coroutines.cc (co_return_expander): Look inside cleanup point

View File

@@ -1451,19 +1451,20 @@ build_actor_fn (location_t loc, tree coro_frame_type, tree actor,
tf_warning_or_error);
tree fnf2_x = build_class_member_access_expr (actor_frame, fnf_m, NULL_TREE,
false, tf_warning_or_error);
tree need_free_if = begin_if_stmt ();
fnf2_x = build1 (CONVERT_EXPR, integer_type_node, fnf2_x);
tree cmp = build2 (NE_EXPR, integer_type_node, fnf2_x, integer_zero_node);
finish_if_stmt_cond (cmp, need_free_if);
tree free_coro_fr
= build_call_expr_loc (loc,
builtin_decl_explicit (BUILT_IN_FREE), 1, actor_fp);
free_coro_fr = coro_build_cvt_void_expr_stmt (free_coro_fr, loc);
tree free_list = NULL;
append_to_statement_list (free_coro_fr, &free_list);
tree goto_ret_list = NULL;
r = build1 (GOTO_EXPR, void_type_node, ret_label);
append_to_statement_list (r, &goto_ret_list);
r = build3 (COND_EXPR, void_type_node, fnf2_x, free_list, goto_ret_list);
r = coro_build_expr_stmt (r, loc);
add_stmt (free_coro_fr);
finish_then_clause (need_free_if);
tree scope = IF_SCOPE (need_free_if);
IF_SCOPE (need_free_if) = NULL;
r = do_poplevel (scope);
add_stmt (r);
/* This is the eventual (or suspend) return point. */