From: Richard Biener Date: Tue, 14 Feb 2017 07:58:12 +0000 (+0000) Subject: re PR tree-optimization/79432 (ICE: verify_ssa failed) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=977472e8c683d25d5a7480c1316c9148bfe4932d;p=gcc.git re PR tree-optimization/79432 (ICE: verify_ssa failed) 2017-02-14 Richard Biener PR middle-end/79432 * tree-into-ssa.c (insert_phi_nodes): When the function can have abnormal edges rewrite SSA names with broken use-def dominance out of SSA and register them for PHI insertion. * gcc.dg/torture/pr79432.c: New testcase. From-SVN: r245417 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2561d535a2a..03c28084add 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-02-14 Richard Biener + + PR middle-end/79432 + * tree-into-ssa.c (insert_phi_nodes): When the function can + have abnormal edges rewrite SSA names with broken use-def + dominance out of SSA and register them for PHI insertion. + 2017-02-13 Martin Sebor PR middle-end/79496 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a3f66e70ff5..7881615f6b1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-02-14 Richard Biener + + PR middle-end/79432 + * gcc.dg/torture/pr79432.c: New testcase. + 2017-02-13 Martin Sebor PR middle-end/79496 diff --git a/gcc/testsuite/gcc.dg/torture/pr79432.c b/gcc/testsuite/gcc.dg/torture/pr79432.c new file mode 100644 index 00000000000..47fef0d48c3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr79432.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int fn1 (void); +int __attribute__((returns_twice)) vfork (void); + +void fn2 () +{ + int a; + a = fn1() + 2 + (vfork() + 1 + vfork()); +} +void fn3 () +{ + int a; + a = fn1() + 1 + vfork(); +} +void fn4 () +{ + int a; + a = fn1() + vfork(); +} diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 22261c15dc2..eebb8047442 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -1066,6 +1066,59 @@ insert_phi_nodes (bitmap_head *dfs) timevar_push (TV_TREE_INSERT_PHI_NODES); + /* When the gimplifier introduces SSA names it cannot easily avoid + situations where abnormal edges added by CFG construction break + the use-def dominance requirement. For this case rewrite SSA + names with broken use-def dominance out-of-SSA and register them + for PHI insertion. We only need to do this if abnormal edges + can appear in the function. */ + tree name; + if (cfun->calls_setjmp + || cfun->has_nonlocal_label) + FOR_EACH_SSA_NAME (i, name, cfun) + { + gimple *def_stmt = SSA_NAME_DEF_STMT (name); + if (SSA_NAME_IS_DEFAULT_DEF (name)) + continue; + + basic_block def_bb = gimple_bb (def_stmt); + imm_use_iterator it; + gimple *use_stmt; + bool need_phis = false; + FOR_EACH_IMM_USE_STMT (use_stmt, it, name) + { + basic_block use_bb = gimple_bb (use_stmt); + if (use_bb != def_bb + && ! dominated_by_p (CDI_DOMINATORS, use_bb, def_bb)) + need_phis = true; + } + if (need_phis) + { + tree var = create_tmp_reg (TREE_TYPE (name)); + use_operand_p use_p; + FOR_EACH_IMM_USE_STMT (use_stmt, it, name) + { + basic_block use_bb = gimple_bb (use_stmt); + FOR_EACH_IMM_USE_ON_STMT (use_p, it) + SET_USE (use_p, var); + update_stmt (use_stmt); + set_livein_block (var, use_bb); + set_rewrite_uses (use_stmt, true); + bitmap_set_bit (interesting_blocks, use_bb->index); + } + def_operand_p def_p; + ssa_op_iter dit; + FOR_EACH_SSA_DEF_OPERAND (def_p, def_stmt, dit, SSA_OP_DEF) + if (DEF_FROM_PTR (def_p) == name) + SET_DEF (def_p, var); + update_stmt (def_stmt); + set_def_block (var, def_bb, false); + set_register_defs (def_stmt, true); + bitmap_set_bit (interesting_blocks, def_bb->index); + release_ssa_name (name); + } + } + auto_vec vars (var_infos->elements ()); FOR_EACH_HASH_TABLE_ELEMENT (*var_infos, info, var_info_p, hi) if (info->info.need_phi_state != NEED_PHI_STATE_NO)