From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id B86FE3858CDB; Thu, 13 Jul 2023 18:40:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B86FE3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-53fa455cd94so644028a12.2; Thu, 13 Jul 2023 11:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689273634; x=1691865634; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=EW5ZuZWALShZ4HtqwSN7yObMEFPpFeyrUpqWAaHLrhU=; b=GtKi3ATOa19VVPFAXWn5D0mGS/5azEPHkIytCao9Vlg7OX39m8wW4AlTg4xQTeRN5e 2ntEgEpgGWf0vNpQTEMHOFSywJnqjlmsJ2LjwBDP83y856V0VEpCuf8GzrThCib/FAIi +6raWQLRRRm1/Ta9M9c22W6Jw1TJ7tnYpA6F4U75n+o0VkZGP+jmv4c8f3PKR+ikYvGl MPDPQhLIlXEscCFKLan9ta42y2A/3UI2YpQeHP74OMTXqAJBwvqHub1pebFiZBoeZuyb TqdupC21vH6OUL4ddGQcSCcE8O+CUCtff/4XCgfzKxEDYKOz00fas474KLbnJnS9QAdW w/hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689273634; x=1691865634; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EW5ZuZWALShZ4HtqwSN7yObMEFPpFeyrUpqWAaHLrhU=; b=h3dQXtN5thdQY1hmncViSa1BUHCZaCF6nN3e1ghZVEB7FscfiLGznVKaErVMyBw1NM IwsO4uF0TWeTSl+P8mghwsxvPYuR4EvU/MwuU8xKaRMOoPfM7n3lmnP49KPkF0d7wqKr 4OAct9tVc3UF24+US2igkroHV20KUidj8D1AB4n+uKW1i1cQuynwG/dL/GmHghRHBHrY N/mbRJgPwqR5++UblE0KhPFP55bKpgaYuhyUylpf5+5jT+kjdA+xLmYedB4DRM360rPs 3PEnroQZRLxiiPgMScinG3/VLUHZ/l2BgbhvwDuNvdd2T1Me1AjI2aSfb9pEDxxYw2nv fkGw== X-Gm-Message-State: ABy/qLbhnBRDAtI5WU1tDHRhojGB7iH1o2a6mdJkrFJqNAFqrBQGAN6I 7de2uXL0BCgmg09lvOkbaF6UW/vo7BIE2lKnNS35Hf8l X-Google-Smtp-Source: APBJJlF639FGOVRW5rgqP71b3Oo4SHRw8zZqKTD+x5HsByiHTNun6wWdRvM+qsFuJtNChXa30FNrV7WIYbGAL76Q9CU= X-Received: by 2002:a17:90b:3883:b0:262:f09c:e73d with SMTP id mu3-20020a17090b388300b00262f09ce73dmr1616058pjb.34.1689273634074; Thu, 13 Jul 2023 11:40:34 -0700 (PDT) MIME-Version: 1.0 References: <20230713085236.330222-1-mikael@gcc.gnu.org> In-Reply-To: <20230713085236.330222-1-mikael@gcc.gnu.org> From: Paul Richard Thomas Date: Thu, 13 Jul 2023 19:40:22 +0100 Message-ID: Subject: Re: [PATCH 00/14] fortran: Use precalculated class container for deallocation [PR110618] To: Mikael Morin Cc: fortran@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Mikael, All 14 patches apply cleanly to trunk, which is rebuilding right now and will regtest this evening. I will review the composite patch tomorrow morning and will come back to you as soon as I can. At first sight all is well; perhaps the commented out line can be dispensed with? Many thanks for this. You are to be commended on your fortitude in putting it all together. The result looks to be considerably neater and more maintainable. If I recall correctly, Tobias was the author of much of this - any comments? Regards Paul On Thu, 13 Jul 2023 at 09:53, Mikael Morin via Fortran wrote: > > Hello, > > the following patches are abot PR110618, a PR similar to PR92178 from which > it is cloned. Both are about a problem of dedendencies between arguments, > when one of them is associated to an allocatable intent(out) dummy, and thus > deallocated in the process of argument association. > > PR110618 exposes a case where the data reference finalization code > for one argument references deallocated data from another argument. > The way I propose to fix this is similar to my recent patches for > PR92178 [1,2] (and is dependent on them). Those patches try to use a data > reference pointer precalculated at the beginning of the process instead of > repeatedly evaluating an expression that becomes invalid at some point > in the generated code. > > Unfortunately, the code for finalization is not prepared for this, as it > only manipulates front-end expressions, whereas the precalculated > pointer is available as middle-end's generic tree. > > These patches refactor the finalization code to ease the introduction > of the forementioned pre-calculated class container pointer. Basically, > four expressions are calculated to build the final procedure call: > the final procedure pointer, the element size, the data reference > (array) descriptor, and (optionally) the virtual table pointer. Each of > the four is outlined stepwise to its own separate function in the > following patches. This abstracts away the generation of these > expressions and makes it easier to add one other way to generate them. > This should also make the impact of the changes more > visible, and regressions easier to spot. > > The main changes are the two last patches introducing an additional > precalculated pointer argument in relevant functions and using them if > set. Details are in the specific patches. > > Each patch has been bubble-bootstrapped and partially tested > with RUNTESTFLAGS="dg.exp=*final*". > The complete set has been fully tested on x86_64-pc-linux-gnu. > OK for master? > > [1] https://gcc.gnu.org/pipermail/fortran/2023-July/059582.html > [2] https://gcc.gnu.org/pipermail/fortran/2023-July/059583.html > > Mikael Morin (14): > fortran: Outline final procedure pointer evaluation > fortran: Outline element size evaluation > fortran: Outline data reference descriptor evaluation > fortran: Inline gfc_build_final_call > fortran: Add missing cleanup blocks > fortran: Reuse final procedure pointer expression > fortran: Push element size expression generation close to its usage > fortran: Push final procedure expr gen close to its one usage. > fortran: Inline variable definition > fortran: Remove redundant argument in get_var_descr > fortran: Outline virtual table pointer evaluation > fortran: Factor scalar descriptor generation > fortran: Use pre-evaluated class container if available [PR110618] > fortran: Pass pre-calculated class container argument [pr110618] > > gcc/fortran/trans-array.cc | 2 +- > gcc/fortran/trans-expr.cc | 7 +- > gcc/fortran/trans-stmt.cc | 3 +- > gcc/fortran/trans.cc | 314 ++++++++++++-------- > gcc/fortran/trans.h | 9 +- > gcc/testsuite/gfortran.dg/intent_out_22.f90 | 37 +++ > 6 files changed, 237 insertions(+), 135 deletions(-) > create mode 100644 gcc/testsuite/gfortran.dg/intent_out_22.f90 > > -- > 2.40.1 > -- "If you can't explain it simply, you don't understand it well enough" - Albert Einstein