diff options
author | Richard Biener <rguenther@suse.de> | 2018-02-08 13:29:15 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2018-02-08 13:29:15 +0000 |
commit | 24db2556253540529a7b11ed42683b2ea9bb8989 (patch) | |
tree | c5f4c37badfc0bb93dd13c20c4b36192bb6013a5 | |
parent | 3d2249215e948493d5aa7ad1aaaa9d9de73207c6 (diff) |
re PR middle-end/84233 (ICE (segfault) in gimple_assign_rhs_code)
2018-02-08 Richard Biener <rguenther@suse.de>
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
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr84233.C | 25 | ||||
-rw-r--r-- | gcc/tree-ssa-phiprop.c | 8 |
4 files changed, 42 insertions, 2 deletions
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 <rguenther@suse.de> + + 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 <mjambor@suse.cz> * 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,5 +1,10 @@ 2018-02-08 Richard Biener <rguenther@suse.de> + PR tree-optimization/84233 + * g++.dg/torture/pr84233.C: New testcase. + +2018-02-08 Richard Biener <rguenther@suse.de> + PR tree-optimization/84278 * gcc.target/i386/pr84278.c: New testcase. 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 <typename b> void c(b); +struct d { + long e; + template <typename> union f; + template <typename h> union f<h *> { + f(h *i) : j(i) {} + h *j; + long bits; + }; + static int k(volatile long &i) { return *(int *)f<volatile long *>(&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. */ |