public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: Richard Biener <richard.guenther@gmail.com>, <gcc@gcc.gnu.org>
Subject: Re: 'walk_stmt_load_store_addr_ops' for non-'gimple_assign_single_p (stmt)'
Date: Tue, 16 Mar 2021 16:02:42 +0100	[thread overview]
Message-ID: <87mtv3ywdp.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <A3EA0097-E325-484C-BB8A-42C33A4660B6@gmail.com>

Hi!

Richard, thanks for your answer.  I'll need to look into this more; two
questions already:

On 2021-03-15T20:17:17+0100, Richard Biener via Gcc <gcc@gcc.gnu.org> wrote:
> On March 15, 2021 7:31:46 PM GMT+01:00, Thomas Schwinge <thomas@codesourcery.com> wrote:
>>First time I'm using this API -- so the error certainly may be on my
>>side.  ;-)
>>
>>What I'm doing, is a 'walk_gimple_seq', and in that one's
>>'callback_stmt', call 'walk_stmt_load_store_addr_ops', to collect
>>variable load/store/address-taken instances.  This did seem quite
>>straight-forward, given the description; 'gcc/gimple-walk.c':
>>
>>/* For the statement STMT call the callbacks VISIT_LOAD, VISIT_STORE
>>and
>>      VISIT_ADDR if non-NULL on loads, store and address-taken operands
>>passing the STMT, the base of the operand, the operand itself
>>containing
>>  the base and DATA to it.  The base will be either a decl, an indirect
>>     reference (including TARGET_MEM_REF) or the argument of an address
>>       expression.
>>       Returns the results of these callbacks or'ed.  */
>>
>>    bool
>>    walk_stmt_load_store_addr_ops (gimple *stmt, void *data,
>>                               walk_stmt_load_store_addr_fn visit_load,
>>                              walk_stmt_load_store_addr_fn visit_store,
>>                               walk_stmt_load_store_addr_fn visit_addr)
>>    { [...] }
>>
>>Indeed, given (Fortran) 'zzz = 1', we produce GIMPLE:
>>
>>    gimple_assign <real_cst, zzz, 1.0e+0, NULL, NULL>
>>
>>..., and calling 'walk_stmt_load_store_addr_ops' on that, I see, as
>>expected, the 'visit_store' callback invoked, with 'rhs' and 'arg':
>>'<var_decl zzz>'.
>>
>>However, given (Fortran) 'zzz = r + r2', we produce GIMPLE:
>>
>>    gimple_assign <plus_expr, zzz, r, r2, NULL>
>>
>>..., and calling 'walk_stmt_load_store_addr_ops' on that, I see,
>>unexpectedly, no callback at all invoked: neither 'visit_load', nor
>>'visit_store' (nor 'visit_address', obviously).
>
> The variables involved are registers. You only get called on memory operands.

How would I have told that from the 'walk_stmt_load_store_addr_ops'
function description?  (How to improve that one "to reflect relatity"?)

But 'zzz' surely is the same in 'zzz = 1' vs. 'zzz = r + r2' -- for the
former I *do* see the 'visit_store' callback invoked, for the latter I
don't?

>From a quick look at 'gcc/gimple-walk.c:walk_stmt_load_store_addr_ops',
>>this seems to intentionally be implemented in this way -- but I don't
>>understand the rationale?
>>
>>
>>Instead of 'walk_gimple_seq' -> 'callback_stmt' ->
>>'walk_stmt_load_store_addr_ops', do I need to use 'walk_gimple_seq' ->
>>'callback_op' -> "something"?
>
> Yes, if you want to visit register sets and uses as a well. Note you'll also see constants that way.

I'll look into that; in particular to figure out "something" for what I
need: load/store/address-taken.


Grüße
 Thomas
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf

  reply	other threads:[~2021-03-16 15:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 18:31 Thomas Schwinge
2021-03-15 19:17 ` Richard Biener
2021-03-16 15:02   ` Thomas Schwinge [this message]
2021-03-16 15:16     ` Richard Biener
2021-03-16 15:25     ` Michael Matz
2021-03-16 23:24       ` Thomas Schwinge
2021-03-17  7:46         ` Richard Biener
2021-03-18 12:32           ` Thomas Schwinge
2021-03-17  7:42       ` Richard Biener
2021-03-17 13:27         ` Michael Matz

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=87mtv3ywdp.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=gcc@gcc.gnu.org \
    --cc=richard.guenther@gmail.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).