According to http://gcc.gnu.org/ml/gcc-patches/2009-11/msg00999.html on Nov 19, 2009, Richard Guenther <richard.guent...@gmail.com> wrote:
> On Thu, Nov 19, 2009 at 4:05 AM, Alexandre Oliva <aol...@redhat.com> wrote: >> On Nov 17, 2009, Richard Guenther <richard.guent...@gmail.com> wrote: >> >>>>> This looks odd. SSA DEF operand iteration should walk the PHI defs >>>>> as well, so the change should not be necessary. >> >>>> I thought so, too, but by the time we get there, the operands of the PHI >>>> stmt have already been disconnected. >> >>> It shouldn't be. Please try to figure out why instead. >> >> Gotta use a different FOR_EACH macro to handle PHI nodes. >> >> s/FOR_EACH_SSA_DEF_OPERAND/FOR_EACH_PHI_OR_STMT_DEF/ fixed it. >> >> In order to make sure no other such mistakes had been made in GCC, I >> added an assertion check in the iterator initializer and adjusted the >> uses of GIMPLE_PHI nodes that triggered the assertion, but that would >> have done nothing whatsoever in its absence. I haven't looked into >> whether doing nothing is correct. >> >> Should I check this in? > I think we should rather let num_ssa_operands and delink_stmt_imm_use > ICE on PHIs, but I'd rather do this in stage1 - can you queue this > patch until then? You meant 4.6 stage1, but I missed it. How's it for 4.7 stage1? Regstrapped on x86_64-linux-gnu and i686-linux-gnu.
for gcc/ChangeLog from Alexandre Oliva <aol...@redhat.com> * tree-flow-inline.h (op_iter_init): Reject GIMPLE_PHI stmts. (num_ssa_operands): Skip GIMPLE_PHI. (delink_stmt_imm_use): Likewise. Index: gcc/tree-flow-inline.h =================================================================== --- gcc/tree-flow-inline.h.orig 2010-06-10 07:20:02.000000000 -0300 +++ gcc/tree-flow-inline.h 2010-06-10 15:17:51.000000000 -0300 @@ -716,9 +716,11 @@ clear_and_done_ssa_iter (ssa_op_iter *pt static inline void op_iter_init (ssa_op_iter *ptr, gimple stmt, int flags) { - /* We do not support iterating over virtual defs or uses without + /* PHI nodes require a different iterator initialization path. We + do not support iterating over virtual defs or uses without iterating over defs or uses at the same time. */ - gcc_checking_assert ((!(flags & SSA_OP_VDEF) || (flags & SSA_OP_DEF)) + gcc_checking_assert (gimple_code (stmt) != GIMPLE_PHI + && (!(flags & SSA_OP_VDEF) || (flags & SSA_OP_DEF)) && (!(flags & SSA_OP_VUSE) || (flags & SSA_OP_USE))); ptr->defs = (flags & (SSA_OP_DEF|SSA_OP_VDEF)) ? gimple_def_ops (stmt) : NULL; if (!(flags & SSA_OP_VDEF) @@ -847,8 +849,9 @@ num_ssa_operands (gimple stmt, int flags tree t; int num = 0; - FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags) - num++; + if (gimple_code (stmt) != GIMPLE_PHI) + FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags) + num++; return num; } @@ -860,7 +863,8 @@ delink_stmt_imm_use (gimple stmt) ssa_op_iter iter; use_operand_p use_p; - if (ssa_operands_active ()) + if (ssa_operands_active () + && gimple_code (stmt) != GIMPLE_PHI) FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES) delink_imm_use (use_p); }
-- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist Red Hat Brazil Compiler Engineer