This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] empty_stmt_nodes, deleted statements, iterators, andgsi_step_bb
On Fri, 2002-11-29 at 10:31, Diego Novillo wrote:
> On Thu, 28 Nov 2002, Andrew Macleod wrote:
>
> > The easiest thing to do to solve that problem would be to make the
> > iterator have 2 words, the stmt pointer and the basic block it belongs
> > to. This would simplify many things I think, but it does have the
> > drawback of passing a couple of words around as an iterator instead of
> > just one. I doubt thats a huge deal, especially since a lot of routines
> > which operate on interators are inlined. Perhaps there is a better
> > option.
> >
> I think we may not need to have the two words. When we replace a
> statement with empty_stmt_node, we do not really affect the
> chaining structure. So, if you are removing a statement in a
> COMPOUND_EXPR, you only replace its 0th operand.
>
Oh ho!
Actually, yes, we may not need the extra word. The bug that was showing
up is a bug in the cfg builder make_blocks():
for (i = gsi_start (first_p); !gsi_after_end (i); gsi_step (&i))
{
tree stmt;
enum tree_code code;
tree *container = gsi_container (i);
stmt = gsi_stmt (i);
STRIP_WFL (stmt);
STRIP_NOPS (stmt);
/* Ignore non-executable statements. */
if (stmt == empty_stmt_node)
continue;
What happens here is that when a COMPOUND_EXPR has an empty_stmt_node as
the stmt, we never get around to setting the basic block for the
containing COMPOUND_EXPR.
Further more, if you do try, we'll crap out in set_bb_for_stmt (t, bb)
because we go down the stmt chain for the compound_expr setting the
basic block. The following patch makes my testcase work OK.
Anything obviously wrong with doing this?
I'm trying a bootstrap now.
Andrew
* tree-cfg.c (make_blocks): Set BB for containers of empty_stmt_nodes.
(set_bb_for_stmt): Don't go into empty_stmt_nodes if the container
has one.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.32
diff -c -p -r1.1.4.32 tree-cfg.c
*** tree-cfg.c 12 Nov 2002 22:01:16 -0000 1.1.4.32
--- tree-cfg.c 29 Nov 2002 17:19:44 -0000
*************** make_blocks (first_p, parent_block)
*** 202,208 ****
/* Ignore non-executable statements. */
if (stmt == empty_stmt_node)
! continue;
code = TREE_CODE (stmt);
--- 202,212 ----
/* Ignore non-executable statements. */
if (stmt == empty_stmt_node)
! {
! if (bb && *container != empty_stmt_node)
! set_bb_for_stmt (*container, bb);
! continue;
! }
code = TREE_CODE (stmt);
*************** set_bb_for_stmt (t, bb)
*** 1845,1849 ****
else
t = NULL;
}
! while (t);
}
--- 1849,1853 ----
else
t = NULL;
}
! while (t && t != empty_stmt_node);
}