public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* 'walk_stmt_load_store_addr_ops' for non-'gimple_assign_single_p (stmt)'
@ 2021-03-15 18:31 Thomas Schwinge
  2021-03-15 19:17 ` Richard Biener
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Schwinge @ 2021-03-15 18:31 UTC (permalink / raw)
  To: gcc

Hi!

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).

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"?


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-03-18 12:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 18:31 'walk_stmt_load_store_addr_ops' for non-'gimple_assign_single_p (stmt)' Thomas Schwinge
2021-03-15 19:17 ` Richard Biener
2021-03-16 15:02   ` Thomas Schwinge
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

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).