From patchwork Thu Jul 13 08:52:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 11974 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1685624vqm; Thu, 13 Jul 2023 01:59:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlFbhU7lGqHFnvOxzBf2YXSeVVo1yCc/huhX4KQNJS0lyF95UxpMUFIqDJoEqscSAiul+lqc X-Received: by 2002:a2e:2c19:0:b0:2b6:ad79:a4fb with SMTP id s25-20020a2e2c19000000b002b6ad79a4fbmr865118ljs.1.1689238752421; Thu, 13 Jul 2023 01:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689238752; cv=none; d=google.com; s=arc-20160816; b=rdoXBoFPE+hEEduGjkA1iHLo8CpzN5fsc74I1AboPCjWyChzmmEwFqY3bgLwo/tmWO N78/Eu6q2XqeDiaO+ZbpmMPOVWmFe70pLeAlDD8sY5a5PX5ps3T2flQu7P0RPLCnpD/5 qGSOB+NBdIBS3yye3eQ6ULCimYtT7jRF2Rp0Q5SWpzjFclOtTCjrWZe0eggbrLlaudCc JTHDKh4XP2/5V/dAZ6Q35342OTaeGxiyjDaJBu5D6Ex+BdMI+aFyj2Pos/sp9SYQLFrt qgtJfjPuGsM8yjPCWCOfOPlJmjLu9tWDXGVUM/w5AU/9EEXJ+IfHYHRgWUT7INJTq9Dn FyGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=UnMjPTHe/FGm6/x9ZE+tW1gLagataI5nm0H3fo4QuLM=; fh=EAqAZnhg4AYtcBjfPm18lEF5V0R2rkI9MSWQf+svVaI=; b=Ksx3H2oQYx6avYCoAPEFxHBzIV/GUFjZOqMGoSH0eyWek1VPEv+B0SWjryxaM9F1eU 0YttfnyGVq+PG7sBSzvESEZGAAKhJkj4hg6SkcJqz5gmi1VGZaW//GyKp1yZjbUDpfSD 6ppC7YmGI4t+3YfciCoCxqfIShBcXleddAU9otiw3i2aZgSKEYD7W1879lkEA6xbwu7e bvoKSWSbSpIsnsTdlJmEwKciUrzQRoEpbAoc2DStqeFhPSJduNnFZR9faAuBP+tUuizt 8t4fN4L1LSQOK9TkaKxdcj3NrnogqsZoQD9t7C0CCkAhfdgQbJbWW0M06aqwsx/7ljlg DI/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=J8bml0+N; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ce20-20020a170906b25400b00991e694a0a2si731644ejb.240.2023.07.13.01.59.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:59:12 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=J8bml0+N; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01D8C388206E for ; Thu, 13 Jul 2023 08:55:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01D8C388206E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689238500; bh=UnMjPTHe/FGm6/x9ZE+tW1gLagataI5nm0H3fo4QuLM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=J8bml0+NFaP20iwuoOeFtnYu/e8A+uCZv7mAYw4zVSOzjvlyjnAfGnMoBNYekyYKI uz79FVHbsd6LSrBY32ZTE8j5TPDBo978Fsgyd8kmuagzqf4a47+t2QARd5o4lV7mzR 8FdJNifAoTQvaKjg3ppDB8NDYyD9v0IPoB60N0gw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by sourceware.org (Postfix) with ESMTPS id ECA18385842D for ; Thu, 13 Jul 2023 08:52:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ECA18385842D Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Js3wqzoJKtImzJs41q0yV3; Thu, 13 Jul 2023 10:52:42 +0200 X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Thu, 13 Jul 2023 10:52:42 +0200 X-ME-IP: 86.215.161.51 To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 00/14] fortran: Use precalculated class container for deallocation [PR110618] Date: Thu, 13 Jul 2023 10:52:22 +0200 Message-Id: <20230713085236.330222-1-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, JMQ_SPF_NEUTRAL, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, 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-Patchwork-Original-From: Mikael Morin via Gcc-patches From: Mikael Morin Reply-To: Mikael Morin Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771295214109675325 X-GMAIL-MSGID: 1771295214109675325 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