From: Richard Biener Date: Thu, 8 Feb 2018 13:29:15 +0000 (+0000) Subject: re PR middle-end/84233 (ICE (segfault) in gimple_assign_rhs_code) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=24db2556253540529a7b11ed42683b2ea9bb8989;p=gcc.git re PR middle-end/84233 (ICE (segfault) in gimple_assign_rhs_code) 2018-02-08 Richard Biener PR tree-optimization/84233 * tree-ssa-phiprop.c (propagate_with_phi): Use separate changed flag instead of boguously re-using phi_inserted. * g++.dg/torture/pr84233.C: New testcase. From-SVN: r257486 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 770d408fa16..f26472ada03 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-02-08 Richard Biener + + PR tree-optimization/84233 + * tree-ssa-phiprop.c (propagate_with_phi): Use separate + changed flag instead of boguously re-using phi_inserted. + 2018-02-08 Martin Jambor * hsa-gen.c (get_symbol_for_decl): Set program allocation for diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5146f7ba612..5b83f3aff8e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-08 Richard Biener + + PR tree-optimization/84233 + * g++.dg/torture/pr84233.C: New testcase. + 2018-02-08 Richard Biener PR tree-optimization/84278 diff --git a/gcc/testsuite/g++.dg/torture/pr84233.C b/gcc/testsuite/g++.dg/torture/pr84233.C new file mode 100644 index 00000000000..d45a830bf63 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr84233.C @@ -0,0 +1,25 @@ +// { dg-do compile } +// { dg-additional-options "-w" } + +void a(const char *, int, const char *, const char *); +template void c(b); +struct d { + long e; + template union f; + template union f { + f(h *i) : j(i) {} + h *j; + long bits; + }; + static int k(volatile long &i) { return *(int *)f(&i).bits; } + typedef long g; + operator g() volatile { + int l = k(e); + c(l); + } +}; +struct : d { + } m, n; +bool o; +void p() { (o ? m : n) ? (void)0 : a("", 5, "", ""); } + diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index fad81d02ba9..03dbb390bf8 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -270,6 +270,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, use_operand_p arg_p, use; ssa_op_iter i; bool phi_inserted; + bool changed; tree type = NULL_TREE; if (!POINTER_TYPE_P (TREE_TYPE (ptr)) @@ -317,6 +318,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, /* Replace the first dereference of *ptr if there is one and if we can move the loads to the place of the ptr phi node. */ phi_inserted = false; + changed = false; FOR_EACH_IMM_USE_STMT (use_stmt, ui, ptr) { gimple *def_stmt; @@ -403,7 +405,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, unlink_stmt_vdef (use_stmt); gsi_remove (&gsi, true); - phi_inserted = true; + changed = true; } /* Found a proper dereference. Insert a phi node if this @@ -424,6 +426,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, gsi_remove (&gsi, true); phi_inserted = true; + changed = true; } else { @@ -431,13 +434,14 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, load. */ gimple_assign_set_rhs1 (use_stmt, res); update_stmt (use_stmt); + changed = true; } next:; /* Continue searching for a proper dereference. */ } - return phi_inserted; + return changed; } /* Main entry for phiprop pass. */