[tuples] change walk_gimple_stmt interface
Aldy Hernandez
aldyh@redhat.com
Tue Mar 4 17:18:00 GMT 2008
On Tue, Mar 04, 2008 at 07:38:46AM -0500, Diego Novillo wrote:
> On 3/4/08 6:14 AM, Aldy Hernandez wrote:
>
>> p.s. Diego, I have also documented walk_gimple_op in the API document.
>
> Thanks. This reminds me that I've still not finished the revisions I had
> started a few days ago. I'll get those in this week.
>
>
>> +/* Helper function of WALK_GIMPLE_STMT. Walk every tree operand in
>> + STMT. CALLBACK_OP and WI are as in WALK_GIMPLE_STMT.
>> +
>> + If the callback returns non-NULL for any operand, the remaining
>> + operands are not scanned. */
>> +inline tree
>
> Blank line after comment.
Crap, I need to tattoo this on my wrists cause I forget every freaking
time. I can never remember whether the closing comment goes on the next
line or the line with the period, and I'm always second guessing myself:
"no wait, Diego wanted it on the current line, no the next line, no...".
> Since we are now passing GSI, we can save the client code from putting it
> in WI. On entry to walk_gimple_stmt we can copy it in WI. Not a big deal,
> though.
Good point, fixed.
>> - addr = walk_gimple_stmt (stmt, NULL, verify_expr, &wi);
>> + addr = walk_gimple_stmt (gsi, NULL, verify_expr, &wi);
>
> Shouldn't this be walk_gimple_op?
Absolutely, fixed too.
Here is the fix I'm currently testing. I will commit if there are no
regressions.
Aldy
* gimple.c (walk_gimple_seq): Do not set wi->gsi.
(walk_gimple_stmt): Set wi->gsi.
* tree-cfg.c (verify_stmt): Use walk_gimple_op instead of
walk_gimple_stmt.
(verify_stmts): Same.
Index: gimple.c
===================================================================
--- gimple.c (revision 132865)
+++ gimple.c (working copy)
@@ -1103,8 +1103,6 @@ walk_gimple_seq (gimple_seq seq, walk_st
for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi))
{
tree ret;
- if (wi)
- wi->gsi = gsi;
ret = walk_gimple_stmt (&gsi, callback_stmt, callback_op, wi);
if (ret)
return ret;
@@ -1187,7 +1185,8 @@ walk_gimple_asm (gimple stmt, walk_tree_
not scanned.
The return value is that returned by the last call to walk_tree, or
- NULL_TREE if no CALLBACK_OP is specified. */
+ NULL_TREE if no CALLBACK_OP is specified.
+*/
inline tree
walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
@@ -1393,6 +1392,9 @@ walk_gimple_stmt (gimple_stmt_iterator *
tree ret;
gimple stmt = gsi_stmt (*gsi);
+ if (wi)
+ wi->gsi = *gsi;
+
if (wi && wi->want_locations && !gimple_locus_empty_p (stmt))
input_location = gimple_locus (stmt);
Index: tree-cfg.c
===================================================================
--- tree-cfg.c (revision 132865)
+++ tree-cfg.c (working copy)
@@ -3821,7 +3821,7 @@ verify_stmt (gimple_stmt_iterator *gsi)
}
memset (&wi, 0, sizeof (wi));
- addr = walk_gimple_stmt (gsi, NULL, verify_expr, &wi);
+ addr = walk_gimple_op (gsi_stmt (*gsi), verify_expr, &wi);
if (addr)
{
debug_generic_expr (addr);
@@ -4019,7 +4019,7 @@ verify_stmts (void)
}
err |= verify_stmt (&gsi);
- addr = walk_gimple_stmt (&gsi, NULL, verify_node_sharing, &wi);
+ addr = walk_gimple_op (gsi_stmt (gsi), verify_node_sharing, &wi);
if (addr)
{
error ("incorrect sharing of tree nodes");
More information about the Gcc-patches
mailing list