From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id 6218E385840F for ; Fri, 3 Sep 2021 13:41:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6218E385840F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 19482 invoked from network); 3 Sep 2021 13:41:08 -0000 X-APM-Out-ID: 16306764671948 X-APM-Authkey: 257869/1(257869/1) 2 Received: from unknown (HELO ?192.168.1.214?) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 3 Sep 2021 13:41:08 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: [PATCH 5/8] coroutines: Define and populate accessors for debug state. From: Iain Sandoe In-Reply-To: <5a184f1f-89a3-a0bc-9bd9-ff29db0013e2@redhat.com> Date: Fri, 3 Sep 2021 14:41:07 +0100 Cc: GCC Patches Content-Transfer-Encoding: quoted-printable Message-Id: <01B6A859-9333-4421-A494-A3F0CAC30406@sandoe.co.uk> References: <4C7B8763-1292-450A-96FE-A56B66926540@sandoe.co.uk> <3E415FEA-27D9-4C04-BFEE-002F67EED9F6@sandoe.co.uk> <7B788329-6FAD-4EE0-B562-B39D559FE5EE@sandoe.co.uk> <036890C2-4D5C-4E7A-B18F-037C740C3283@sandoe.co.uk> <5a184f1f-89a3-a0bc-9bd9-ff29db0013e2@redhat.com> To: Jason Merrill X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-15.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Sep 2021 13:41:11 -0000 > On 3 Sep 2021, at 14:39, Jason Merrill wrote: >=20 > On 9/1/21 6:54 AM, Iain Sandoe wrote: >> This is an efficiency measure and repeats the pattern used for >> other identifiers used in the coroutine implementation. >> In support of debugging, the user might well need to look at some >> of the variables that the implementation manipulates in lowering >> the coroutines. The defines the identifiers for these and populates >> them on demand (avoiding repeated identifier calls). >> Contributory to debug support (PR 99215) >> Signed-off-by: Iain Sandoe >> gcc/cp/ChangeLog: >> * coroutines.cc: Add identifiers for implementation >> variables that we want to expose to debug. >> (coro_init_identifiers): Initialize implementation names. >> (coro_promise_type_found_p): Use pre-built identifiers. >> (build_actor_fn): Likewise. >> (build_destroy_fn): Likewise. >> --- >> gcc/cp/coroutines.cc | 32 ++++++++++++++++++++++++-------- >> 1 file changed, 24 insertions(+), 8 deletions(-) >> diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc >> index 081e1a46c63..3b46aac4dc5 100644 >> --- a/gcc/cp/coroutines.cc >> +++ b/gcc/cp/coroutines.cc >> @@ -215,7 +215,17 @@ static GTY(()) tree coro_await_ready_identifier; >> static GTY(()) tree coro_await_suspend_identifier; >> static GTY(()) tree coro_await_resume_identifier; >> -/* Create the identifiers used by the coroutines library = interfaces. */ >> +/* Accessors for the coroutine frame state used by the = implementation. */ >> + >> +static GTY(()) tree coro_resume_fn_field; >> +static GTY(()) tree coro_destroy_fn_field; >> +static GTY(()) tree coro_promise_field; >> +static GTY(()) tree coro_frame_needs_free_field; >> +static GTY(()) tree coro_resume_index_field; >> +static GTY(()) tree coro_self_handle_field; >=20 > Since these are identifiers, not FIELD_DECLs, calling them *_field = seems misleading. >=20 >> +/* Create the identifiers used by the coroutines library interfaces = and >> + the implementation frame state. */ >> static void >> coro_init_identifiers () >> @@ -241,6 +251,14 @@ coro_init_identifiers () >> coro_await_ready_identifier =3D get_identifier ("await_ready"); >> coro_await_suspend_identifier =3D get_identifier = ("await_suspend"); >> coro_await_resume_identifier =3D get_identifier ("await_resume"); >> + >> + /* Coroutine state frame field accessors. */ >> + coro_resume_fn_field =3D get_identifier ("_Coro_resume_fn"); >> + coro_destroy_fn_field =3D get_identifier ("_Coro_destroy_fn"); >> + coro_promise_field =3D get_identifier ("_Coro_promise"); >> + coro_frame_needs_free_field =3D get_identifier = ("_Coro_frame_needs_free"); >> + coro_resume_index_field =3D get_identifier ("_Coro_resume_index"); >> + coro_self_handle_field =3D get_identifier ("_Coro_self_handle"); >> } >> /* Trees we only need to set up once. */ >> @@ -513,12 +531,12 @@ coro_promise_type_found_p (tree fndecl, = location_t loc) >> /* Build a proxy for a handle to "self" as the param to >> await_suspend() calls. */ >> coro_info->self_h_proxy >> - =3D build_lang_decl (VAR_DECL, get_identifier = ("_Coro_self_handle"), >> + =3D build_lang_decl (VAR_DECL, coro_self_handle_field, >> coro_info->handle_type); >> /* Build a proxy for the promise so that we can perform = lookups. */ >> coro_info->promise_proxy >> - =3D build_lang_decl (VAR_DECL, get_identifier ("_Coro_promise"), >> + =3D build_lang_decl (VAR_DECL, coro_promise_field, >> coro_info->promise_type); >> /* Note where we first saw a coroutine keyword. */ >> @@ -2198,8 +2216,7 @@ build_actor_fn (location_t loc, tree = coro_frame_type, tree actor, tree fnbody, >> =3D {actor, actor_frame, coro_frame_type, loc, local_var_uses}; >> cp_walk_tree (&fnbody, transform_local_var_uses, &xform_vars_data, = NULL); >> - tree resume_idx_name =3D get_identifier ("_Coro_resume_index"); >> - tree rat_field =3D lookup_member (coro_frame_type, = resume_idx_name, 1, 0, >> + tree rat_field =3D lookup_member (coro_frame_type, = coro_resume_index_field, 1, 0, >> tf_warning_or_error); >> tree rat =3D build3 (COMPONENT_REF, short_unsigned_type_node, = actor_frame, >> rat_field, NULL_TREE); >> @@ -2462,7 +2479,7 @@ build_actor_fn (location_t loc, tree = coro_frame_type, tree actor, tree fnbody, >> /* We will need to know which resume point number should be = encoded. */ >> tree res_idx_m >> - =3D lookup_member (coro_frame_type, resume_idx_name, >> + =3D lookup_member (coro_frame_type, coro_resume_index_field, >> /*protect=3D*/1, /*want_type=3D*/0, = tf_warning_or_error); >> tree resume_pt_number >> =3D build_class_member_access_expr (actor_frame, res_idx_m, = NULL_TREE, false, >> @@ -2504,8 +2521,7 @@ build_destroy_fn (location_t loc, tree = coro_frame_type, tree destroy, >> tree destr_frame =3D build1 (INDIRECT_REF, coro_frame_type, = destr_fp); >> - tree resume_idx_name =3D get_identifier ("_Coro_resume_index"); >> - tree rat_field =3D lookup_member (coro_frame_type, = resume_idx_name, 1, 0, >> + tree rat_field =3D lookup_member (coro_frame_type, = coro_resume_index_field, 1, 0, >> tf_warning_or_error); >> tree rat =3D build3 (COMPONENT_REF, short_unsigned_type_node, = destr_frame, >> rat_field, NULL_TREE);