public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mikael Morin <mikael@gcc.gnu.org>
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	[thread overview]
Message-ID: <20230713085236.330222-1-mikael@gcc.gnu.org> (raw)

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


             reply	other threads:[~2023-07-13  8:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13  8:52 Mikael Morin [this message]
2023-07-13  8:52 ` [PATCH 01/14] fortran: Outline final procedure pointer evaluation Mikael Morin
2023-07-13  8:52 ` [PATCH 02/14] fortran: Outline element size evaluation Mikael Morin
2023-07-13  8:52 ` [PATCH 03/14] fortran: Outline data reference descriptor evaluation Mikael Morin
2023-07-13  8:52 ` [PATCH 04/14] fortran: Inline gfc_build_final_call Mikael Morin
2023-07-13  8:52 ` [PATCH 05/14] fortran: Add missing cleanup blocks Mikael Morin
2023-07-13  8:52 ` [PATCH 06/14] fortran: Reuse final procedure pointer expression Mikael Morin
2023-07-13  8:52 ` [PATCH 07/14] fortran: Push element size expression generation close to its usage Mikael Morin
2023-07-13  8:52 ` [PATCH 08/14] fortran: Push final procedure expr gen close to its one usage Mikael Morin
2023-07-13  8:52 ` [PATCH 09/14] fortran: Inline variable definition Mikael Morin
2023-07-13  8:52 ` [PATCH 10/14] fortran: Remove redundant argument in get_var_descr Mikael Morin
2023-07-13  8:52 ` [PATCH 11/14] fortran: Outline virtual table pointer evaluation Mikael Morin
2023-07-13  8:52 ` [PATCH 12/14] fortran: Factor scalar descriptor generation Mikael Morin
2023-07-13  8:52 ` [PATCH 13/14] fortran: Use pre-evaluated class container if available [PR110618] Mikael Morin
2023-07-13  8:52 ` [PATCH 14/14] fortran: Pass pre-calculated class container argument [pr110618] Mikael Morin
2023-07-14  5:55   ` Paul Richard Thomas
2023-07-14  7:43     ` Mikael Morin
2023-07-13 18:40 ` [PATCH 00/14] fortran: Use precalculated class container for deallocation [PR110618] Paul Richard Thomas
2023-07-15  6:11   ` Paul Richard Thomas
2023-07-15 10:08     ` Mikael Morin
2023-07-16 17:09       ` Mikael Morin
2023-07-17  6:12         ` Paul Richard Thomas
2023-07-17 17:43     ` Mikael Morin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230713085236.330222-1-mikael@gcc.gnu.org \
    --to=mikael@gcc.gnu.org \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).