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 4E3043857C5B for ; Tue, 12 Jul 2022 14:08:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E3043857C5B 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 3444 invoked from network); 12 Jul 2022 14:08:31 -0000 X-APM-Out-ID: 16576349110344 X-APM-Authkey: 257869/1(257869/1) 4 Received: from unknown (HELO ?192.168.1.95?) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 12 Jul 2022 14:08:31 -0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: [PATCH] c++: coroutines - Overlap variables in frame [PR105989] From: Iain Sandoe In-Reply-To: Date: Tue, 12 Jul 2022 15:08:31 +0100 Cc: GCC Patches Content-Transfer-Encoding: quoted-printable Message-Id: <236E416B-F744-42C1-806C-4701DB1BAB55@sandoe.co.uk> References: To: =?utf-8?Q?Michal_Jankovi=C4=8D?= X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tue, 12 Jul 2022 14:08:34 -0000 Hi Michal, > On 12 Jul 2022, at 14:35, Michal Jankovi=C4=8D via Gcc-patches = wrote: >=20 > Currently, coroutine frames store all variables of a coroutine = separately, > even if their lifetime does not overlap (they are in distinct scopes). = This > patch implements overlapping distinct variable scopes in the coroutine = frame, > by storing the frame fields in nested unions of structs. This lowers = the size > of the frame for larger coroutines significantly, and makes them more = usable > on systems with limited memory. not a review (I will try to take a look at the weekend). but =E2=80=A6 this is one of the two main optimisations on my TODO - so = cool for doing it. (the other related optimisation is to eliminate frame entries for scopes = without any suspend points - which has the potential to save even more space for code with = sparse use of co_xxxx) Iain > Bootstrapped and regression tested on x86_64-pc-linux-gnu; new test = fails > before the patch and succeeds after with no regressions. >=20 > PR c++/105989 >=20 > gcc/cp/ChangeLog: >=20 > * coroutines.cc (struct local_var_info): Add field_access_path. > (build_local_var_frame_access_expr): New. > (transform_local_var_uses): Use = build_local_var_frame_access_expr. > (coro_make_frame_entry_id): New. > (coro_make_frame_entry): Delegate to coro_make_frame_entry_id. > (struct local_vars_frame_data): Add orig, field_access_path. > (register_local_var_uses): Generate new frame layout. Create = access > paths to vars. > (morph_fn_to_coro): Set new fields in local_vars_frame_data.=20 >=20 > gcc/testsuite/ChangeLog: >=20 > * g++.dg/coroutines/pr105989.C: New test. >=20 >