Serious problems with tree-ssa operand handling
Diego Novillo
dnovillo@redhat.com
Tue Sep 7 14:12:00 GMT 2004
On Tue, 2004-09-07 at 07:47, Richard Kenner wrote:
> As I said originally, this puts a pointer into the stack of that function
> into the operands of the statement. That causes an access of junk when
> the operands are referenced.
>
No, it does not. VAR is not a GIMPLE register, follow what happens to
non-GIMPLE registers in add_stmt_operand:
1424 add_stmt_operand (tree *var_p, tree stmt, int flags)
1425 {
[ ... ]
1430
1431 var = *var_p;
1432 STRIP_NOPS (var);
[ ... ]
1445 is_real_op = is_gimple_reg (var);
1446 if (!is_real_op && !DECL_P (var))
1447 var = get_virtual_var (var);
[ ... ]
1463
1464 if (is_real_op)
1465 {
1466 /* The variable is a GIMPLE register. Add it to real operands. */
1467 if (flags & opf_is_def)
1468 append_def (var_p);
1469 else
1470 append_use (var_p);
1471 }
1472 else
1473 {
[ ... ]
1497 append_v_may_def (var);
[ ... ]
1509 append_v_must_def (var);
1510 }
[ ...]
1515 append_v_may_def (var);
[ ... ]
1520 append_vuse (var);
[ ... ]
1543 append_v_may_def (var);
1544
[ ... ]
1546 append_v_may_def (VARRAY_TREE (aliases, i));
[ ... ]
1556 append_vuse (var);
1557
[ ... ]
1559 append_vuse (VARRAY_TREE (aliases, i));
[ ... ]
1565 }
I have elided most of the logic. But you see that we only ever use
VAR_P if we are given a real operand (i.e., a symbol that
is_gimple_reg). The only reason we take the address of the variable is
because for GIMPLE regs we want to store a pointer into the operand so
that we can simplify operand replacement.
We could probably split add_stmt_operand in two so that we have a
version for GIMPLE regs and a version for others. The downside is that
some of the preparatory logic in add_stmt_operands may have to move to
the callers.
> But I shouldn't have to put in that kludge and disable both checks.
>
No. Both kludges are papering over the real problem and are wrong. I
would need a test case. Do you have a variable that is a GIMPLE reg and
at the same time belongs to an alias set or its address is taken?
Diego.
More information about the Gcc
mailing list