From: Andrew Burgess <aburgess@redhat.com>
To: "Maciej W. Rozycki" <macro@embecosm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/6] Avoid redundant operations in `fortran_array_walker'
Date: Wed, 15 Dec 2021 13:19:00 +0000 [thread overview]
Message-ID: <20211215131900.GJ175541@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.20.2112092225040.10183@tpp.orcam.me.uk>
* Maciej W. Rozycki <macro@embecosm.com> [2021-12-11 11:47:14 +0000]:
> Move inner dimension's element type determination outside the respective
> loops in `fortran_array_walker'. The operation is exactly the same with
> each iteration, so there is no point in redoing it for each element and
> while a smart compiler might be able to move it outside the loop it is
> regardless a bad coding style. No functional change.
LGTM.
Thanks,
Andrew
> ---
> gdb/f-array-walker.h | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> gdb-fortran-array-walker-walk-type.diff
> Index: src/gdb/f-array-walker.h
> ===================================================================
> --- src.orig/gdb/f-array-walker.h
> +++ src/gdb/f-array-walker.h
> @@ -208,6 +208,8 @@ class fortran_array_walker
>
> if (nss != m_ndimensions)
> {
> + struct type *subarray_type = TYPE_TARGET_TYPE (check_typedef (type));
> +
> /* For dimensions other than the inner most, walk each element and
> recurse while peeling off one more dimension of the array. */
> for (LONGEST i = lowerbound;
> @@ -218,13 +220,13 @@ class fortran_array_walker
> LONGEST new_offset = offset + calc.index_offset (i);
>
> /* Now print the lower dimension. */
> - struct type *subarray_type
> - = TYPE_TARGET_TYPE (check_typedef (type));
> walk_1 (nss + 1, subarray_type, new_offset, (i == upperbound));
> }
> }
> else
> {
> + struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (type));
> +
> /* For the inner most dimension of the array, process each element
> within this dimension. */
> for (LONGEST i = lowerbound;
> @@ -233,7 +235,6 @@ class fortran_array_walker
> {
> LONGEST elt_off = offset + calc.index_offset (i);
>
> - struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (type));
> if (is_dynamic_type (elt_type))
> {
> CORE_ADDR e_address = m_address + elt_off;
>
next prev parent reply other threads:[~2021-12-15 13:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-11 11:46 [PATCH 0/6] Make Fortran support respect more `set print' settings Maciej W. Rozycki
2021-12-11 11:47 ` [PATCH 1/6] Initialize `m_ndimensions' in the member initializer list Maciej W. Rozycki
2021-12-15 13:18 ` Andrew Burgess
2021-12-17 15:03 ` Maciej W. Rozycki
2021-12-11 11:47 ` [PATCH 2/6] Avoid redundant operations in `fortran_array_walker' Maciej W. Rozycki
2021-12-15 13:19 ` Andrew Burgess [this message]
2021-12-17 15:04 ` Maciej W. Rozycki
2021-12-11 11:47 ` [PATCH 3/6] Respect `set print repeats' with Fortran arrays Maciej W. Rozycki
2021-12-15 15:18 ` Andrew Burgess
2022-01-08 16:25 ` Maciej W. Rozycki
2021-12-11 11:47 ` [PATCH 4/6] Add `set print repeats' tests for C/C++ arrays Maciej W. Rozycki
2021-12-15 15:33 ` Andrew Burgess
2022-01-08 16:26 ` Maciej W. Rozycki
2021-12-11 11:47 ` [PATCH 5/6] Respect `set print array-indexes' with Fortran arrays Maciej W. Rozycki
2021-12-15 16:49 ` Andrew Burgess
2022-01-08 16:27 ` Maciej W. Rozycki
2021-12-11 11:48 ` [PATCH 6/6] Add `set print array-indexes' tests for C/C++ arrays Maciej W. Rozycki
2021-12-15 16:51 ` Andrew Burgess
2022-01-08 16:27 ` Maciej W. Rozycki
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=20211215131900.GJ175541@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=macro@embecosm.com \
/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).