Commit 24db2556 by Richard Biener Committed by Richard Biener

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
parent 3d224921
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> 2018-02-08 Martin Jambor <mjambor@suse.cz>
* hsa-gen.c (get_symbol_for_decl): Set program allocation for * hsa-gen.c (get_symbol_for_decl): Set program allocation for
......
2018-02-08 Richard Biener <rguenther@suse.de> 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 PR tree-optimization/84278
* gcc.target/i386/pr84278.c: New testcase. * gcc.target/i386/pr84278.c: New testcase.
......
// { 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, "", ""); }
...@@ -270,6 +270,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, ...@@ -270,6 +270,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
use_operand_p arg_p, use; use_operand_p arg_p, use;
ssa_op_iter i; ssa_op_iter i;
bool phi_inserted; bool phi_inserted;
bool changed;
tree type = NULL_TREE; tree type = NULL_TREE;
if (!POINTER_TYPE_P (TREE_TYPE (ptr)) if (!POINTER_TYPE_P (TREE_TYPE (ptr))
...@@ -317,6 +318,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, ...@@ -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 /* 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. */ can move the loads to the place of the ptr phi node. */
phi_inserted = false; phi_inserted = false;
changed = false;
FOR_EACH_IMM_USE_STMT (use_stmt, ui, ptr) FOR_EACH_IMM_USE_STMT (use_stmt, ui, ptr)
{ {
gimple *def_stmt; gimple *def_stmt;
...@@ -403,7 +405,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, ...@@ -403,7 +405,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
unlink_stmt_vdef (use_stmt); unlink_stmt_vdef (use_stmt);
gsi_remove (&gsi, true); gsi_remove (&gsi, true);
phi_inserted = true; changed = true;
} }
/* Found a proper dereference. Insert a phi node if this /* 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, ...@@ -424,6 +426,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
gsi_remove (&gsi, true); gsi_remove (&gsi, true);
phi_inserted = true; phi_inserted = true;
changed = true;
} }
else else
{ {
...@@ -431,13 +434,14 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, ...@@ -431,13 +434,14 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
load. */ load. */
gimple_assign_set_rhs1 (use_stmt, res); gimple_assign_set_rhs1 (use_stmt, res);
update_stmt (use_stmt); update_stmt (use_stmt);
changed = true;
} }
next:; next:;
/* Continue searching for a proper dereference. */ /* Continue searching for a proper dereference. */
} }
return phi_inserted; return changed;
} }
/* Main entry for phiprop pass. */ /* Main entry for phiprop pass. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment