This is the mail archive of the
mailing list for the GCC project.
Re: valid_gimple_expression_p claims validity of invalid gimple
On 7/14/07, Eric Botcazou <firstname.lastname@example.org> wrote:
> First is_gimple_min_invariant in try_to_simplify where it chooses
> DECL_INITIAL should be valid_gimple_expression_p instead.
That's a known problem, see tree-ssa-ccp.c:
I had forgotten about this because i hadn't done IPA in a while. At
some point, we should just create special initializer functions and
gimplify these into them.
/* The regular is_gimple_min_invariant does a shallow test of the object.
It assumes that full gimplification has happened, or will happen on the
object. For a value coming from DECL_INITIAL, this is not true, so we
have to be more strict ourselves. */
ccp_decl_initial_min_invariant (tree t)
if (!is_gimple_min_invariant (t))
if (TREE_CODE (t) == ADDR_EXPR)
/* Inline and unroll is_gimple_addressable. */
t = TREE_OPERAND (t, 0);
if (is_gimple_id (t))
if (!handled_component_p (t))
get_symbol_constant_value (tree sym)
if (TREE_STATIC (sym)
&& TREE_READONLY (sym)
&& !MTAG_P (sym))
tree val = DECL_INITIAL (sym);
&& ccp_decl_initial_min_invariant (val))
You could turn ccp_decl_initial_min_invariant into a global predicate and
invoke it from tree-ssa-sccvn.c on the DECL_INITIAL.
> However, even if i fix this, the testcase still fails because
> valid_gimple_expression says something that is clearly invalid is
> (gdb) p valid_gimple_expression_p ($2)
> $3 = 1 '\001'
> (gdb) p debug_generic_stmt ($2)
> &((struct RegisterLayout *) (char *) &SimulatedRegisters)->intmask;
> This is not valid gimple by a longshot :)
Almost. :-) The function was extracted unchanged from set_rhs but it looks
like it needs to be beefed up a bit if it is to become of general use.
> If you fix this part, i'll happily fix the bug report with the first part.
The problem is again the ADDR_EXPR case, because it drags lvalues into the
game. This would be something like:
I'll try this and submit it as part of my patch if it works.
Thanks a ton!