From patchwork Fri Jul 9 18:16:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1503311 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GM1ZD3Wtkz9sS8 for ; Sat, 10 Jul 2021 04:16:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A4E853861036 for ; Fri, 9 Jul 2021 18:16:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id 917B9385803F for ; Fri, 9 Jul 2021 18:16:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 917B9385803F 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 70277 invoked from network); 9 Jul 2021 18:16:03 -0000 X-APM-Out-ID: 16258545637027 X-APM-Authkey: 257869/1(257869/1) 11 Received: from unknown (HELO ?192.168.1.214?) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 9 Jul 2021 18:16:03 -0000 From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: [pushed] coroutines: Factor code. Match original source location in helpers [NFC]. Message-Id: <1BA2EBB6-EA21-43F1-953D-1DB51FAA895D@sandoe.co.uk> Date: Fri, 9 Jul 2021 19:16:02 +0100 To: GCC Patches X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-16.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This is primarily a source code refactoring, the only change is to ensure that the outlined functions are marked to begin at the same line as the original. Otherwise, they get the default (which seems to be input_location, which corresponds to the closing brace at the point that this is done). Having the source location point to that confuses some debuggers. This is a contributory fix to: PR c++/99215 - coroutines: debugging with gdb tested on x86_64-darwin, linux, pushed to master as trivial/obvious, thanks Iain Signed-off-by: Iain Sandoe gcc/cp/ChangeLog: * coroutines.cc (build_actor_fn): Move common code to act_des_fn. (build_destroy_fn): Likewise. (act_des_fn): Build the void return here. Ensure that the source location matches the original function. --- gcc/cp/coroutines.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index f5ae2d6d101..54ffdc8d062 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -2155,13 +2155,6 @@ build_actor_fn (location_t loc, tree coro_frame_type, tree actor, tree fnbody, /* One param, the coro frame pointer. */ tree actor_fp = DECL_ARGUMENTS (actor); - /* A void return. */ - tree resdecl = build_decl (loc, RESULT_DECL, 0, void_type_node); - DECL_ARTIFICIAL (resdecl) = 1; - DECL_IGNORED_P (resdecl) = 1; - DECL_RESULT (actor) = resdecl; - DECL_COROUTINE_P (actor) = 1; - /* We have a definition here. */ TREE_STATIC (actor) = 1; @@ -2532,15 +2525,8 @@ build_destroy_fn (location_t loc, tree coro_frame_type, tree destroy, /* One param, the coro frame pointer. */ tree destr_fp = DECL_ARGUMENTS (destroy); - /* A void return. */ - tree resdecl = build_decl (loc, RESULT_DECL, 0, void_type_node); - DECL_ARTIFICIAL (resdecl) = 1; - DECL_IGNORED_P (resdecl) = 1; - DECL_RESULT (destroy) = resdecl; - /* We have a definition here. */ TREE_STATIC (destroy) = 1; - DECL_COROUTINE_P (destroy) = 1; tree destr_outer = push_stmt_list (); current_stmt_tree ()->stmts_are_full_exprs_p = 1; @@ -4000,15 +3986,19 @@ static tree act_des_fn (tree orig, tree fn_type, tree coro_frame_ptr, const char* name) { tree fn_name = get_fn_local_identifier (orig, name); + location_t loc = DECL_SOURCE_LOCATION (orig); tree fn = build_lang_decl (FUNCTION_DECL, fn_name, fn_type); DECL_CONTEXT (fn) = DECL_CONTEXT (orig); + DECL_SOURCE_LOCATION (fn) = loc; DECL_ARTIFICIAL (fn) = true; DECL_INITIAL (fn) = error_mark_node; + tree id = get_identifier ("frame_ptr"); tree fp = build_lang_decl (PARM_DECL, id, coro_frame_ptr); DECL_CONTEXT (fp) = fn; DECL_ARG_TYPE (fp) = type_passed_as (coro_frame_ptr); DECL_ARGUMENTS (fn) = fp; + /* Copy selected attributes from the original function. */ TREE_USED (fn) = TREE_USED (orig); if (DECL_SECTION_NAME (orig)) @@ -4020,6 +4010,17 @@ act_des_fn (tree orig, tree fn_type, tree coro_frame_ptr, const char* name) DECL_USER_ALIGN (fn) = DECL_USER_ALIGN (orig); /* Apply attributes from the original fn. */ DECL_ATTRIBUTES (fn) = copy_list (DECL_ATTRIBUTES (orig)); + + /* A void return. */ + tree resdecl = build_decl (loc, RESULT_DECL, 0, void_type_node); + DECL_CONTEXT (resdecl) = fn; + DECL_ARTIFICIAL (resdecl) = 1; + DECL_IGNORED_P (resdecl) = 1; + DECL_RESULT (fn) = resdecl; + + /* This is a coroutine component. */ + DECL_COROUTINE_P (fn) = 1; + return fn; }